Change to the spec...missed a consistency property. Adding timing option.
[repair.git] / Repair / RepairInterpreter / file.h
1 #ifndef FILE_H
2 #define FILE_H
3
4 #define BLOCKSIZE 8192
5 #define NUMBLOCK 1024
6 #define LENGTH BLOCKSIZE*NUMBLOCK
7 #define NUMINODES BLOCKSIZE/56
8 #define NUMFILES 100
9
10 struct block {
11   char array[BLOCKSIZE];
12 };
13
14
15 struct SuperBlock {
16   int FreeBlockCount;
17   int FreeInodeCount;
18   int NumberofBlocks;
19   int NumberofInodes;
20   int RootDirectoryInode;
21   int blocksize;
22 };
23
24
25 struct GroupBlock {
26   int BlockBitmapBlock;
27   int InodeBitmapBlock;
28   int InodeTableBlock;
29   int GroupFreeBlockCount;
30   int GroupFreeInodeCount;
31 };
32
33
34 struct BlockBitmap {
35   char blocks[NUMBLOCK/8+1];
36 };
37
38
39 struct InodeBitmap {
40   char inode[NUMINODES/8+1];
41 };
42
43
44 struct Inode {
45   int filesize;
46   int Blockptr[12];
47   int referencecount;
48 };
49
50
51 //the inode table
52 struct InodeBlock {
53   struct Inode entries[NUMINODES];
54 };
55
56
57 #define DIRECTORYENTRYSIZE 128
58 struct DirectoryEntry {
59   char name[124];
60   int inodenumber;
61 };
62
63
64
65 struct DirectoryBlock {
66   struct DirectoryEntry entries[BLOCKSIZE/128];
67 };
68
69
70
71
72
73 void createdisk();
74 void createfile(struct block *ptr,char *filename, char *buf,int buflen);
75 void addtode(struct block *ptr, int inode, char * filename);
76 int getinode(struct block *ptr);
77 int getblock(struct block * ptr);
78
79 void removefile(char *filename, struct block *ptr);
80 void createlink(struct block *ptr,char *filename, char *linkname);
81 struct block * chmountdisk(char *filename);
82 void chunmountdisk(struct block *vptr);
83 struct block * mountdisk(char *filename);
84 void unmountdisk(struct block *vptr);
85 void closefile(struct block *ptr, int fd);
86 bool writefile(struct block *ptr, int fd, char *s);
87 int writefile(struct block *ptr, int fd, char *s, int len);
88 char readfile(struct block *ptr, int fd);
89 int readfile(struct block *ptr, int fd, char *buf, int len);
90 int openfile(struct block *ptr, char *filename);
91
92 void printdirectory(struct block *ptr);
93 void printfile(char *filename, struct block *ptr);
94 void printinodeblock(struct block* ptr);
95
96
97 #define MAXFILES 300
98 struct filedesc {
99   int inode;
100   int offset;
101   bool used;
102 };
103 #endif
104