1

The xv6 mkfs.c file declare the variables:

int nblocks = 985;
int nlog = LOGSIZE;
int ninodes = 200;
int size = 1024;

That declaration should work properly with inode that have 12 direct blocks and 1 indirect block, what i don't understand is why nblocks is defined as 985? The number of blocks in one inode is 140 (128 for the indirect + 12 direct), so i don't fully understand where is 985 came from and also the size of 1024.

If i would understand that part i think i will be able to change the variables to support triple indirection.

Thanks!

avivar
  • 25
  • 2
  • this may be helpful: http://stackoverflow.com/questions/30853617/xv6-crashes-when-trying-to-implement-triple-indirection-in-xv6-operating-system – Paolo Jun 19 '15 at 08:52
  • yes, but still i don't understand the calculation behind it. – avivar Jun 19 '15 at 11:02

1 Answers1

0

An inode takes only 32 bytes on disk (sizeof(struct inode)). Only when writing to an inode it starts to take more space (blocks) on disk.

Notice this block of code:

bitblocks = size/(512*8) + 1;
usedblocks = ninodes / IPB + 3 + bitblocks;
...
assert(nblocks + usedblocks + nlog == size);
Doron Cohen
  • 1,026
  • 8
  • 13