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
00044
00045 struct ubixDiskLabel {
00046 uInt32 magicNum;
00047 uInt32 magicNum2;
00048 uInt16 driveType;
00049 uInt16 numPartitions;
00050 struct drivePartitions {
00051 uInt32 pSize;
00052 uInt32 pOffset;
00053 uInt32 pFsSize;
00054 uInt32 pBatSize;
00055 uInt8 pFsType;
00056 uInt8 pFrag;
00057 } partitions[MAXPARTITIONS];
00058 };
00059
00060 struct partitionInformation {
00061 uInt32 size;
00062 uInt32 startSector;
00063 uInt32 blockAllocationTable;
00064 uInt32 rootDirectory;
00065 };
00066
00067
00068 struct blockAllocationTableEntry {
00069 long attributes;
00070 long realSector;
00071 long nextBlock;
00072 long reserved;
00073 };
00074
00075
00076 struct directoryEntry {
00077 uInt32 startCluster;
00078 uInt32 size;
00079 uInt32 creationDate;
00080 uInt32 lastModified;
00081 uInt32 uid;
00082 uInt32 gid;
00083 uShort attributes;
00084 uShort permissions;
00085 char fileName[256];
00086 };
00087
00088 struct bootSect {
00089 uChar jmp[4];
00090 uChar id[6];
00091 uShort version;
00092 uShort tmp;
00093 uShort fsStart;
00094 uShort tmp2;
00095 uInt32 krnl_start;
00096 uInt BytesPerSector;
00097 uInt SectersPerTrack;
00098 uInt TotalHeads;
00099 uInt32 TotalSectors;
00100 uChar code[479];
00101 };
00102
00103 struct ubixFsInfo {
00104 struct blockAllocationTableEntry *blockAllocationTable;
00105 uInt32 batEntries;
00106 };
00107
00108 int readFile(char *file);
00109 int writeFileByte(int ch,fileDescriptor *fd,long offset);
00110 int openFileUbixFS(char *file,fileDescriptor *fd);
00111 int mkDirUbixFS(char *dir,fileDescriptor *fd);
00112 int getFreeBlocks(int count,fileDescriptor *fd);
00113
00114
00115
00116 void initUbixFS(struct mountPoints *mp);
00117 int enableUbixFS();
00118 int readUbixFS(fileDescriptor *fd,char *data,long offset,long size);
00119 int writeUbixFS(fileDescriptor *fd,char *data,long offset,long size);
00120 void syncBat(struct mountPoints *mp);
00121 int freeBlocks(int block,fileDescriptor *fd);
00122 int addDirEntry(struct directoryEntry *dir,fileDescriptor *fd);
00123 void ubixFSUnlink(char *path,struct mountPoints *mp);
00124
00125 #endif