Ext3 Block Group Descriptor

994 views Asked by At

I am having a problem understanding how to find Block Group Descriptor table. In literature (D.Poirier: "The 2nd extended filesystem") is stated that block group descriptor is located in block right after superblock.

Now, when I look at first disk, with block size of 1024 bytes, structure is like this:

  • MBR, 0-512 bytes
  • Superblock, 1536-2560 bytes
  • BG Descriptor, 2560 - ... bytes

And this structure is fine, because superblock starts with 3rd sector and BGD follows right after. However, when I look at second disk with block size of 4096 bytes, structure is like this:

  • MBR, 0-512 bytes
  • Superblock, 1536-2560 bytes
  • BG Descriptor, 4608 - ... bytes

In this case, BGD is located 3072(?) bytes away from superblock. Could someone enlight me and tell me how exactly is BGD position determined, because I'm writing a program that reads and analyses ext structure, and I can't write a generic program that knows how to find BGD.

1

There are 1 answers

0
wenqing On BEST ANSWER

the BGD starts offset can vary depending on the block size (1k, 2k, 4k). In a partition, the first 1024 bytes are reserved, then followed with 1024 bytes of SUPER BLOCK. Depending on the block size, the BGD starts from:

BLK=1K, the BGD starts at partition offset 2048 (1024 reserved + 1024 super block).

BLK=2K, the BGD starts at partition offset 2048 (1024 reserved + 1024 super block).

BLK=4K, the BGD starts at partition offset 4096, which is 1 block from start, that is the result you see 3072 bytes apart from the super block.