diff options
author | Frans Kaashoek <[email protected]> | 2015-06-27 12:39:13 -0400 |
---|---|---|
committer | Frans Kaashoek <[email protected]> | 2015-06-27 12:39:13 -0400 |
commit | 8320d61be5613fb2875be859695752b1487fda20 (patch) | |
tree | f0a800145225ffcd97f805be47e5b41764504898 /fs.h | |
parent | de4af193c87b3a7fa8762ccaeb81a6addf168799 (diff) | |
download | xv6-labs-8320d61be5613fb2875be859695752b1487fda20.tar.gz xv6-labs-8320d61be5613fb2875be859695752b1487fda20.tar.bz2 xv6-labs-8320d61be5613fb2875be859695752b1487fda20.zip |
Pick up where i left off in april:
- move log into metadata part of disk, so that marking
that the log's blocks are in use falls out for free
- superblock describes the whole disk (sizes and offets)
- sizes and offsets are computed in one place (mkfs) and
the rest of the code refers to the superblock for these values,
instead of recomputing them.
Diffstat (limited to 'fs.h')
-rw-r--r-- | fs.h | 21 |
1 files changed, 11 insertions, 10 deletions
@@ -1,22 +1,23 @@ // On-disk file system format. // Both the kernel and user programs use this header file. -// Block 0 is unused. -// Block 1 is super block. -// Blocks 2 through sb.ninodes/IPB hold inodes. -// Then free bitmap blocks holding sb.size bits. -// Then sb.nblocks data blocks. -// Then sb.nlog log blocks. #define ROOTINO 1 // root i-number #define BSIZE 512 // block size -// File system super block +// Disk layout: +// [ boot block | super block | log | inode blocks | free bit map | data blocks ] +// +// mkfs computes the super block and builds an initial file system. The super describes +// the disk layout: struct superblock { uint size; // Size of file system image (blocks) uint nblocks; // Number of data blocks uint ninodes; // Number of inodes. uint nlog; // Number of log blocks + uint logstart; // Block number of first log block + uint inodestart; // Block number of first inode block + uint bmapstart; // Block number of first free map block }; #define NDIRECT 12 @@ -37,13 +38,13 @@ struct dinode { #define IPB (BSIZE / sizeof(struct dinode)) // Block containing inode i -#define IBLOCK(i) ((i) / IPB + 2) +#define IBLOCK(i, sb) ((i) / IPB + sb.inodestart) // Bitmap bits per block #define BPB (BSIZE*8) -// Block containing bit for block b -#define BBLOCK(b, ninodes) (b/BPB + (ninodes)/IPB + 3) +// Block of free map containing bit for block b +#define BBLOCK(b, sb) (b/BPB + sb.bmapstart) // Directory is a file containing a sequence of dirent structures. #define DIRSIZ 14 |