-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsfs_api.h
65 lines (54 loc) · 1.4 KB
/
sfs_api.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "disk_emu.h"
#define _BLOCK_SIZE 1024
#define _INODE_SIZE 16
#define _NUMBER_OF_BLOCKS 2850
#define _NUMBER_OF_INODES 224
typedef struct blocks{
unsigned char bytes[_BLOCK_SIZE];
// unsigned char byte;
}Block;
typedef struct iNodes{
int size;
unsigned int direct[14];
unsigned int indirect;
}INode;
typedef struct rootDirsEntries{
char fileName[16];
int iNodeNumber;
}RootDirectoryEntry;
typedef struct rootdirs{
RootDirectoryEntry lookUpTable[224];
}RootDirectory;
typedef struct superBlocks{
unsigned char magic[4];
unsigned int blockSize;
unsigned int blocksCount;
unsigned int freeBlocks;
unsigned int iNodesCount;
INode jNode;
}SuperBlock;
typedef struct fileDescs{
unsigned int iNodeNumber;
unsigned int readPointer;
unsigned int writePointer;
unsigned int freeBit;
}FileDesc;
typedef struct fileDescTables{
FileDesc table[200];
}FileDescTable;
//Functions you should implement.
//Return -1 for error besides mkssfs
void mkssfs(int fresh);
int ssfs_fopen(char *name);
int ssfs_fclose(int fileID);
int ssfs_frseek(int fileID, int loc);
int ssfs_fwseek(int fileID, int loc);
int ssfs_fwrite(int fileID, char *buf, int length);
int ssfs_fread(int fileID, char *buf, int length);
int ssfs_remove(char *file);
int ssfs_commit();
int ssfs_restore(int cnum);