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