Loading [MathJax]/extensions/tex2jax.js
CS350 COS
COS
All Data Structures Files Functions Variables Typedefs Macros
o2fs.h
Go to the documentation of this file.
1
2#ifndef __FS_O2FS_H__
3#define __FS_O2FS_H__
4
5/*
6 * *** Disk Layout ***
7 *
8 * +---------------------+
9 * | Super Blocks (4MBs) |
10 * +---------------------+
11 * | |
12 * .
13 * .
14 * .
15 * | |
16 * +---------------------+
17 * | Super Blocks (4MBs) |
18 * +---------------------+
19 *
20 */
21
22#define MAXUSERNAMELEN 32
23#define MAXNAMELEN 255
24
25/*
26 * *** Version History ***
27 * 1.0 Initial release
28 */
29
30#define O2FS_VERSION_MAJOR 1
31#define O2FS_VERSION_MINOR 0
32
33/*
34 * Object ID: Pointer to a block node
35 */
36typedef struct ObjID {
41
42/*
43 * Super block
44 */
45typedef struct SuperBlock
46{
47 uint8_t magic[8]; /* Superblock Magic */
48 uint16_t versionMajor; /* Major Version Number */
49 uint16_t versionMinor; /* Minor Version Number */
51 uint64_t features; /* Feature Flags */
52 uint64_t blockCount; /* Total Blocks */
53 uint64_t blockSize; /* Block Size in Bytes */
54 uint64_t bitmapSize; /* Free Bitmap Size in Bytes */
55 uint64_t bitmapOffset; /* Free Bitmap Offset */
56
57 uint64_t version; /* Snapshot version */
58 ObjID root; /* Root Tree */
59
62
63#define SUPERBLOCK_MAGIC "SUPRBLOK"
64
65/*
66 * Block Pointer: Address raw blocks on the disk
67 */
68typedef struct BPtr {
75
76
77#define O2FS_DIRECT_PTR (64)
78
79/*
80 * Block Nodes: Contain indirect pointers to pieces of a file
81 */
82typedef struct BNode
83{
89
92
93#define BNODE_MAGIC "BLOKNODE"
94
95/*
96 * Directory entries are exactly 512 bytes
97 */
98typedef struct BDirEntry
99{
106 uint8_t user[MAXUSERNAMELEN]; // Not null terminated
109 uint8_t name[MAXNAMELEN+1]; // Null terminated
111
112#define BDIR_MAGIC "DIRENTRY"
113
114#endif /* __FS_O2FS_H__ */
115
uint64_t flags
Definition: o2fs.h:103
uint8_t magic[8]
Definition: o2fs.h:84
uint64_t device
Definition: o2fs.h:38
uint8_t hash[32]
Definition: o2fs.h:69
uint8_t magic[8]
Definition: o2fs.h:47
ObjID root
Definition: o2fs.h:58
uint8_t padding[104]
Definition: o2fs.h:108
uint8_t name[MAXNAMELEN+1]
Definition: o2fs.h:109
uint64_t blockCount
Definition: o2fs.h:52
uint64_t offset
Definition: o2fs.h:71
uint64_t _rsvd0
Definition: o2fs.h:72
#define MAXNAMELEN
Definition: o2fs.h:23
uint64_t features
Definition: o2fs.h:51
uint16_t versionMinor
Definition: o2fs.h:86
#define MAXUSERNAMELEN
Definition: o2fs.h:22
uint64_t device
Definition: o2fs.h:70
uint16_t versionMinor
Definition: o2fs.h:49
uint16_t versionMajor
Definition: o2fs.h:48
uint64_t mtime
Definition: o2fs.h:105
uint64_t version
Definition: o2fs.h:57
uint8_t hash[32]
Definition: o2fs.h:37
uint64_t offset
Definition: o2fs.h:39
uint64_t ctime
Definition: o2fs.h:104
uint64_t bitmapSize
Definition: o2fs.h:54
uint64_t size
Definition: o2fs.h:102
uint64_t blockSize
Definition: o2fs.h:53
uint64_t size
Definition: o2fs.h:88
uint8_t user[MAXUSERNAMELEN]
Definition: o2fs.h:106
ObjID objId
Definition: o2fs.h:101
#define O2FS_DIRECT_PTR
Definition: o2fs.h:77
uint8_t group[MAXUSERNAMELEN]
Definition: o2fs.h:107
uint16_t versionMajor
Definition: o2fs.h:85
uint32_t flags
Definition: o2fs.h:87
uint8_t hash[32]
Definition: o2fs.h:60
uint64_t _rsvd1
Definition: o2fs.h:73
BPtr direct[O2FS_DIRECT_PTR]
Definition: o2fs.h:90
uint64_t bitmapOffset
Definition: o2fs.h:55
uint8_t magic[8]
Definition: o2fs.h:100
uint32_t _rsvd0
Definition: o2fs.h:50
Definition: o2fs.h:99
Definition: o2fs.h:83
Definition: o2fs.h:68
Definition: o2fs.h:36
unsigned short uint16_t
Definition: types.h:11
unsigned int uint32_t
Definition: types.h:12
unsigned long uint64_t
Definition: types.h:13
unsigned char uint8_t
Definition: types.h:10