00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 #ifndef _UBIXFS_H
00031 #define _UBIXFS_H
00032 
00033 #include <ubixos/types.h>
00034 #include <vfs/vfs.h>
00035 #include <sys/device.h>
00036 #include <mpi/mpi.h>
00037 #include <ubixfs/dirCache.h>
00038 
00039 
00040 #define UBIXFS_BLOCKSIZE_BYTES     blockSize*512
00041 #define UBIXFS_ALIGN(size) (size + ((((size) % (UBIXFS_BLOCKSIZE_BYTES)) == 0)? 0 : ((UBIXFS_BLOCKSIZE_BYTES) - ((size) % (UBIXFS_BLOCKSIZE_BYTES)))))
00042 
00043 #define UBIXDISKMAGIC     ((uInt32)0x45) 
00044 #define MAXUBIXPARTITIONS 16
00045 #define blockSize         8
00046 
00047 
00048 #define EOBC              -1
00049 
00050 
00051 #define typeFile      1
00052 #define typeContainer 2
00053 #define typeDirectory 4
00054 #define typeDeleted   8
00055 
00056 
00057 struct directoryList {
00058   char                  dirName[256];
00059   char                 *dirCache;
00060   uInt32                dirBlock;
00061   struct directoryList *next;
00062   struct directoryList *prev;
00063   };
00064 
00065 typedef struct directoryList * dirList_t;
00066 
00067 dirList_t ubixFSLoadDir(char *);
00068 
00069 
00070 
00071 struct ubixDiskLabel {
00072   uInt32 magicNum;
00073   uInt32 magicNum2;
00074   uInt16 driveType;
00075   uInt16 numPartitions;
00076   struct  ubixPartitions {  
00077     uInt32 pSize;            
00078     uInt32 pOffset;          
00079     uInt32 pFsSize;          
00080     uInt32 pBatSize;         
00081     uInt8 pFsType;          
00082     uInt8 pFrag;            
00083     } partitions[MAXUBIXPARTITIONS];
00084   };
00085 
00086 
00087 struct partitionInformation {
00088   uInt32 size;                 
00089   uInt32 startSector;          
00090   uInt32 blockAllocationTable; 
00091   uInt32 rootDirectory;        
00092   };
00093 
00094 
00095 struct blockAllocationTableEntry {
00096   long attributes; 
00097   long realSector; 
00098   long nextBlock;  
00099   long reserved;   
00100   };
00101 
00102 
00103 struct directoryEntry {
00104   uInt32  startCluster;   
00105   uInt32  size;           
00106   uInt32  creationDate;  
00107   uInt32  lastModified;  
00108   uInt32  uid;           
00109   uInt32  gid;           
00110   uInt16 attributes;    
00111   uInt16 permissions;   
00112   char   fileName[256]; 
00113   };
00114 
00115 struct bootSect {
00116   uInt8 jmp[4];
00117   uInt8 id[6];
00118   uInt16 version;
00119   uInt16 tmp;
00120   uInt16 fsStart;
00121   uInt16 tmp2;
00122   uInt32 krnl_start;
00123   uInt BytesPerSector;
00124   uInt SectersPerTrack;
00125   uInt TotalHeads;
00126   uInt32 TotalSectors;
00127   uInt8 code[479];
00128   };  
00129 
00130 struct ubixFSInfo {
00131   struct blockAllocationTableEntry *blockAllocationTable;
00132   struct cacheNode * dirCache;
00133   uInt32 batEntries;
00134   uInt32 rootDir;
00135 }; 
00136 
00137 int readFile(char *file);
00138 int writeFileByte(int ch,fileDescriptor *fd,long offset);
00139 
00140 int getFreeBlocks(int count,fileDescriptor *fd);
00141 
00142 
00143 
00144 
00145 
00146 int readUbixFS(fileDescriptor *fd,char *data,uInt32,long size);
00147 int writeUbixFS(fileDescriptor *fd,char *data,long offset,long size);
00148 void syncBat(vfs_mountPoint_t *mp);
00149 int freeBlocks(int block,fileDescriptor *fd);
00150 int addDirEntry(struct directoryEntry *dir,fileDescriptor *fd);
00151 void ubixFSUnlink(char *path,vfs_mountPoint_t *mp);
00152 int ubixFSmkDir(char *dir,fileDescriptor *fd);
00153 
00154 int  ubixfs_init();
00155 int  ubixfs_initialize();
00156 void ubixfs_thread();
00157 
00158 
00159 #endif
00160 
00161 
00162 
00163 
00164 
00165 
00166 
00167 
00168 
00169 
00170 
00171 
00172 
00173 
00174 
00175 
00176 
00177 
00178 
00179 
00180 
00181 
00182 
00183 
00184 
00185 
00186 
00187 
00188 
00189 
00190 
00191 
00192 
00193 
00194 
00195 
00196 
00197 
00198 
00199 
00200