00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _UBIXFS_H
00025 #define _UBIXFS_H
00026
00027 #include <ubixos/types.h>
00028 #include <sys/device.h>
00029 #include <vfs/file.h>
00030
00031 #define UBIXDISKMAGIC ((uInt32)0x45)
00032 #define MAXPARTITIONS 4
00033 #define blockSize 8
00034 #define blockByteSize blockSize*512
00035
00036 #define EOBC -1
00037
00038
00039 #define typeFile 1
00040 #define typeContainer 2
00041 #define typeDirectory 4
00042 #define typeDeleted 8
00043
00045 struct ubixDiskLabel {
00046 uInt32 magicNum;
00049 uInt16 numPartitions;
00051 struct drivePartitions {
00052 uInt32 pSize;
00053 uInt32 pOffset;
00054 uInt32 pFsSize;
00055 uInt32 pBatSize;
00056 uInt8 pFsType;
00057 uInt8 pFrag;
00058 } partitions[MAXPARTITIONS];
00059 };
00060
00061 struct partitionInformation {
00062 uInt32 size;
00063 uInt32 startSector;
00064 uInt32 blockAllocationTable;
00065 uInt32 rootDirectory;
00066 };
00067
00069 struct blockAllocationTableEntry {
00070 long attributes;
00071 long realSector;
00072 long nextBlock;
00073 long reserved;
00074 };
00075
00077 struct directoryEntry {
00078 uInt32 startCluster;
00079 uInt32 size;
00080 uInt32 creationDate;
00081 uInt32 lastModified;
00082 uInt32 uid;
00083 uInt32 gid;
00084 uInt16 attributes;
00085 uInt16 permissions;
00086 char fileName[256];
00087 };
00088
00090 struct bootSect {
00091 uInt8 jmp[4];
00092 uInt8 id[6];
00093 uInt16 version;
00094 uInt16 tmp;
00095 uInt16 fsStart;
00096 uInt16 tmp2;
00097 uInt32 krnl_start;
00098 uInt BytesPerSector;
00099 uInt SectersPerTrack;
00100 uInt TotalHeads;
00101 uInt32 TotalSectors;
00102 uInt8 code[479];
00103 };
00104
00106 struct ubixFsInfo {
00107 struct blockAllocationTableEntry *blockAllocationTable;
00108 uInt32 batEntries;
00109 };
00110
00111 int readFile(char *file);
00112 int writeFileByte(int ch,fileDescriptor *fd,long offset);
00116 int openFileUbixFS(char *file,fileDescriptor *fd);
00118 int mkDirUbixFS(char *dir,fileDescriptor *fd);
00119 int getFreeBlocks(int count,fileDescriptor *fd);
00120
00121
00124 int enableUbixFS();
00127 void initUbixFS(struct mountPoints *mp);
00130 int readUbixFS(fileDescriptor *fd,char *data,long offset,long size);
00133 int writeUbixFS(fileDescriptor *fd,char *data,long offset,long size);
00134 void syncBat(struct mountPoints *mp);
00135 int freeBlocks(int block,fileDescriptor *fd);
00136
00137 int addDirEntry(struct directoryEntry *dir,fileDescriptor *fd);
00139 void ubixFSUnlink(char *path,struct mountPoints *mp);
00140
00141 #endif