-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmfs.h
More file actions
77 lines (64 loc) · 1.67 KB
/
mfs.h
File metadata and controls
77 lines (64 loc) · 1.67 KB
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
66
67
68
69
70
71
72
73
74
75
76
#ifndef __MFS_h__
#define __MFS_h__
#define MFS_DIRECTORY (0)
#define MFS_REGULAR_FILE (1)
#define MFS_BLOCK_SIZE (4096)
//Syscall Number Codes
#define LOOKUP (0)
#define STAT (1)
#define WRITE (2)
#define READ (3)
#define CREAT (4)
#define UNLINK (5)
#define SHUTDOWN (6)
typedef struct __MFS_Stat_t {
int type; // MFS_DIRECTORY or MFS_REGULAR
int size; // bytes
int blocksUsed;
void *blocks[14];
// note: no permissions, access times, etc.
} MFS_Stat_t;
typedef struct __MFS_InodeMap_t{
int inodes[16];
} MFS_InodeMap_t;
typedef struct __MFS_Checkpoint_t{
int end;
int mapPieces[256];
} MFS_Checkpoint_t;
typedef struct __MFS_Inode_t{
int size;
int type;
int addrs[14];
} MFS_Inode_t;
typedef struct __MFS_DirEnt_t {
char name[28]; // up to 28 bytes of name in directory (including \0)
int inum; // inode number of entry (-1 means entry not used)
} MFS_DirEnt_t;
typedef struct __MFS_Dir_t{
char name[28];
int inum;
int entries[128];
} MFS_Dir_t;
typedef struct __ClientMessage_t{
int syscallNumber;
int type;
int inum;
int block;
char buffer[MFS_BLOCK_SIZE];
} ClientMessage_t;
typedef struct __ServerMessage_t{
int type;
int size;
int blocksUsed;
void *blocks[14];
char buffer[MFS_BLOCK_SIZE];
int returnCode;
} ServerMessage_t;
int MFS_Init(char *hostname, int port);
int MFS_Lookup(int pinum, char *name);
int MFS_Stat(int inum, MFS_Stat_t *m);
int MFS_Write(int inum, char *buffer, int block);
int MFS_Read(int inum, char *buffer, int block);
int MFS_Creat(int pinum, int type, char *name);
int MFS_Unlink(int pinum, char *name);
#endif // __MFS_h__