UbixOS  2.0
ubixfs.h
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2002-2018 The UbixOS Project.
3  * All rights reserved.
4  *
5  * This was developed by Christopher W. Olsen for the UbixOS Project.
6  *
7  * Redistribution and use in source and binary forms, with or without modification, are permitted
8  * provided that the following conditions are met:
9  *
10  * 1) Redistributions of source code must retain the above copyright notice, this list of
11  * conditions, the following disclaimer and the list of authors.
12  * 2) Redistributions in binary form must reproduce the above copyright notice, this list of
13  * conditions, the following disclaimer and the list of authors in the documentation and/or
14  * other materials provided with the distribution.
15  * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to
16  * endorse or promote products derived from this software without specific prior written
17  * permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
20  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef _UBIXFS_UBIXFS_H
30 #define _UBIXFS_UBIXFS_H
31 
32 #include <sys/types.h>
33 #include <vfs/vfs.h>
34 #include <sys/device.h>
35 #include <mpi/mpi.h>
36 #include <ubixfs/dirCache.h>
37 
38 #define UBIXFS_BLOCKSIZE_BYTES blockSize*512
39 #define UBIXFS_ALIGN(size) (size + ((((size) % (UBIXFS_BLOCKSIZE_BYTES)) == 0)? 0 : ((UBIXFS_BLOCKSIZE_BYTES) - ((size) % (UBIXFS_BLOCKSIZE_BYTES)))))
40 
41 #define UBIXDISKMAGIC ((uInt32)0x45) /* The disk magic number */
42 #define MAXUBIXPARTITIONS 16
43 #define blockSize 8
44 
45 #define EOBC -1
46 
47 #define typeFile 1
48 #define typeContainer 2
49 #define typeDirectory 4
50 #define typeDeleted 8
51 
52 /* Start */
53 struct directoryList {
54  char dirName[256];
55  char *dirCache;
59 };
60 
61 typedef struct directoryList * dirList_t;
62 
63 dirList_t ubixFSLoadDir(char *);
64 /* End */
65 
66 //Partition Information
67 struct ubixDiskLabel {
72  struct ubixPartitions { //the partition table
73  uInt32 pSize; //number of sectors in partition
74  uInt32 pOffset; //starting sector
75  uInt32 pFsSize; //filesystem basic fragment size
76  uInt32 pBatSize; //BAT size
77  uInt8 pFsType; //filesystem type, see below
78  uInt8 pFrag; //filesystem fragments per block
80 };
81 
83  uInt32 size; //Size In Sectors
84  uInt32 startSector; //Base Sector Of Partition
85  uInt32 blockAllocationTable; //Base Sector Of BAT
86  uInt32 rootDirectory; //Base Sector Of Root Directory
87 };
88 
89 //Block Allocation Table Entry
91  long attributes; //Block Attributes
92  long realSector; //Real Sector
93  long nextBlock; //Sector Of Next Block
94  long reserved; //Reserved
95 };
96 
97 //UbixFS Directory Entry
99  uInt32 startCluster; //Starting Cluster Of File
100  uInt32 size; //Size Of File
101  uInt32 creationDate; //Date Created
102  uInt32 lastModified; //Date Last Modified
103  uInt32 uid; //UID Of Owner
104  uInt32 gid; //GID Of Owner
105  uInt16 attributes; //Files Attributes
106  uInt16 permissions; //Files Permissions
107  char fileName[256]; //File Name
108 };
109 
110 struct bootSect {
111  uInt8 jmp[4];
112  uInt8 id[6];
122  uInt8 code[479];
123 };
124 
125 struct ubixFSInfo {
127  struct cacheNode * dirCache;
130 };
131 /* ubixFSInfo */
132 
133 int readFile(char *file);
134 int writeFileByte(int ch, fileDescriptor_t *fd, long offset);
135 //int openFileUbixFS(char *file,fileDescriptor_t *fd);
136 int getFreeBlocks(int count, fileDescriptor_t *fd);
137 //extern struct ubixDiskLabel *diskLabel;
138 
139 //Good Functions
140 //void initUbixFS(struct mountPoints *mp);
141 
142 int readUbixFS(fileDescriptor_t *fd, char *data, uInt32, long size);
143 int writeUbixFS(fileDescriptor_t *fd, char *data, long offset, long size);
144 void syncBat(struct vfs_mountPoint *mp);
145 int freeBlocks(int block, fileDescriptor_t *fd);
146 int addDirEntry(struct directoryEntry *dir, fileDescriptor_t *fd);
147 void ubixFSUnlink(char *path, struct vfs_mountPoint *mp);
148 int ubixFSmkDir(char *dir, fileDescriptor_t *fd);
149 
150 int ubixfs_init();
151 int ubixfs_initialize();
152 void ubixfs_thread();
153 
154 #endif /* END _UBIXFS_UBIXFS_H */
ubixDiskLabel::ubixPartitions::pSize
uInt32 pSize
Definition: ubixfs.h:73
ubixfs_initialize
int ubixfs_initialize()
directoryList::dirCache
char * dirCache
Definition: ubixfs.h:55
directoryEntry::lastModified
uInt32 lastModified
Definition: ubixfs.h:102
directoryList::next
struct directoryList * next
Definition: ubixfs.h:57
dirList_t
struct directoryList * dirList_t
Definition: ubixfs.h:61
ubixFSmkDir
int ubixFSmkDir(char *dir, fileDescriptor_t *fd)
Definition: directory.c:92
directoryEntry::permissions
uInt16 permissions
Definition: ubixfs.h:106
bootSect::jmp
uInt8 jmp[4]
Definition: ubixfs.h:111
directoryEntry::gid
uInt32 gid
Definition: ubixfs.h:104
blockAllocationTableEntry::attributes
long attributes
Definition: ubixfs.h:91
partitionInformation
Definition: ubixfs.h:82
uInt32
unsigned long int uInt32
Definition: objgfx30.h:49
ubixFSUnlink
void ubixFSUnlink(char *path, struct vfs_mountPoint *mp)
Definition: ubixfs.c:306
blockAllocationTableEntry::reserved
long reserved
Definition: ubixfs.h:94
vfs.h
uInt
unsigned int uInt
Definition: types.h:65
ubixDiskLabel::ubixPartitions::pFrag
uInt8 pFrag
Definition: ubixfs.h:78
uInt16
unsigned short int uInt16
Definition: objgfx30.h:48
partitionInformation::rootDirectory
uInt32 rootDirectory
Definition: ubixfs.h:86
directoryEntry::fileName
char fileName[256]
Definition: ubixfs.h:107
ubixDiskLabel::ubixPartitions::pFsType
uInt8 pFsType
Definition: ubixfs.h:77
fileDescriptor
Definition: file.h:62
ubixfs_thread
void ubixfs_thread()
ubixFSInfo
Definition: ubixfs.h:125
readUbixFS
int readUbixFS(fileDescriptor_t *fd, char *data, uInt32, long size)
Definition: ubixfs.c:192
blockAllocationTableEntry
Definition: ubixfs.h:90
file
Definition: descrip.h:67
ubixDiskLabel::magicNum2
uInt32 magicNum2
Definition: ubixfs.h:69
dirCache.h
directoryList::dirName
char dirName[256]
Definition: ubixfs.h:54
directoryList::prev
struct directoryList * prev
Definition: ubixfs.h:58
directoryEntry::attributes
uInt16 attributes
Definition: ubixfs.h:105
ubixDiskLabel::magicNum
uInt32 magicNum
Definition: ubixfs.h:68
directoryEntry
Definition: ubixfs.h:98
ubixDiskLabel::partitions
struct ubixDiskLabel::ubixPartitions partitions[16]
bootSect::TotalHeads
uInt TotalHeads
Definition: ubixfs.h:120
directoryEntry::creationDate
uInt32 creationDate
Definition: ubixfs.h:101
types.h
ubixFSInfo::rootDir
uInt32 rootDir
Definition: ubixfs.h:129
ubixDiskLabel::ubixPartitions::pOffset
uInt32 pOffset
Definition: ubixfs.h:74
directoryList
Definition: ubixfs.h:53
getFreeBlocks
int getFreeBlocks(int count, fileDescriptor_t *fd)
Definition: block.c:95
ubixFSLoadDir
dirList_t ubixFSLoadDir(char *)
Definition: directory.c:39
vfs_mountPoint
Definition: mount.h:66
MAXUBIXPARTITIONS
#define MAXUBIXPARTITIONS
Definition: ubixfs.h:42
ubixDiskLabel::numPartitions
uInt16 numPartitions
Definition: ubixfs.h:71
mpi.h
uInt8
unsigned char uInt8
Definition: objgfx30.h:47
directoryEntry::startCluster
uInt32 startCluster
Definition: ubixfs.h:99
partitionInformation::blockAllocationTable
uInt32 blockAllocationTable
Definition: ubixfs.h:85
cacheNode::size
int * size
Definition: dirCache.h:43
blockAllocationTableEntry::realSector
long realSector
Definition: ubixfs.h:92
readFile
int readFile(char *file)
writeUbixFS
int writeUbixFS(fileDescriptor_t *fd, char *data, long offset, long size)
Definition: ubixfs.c:229
ubixDiskLabel
Definition: ubixfs.h:67
bootSect
Definition: ubixfs.h:110
device.h
ubixDiskLabel::ubixPartitions
Definition: ubixfs.h:72
directoryList::dirBlock
uInt32 dirBlock
Definition: ubixfs.h:56
bootSect::tmp2
uInt16 tmp2
Definition: ubixfs.h:116
partitionInformation::startSector
uInt32 startSector
Definition: ubixfs.h:84
addDirEntry
int addDirEntry(struct directoryEntry *dir, fileDescriptor_t *fd)
Definition: directory.c:64
freeBlocks
int freeBlocks(int block, fileDescriptor_t *fd)
Definition: block.c:78
ubixDiskLabel::ubixPartitions::pFsSize
uInt32 pFsSize
Definition: ubixfs.h:75
bootSect::BytesPerSector
uInt BytesPerSector
Definition: ubixfs.h:118
ubixFSInfo::blockAllocationTable
struct blockAllocationTableEntry * blockAllocationTable
Definition: ubixfs.h:126
ubixFSInfo::batEntries
uInt32 batEntries
Definition: ubixfs.h:128
bootSect::fsStart
uInt16 fsStart
Definition: ubixfs.h:115
syncBat
void syncBat(struct vfs_mountPoint *mp)
Definition: block.c:73
ubixFSInfo::dirCache
struct cacheNode * dirCache
Definition: ubixfs.h:127
bootSect::TotalSectors
uInt32 TotalSectors
Definition: ubixfs.h:121
writeFileByte
int writeFileByte(int ch, fileDescriptor_t *fd, long offset)
Definition: ubixfs.c:116
partitionInformation::size
uInt32 size
Definition: ubixfs.h:83
bootSect::version
uInt16 version
Definition: ubixfs.h:113
ubixDiskLabel::ubixPartitions::pBatSize
uInt32 pBatSize
Definition: ubixfs.h:76
bootSect::tmp
uInt16 tmp
Definition: ubixfs.h:114
bootSect::code
uInt8 code[479]
Definition: ubixfs.h:122
directoryEntry::size
uInt32 size
Definition: ubixfs.h:100
ubixfs_init
int ubixfs_init()
Definition: ubixfs.c:450
ubixDiskLabel::driveType
uInt16 driveType
Definition: ubixfs.h:70
bootSect::krnl_start
uInt32 krnl_start
Definition: ubixfs.h:117
blockAllocationTableEntry::nextBlock
long nextBlock
Definition: ubixfs.h:93
bootSect::SectersPerTrack
uInt SectersPerTrack
Definition: ubixfs.h:119
cacheNode
Definition: dirCache.h:35
directoryEntry::uid
uInt32 uid
Definition: ubixfs.h:103