1 // See COPYRIGHT for copyright information.
8 // File nodes (both in-memory and on-disk)
10 // Bytes per file system block - same as page size
11 #define BLKSIZE PGSIZE
12 #define BLKBITSIZE (BLKSIZE * 8)
14 // Maximum size of a filename (a single path component), including null
15 // Must be a multiple of 4
16 #define MAXNAMELEN 128
18 // Maximum size of a complete pathname, including null
19 #define MAXPATHLEN 1024
21 // Number of block pointers in a File descriptor
23 // Number of direct block pointers in an indirect block
24 #define NINDIRECT (BLKSIZE / 4)
26 #define MAXFILESIZE (NINDIRECT * BLKSIZE)
29 char f_name
[MAXNAMELEN
]; // filename
30 off_t f_size
; // file size in bytes
31 uint32_t f_type
; // file type
34 // A block is allocated iff its value is != 0.
35 uint32_t f_direct
[NDIRECT
]; // direct blocks
36 uint32_t f_indirect
; // indirect block
38 // Points to the directory in which this file lives.
39 // Meaningful only in memory; the value on disk can be garbage.
40 // dir_lookup() sets the value when required.
43 // Pad out to 256 bytes; must do arithmetic in case we're compiling
44 // fsformat on a 64-bit machine.
45 uint8_t f_pad
[256 - MAXNAMELEN
- 8 - 4*NDIRECT
- 4 - sizeof(struct File
*)];
46 } __attribute__((packed
)); // required only on some 64-bit machines
48 // An inode block contains exactly BLKFILES 'struct File's
49 #define BLKFILES (BLKSIZE / sizeof(struct File))
52 #define FTYPE_REG 0 // Regular file
53 #define FTYPE_DIR 1 // Directory
56 // File system super-block (both in-memory and on-disk)
58 #define FS_MAGIC 0x4A0530AE // related vaguely to 'J\0S!'
61 uint32_t s_magic
; // Magic number: FS_MAGIC
62 uint32_t s_nblocks
; // Total number of blocks on disk
63 struct File s_root
; // Root directory node
66 // Definitions for requests from clients to file system
70 #define FSREQ_SET_SIZE 3
73 #define FSREQ_REMOVE 6
77 char req_path
[MAXPATHLEN
];
86 struct Fsreq_set_size
{
100 struct Fsreq_remove
{
101 char req_path
[MAXPATHLEN
];
104 #endif /* !JOS_INC_FS_H */