-
Notifications
You must be signed in to change notification settings - Fork 220
/
simple.h
92 lines (72 loc) · 2.46 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#define SIMPLEFS_MAGIC 0x10032013
#define SIMPLEFS_JOURNAL_MAGIC = 0x20032013
#define SIMPLEFS_DEFAULT_BLOCK_SIZE 4096
#define SIMPLEFS_FILENAME_MAXLEN 255
#define SIMPLEFS_START_INO 10
/**
* Reserver inodes for super block, inodestore
* and datablock
*/
#define SIMPLEFS_RESERVED_INODES 3
#ifdef SIMPLEFS_DEBUG
#define sfs_trace(fmt, ...) { \
printk(KERN_ERR "[simplefs] %s +%d:" fmt, \
__FILE__, __LINE__, ##__VA_ARGS__); \
}
#define sfs_debug(level, fmt, ...) { \
printk(level "[simplefs]:" fmt, ##__VA_ARGS__); \
}
#else
#define sfs_trace(fmt, ...) no_printk(fmt, ##__VA_ARGS__)
#define sfs_debug(level, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
#endif
/* 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;
/** Journal settings */
const int SIMPLEFS_JOURNAL_INODE_NUMBER = 2;
const int SIMPLEFS_JOURNAL_BLOCK_NUMBER = 2;
const int SIMPLEFS_JOURNAL_BLOCKS = 2;
/* The disk block where the name+inode_number pairs of the
* contents of the root directory are stored */
const int SIMPLEFS_ROOTDIR_DATABLOCK_NUMBER = 4;
#define SIMPLEFS_LAST_RESERVED_BLOCK SIMPLEFS_ROOTDIR_DATABLOCK_NUMBER
#define SIMPLEFS_LAST_RESERVED_INODE SIMPLEFS_JOURNAL_INODE_NUMBER
/* 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 journal_s;
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;
/** FIXME: move this into separate struct */
struct journal_s *journal;
char padding[4048];
};