forked from psankar/simplefs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple.h
56 lines (44 loc) · 1.54 KB
/
simple.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
#define SIMPLEFS_MAGIC 0x10032013
#define SIMPLEFS_DEFAULT_BLOCK_SIZE 4096
#define SIMPLEFS_FILENAME_MAXLEN 255
/* Hard-coded inode number for the root directory */
const int SIMPLEFS_ROOTDIR_INODE_NUMBER = 1;
/* The disk block where super block is stored */
const int SIMPLEFS_SUPERBLOCK_BLOCK_NUMBER = 0;
/* The disk block where the inodes are stored */
const int SIMPLEFS_INODESTORE_BLOCK_NUMBER = 1;
/* The disk block where the name+inode_number pairs of the
* contents of the root directory are stored */
const int SIMPLEFS_ROOTDIR_DATABLOCK_NUMBER = 2;
/* The name+inode_number pair for each file in a directory.
* This gets stored as the data for a directory */
struct simplefs_dir_record {
char filename[SIMPLEFS_FILENAME_MAXLEN];
uint64_t inode_no;
};
struct simplefs_inode {
mode_t mode;
uint64_t inode_no;
uint64_t data_block_number;
union {
uint64_t file_size;
uint64_t dir_children_count;
};
};
const int SIMPLEFS_MAX_FILESYSTEM_OBJECTS_SUPPORTED = 64;
/* min (
SIMPLEFS_DEFAULT_BLOCK_SIZE / sizeof(struct simplefs_inode),
sizeof(uint64_t) //The free_blocks tracker in the sb
); */
/* FIXME: Move the struct to its own file and not expose the members
* Always access using the simplefs_sb_* functions and
* do not access the members directly */
struct simplefs_super_block {
uint64_t version;
uint64_t magic;
uint64_t block_size;
/* FIXME: This should be moved to the inode store and not part of the sb */
uint64_t inodes_count;
uint64_t free_blocks;
char padding[SIMPLEFS_DEFAULT_BLOCK_SIZE - (5 * sizeof(uint64_t))];
};