Error In EXT2 Documentation

All about the OSDev Wiki. Discussions about the organization and general structure of articles and how to use the wiki. Request changes here if you don't know how to use the wiki.
Post Reply
User avatar
Pancakes
Member
Member
Posts: 75
Joined: Mon Mar 19, 2012 1:52 pm

Error In EXT2 Documentation

Post by Pancakes »

http://wiki.osdev.org/Ext2

The original text stated that if the blockSize is 1024 that the first group block descriptor will start at the 2nd block (zero indexed) or aka 2048, and if the bockSize was other than 1024 the first group block descriptor will start at the 1st block (zero indexed).

Of course this did not make a lot of sense, but I discovered that instead (and this way makes more sense) that if the blockSize is 1024 that the first block group descriptor will start at 1024. This I actually tested and found to be true after using mkfs.ext2.

I am not sure and can not test but it maybe if the majorVersion field is >= 1 then you will have the extended super block (2048 byte superblock instead of 1024) and then it would make sense for the first group descriptor block to start at offset 2048 instead of 1024 because otherwise you would have the extended superblock (1024 bytes) and the first block group descriptor sitting on top of each other which has to be incorrect.

EDIT:
Anyway, I left a note there for future readers. To at least get them to double check if they run into problems, and hopefully if one or more people verify then we could fix it on the wiki.

EDIT:
Wait, found something funny in my own code. Maybe indeed the wiki page is correct. Let me figure out what kind of weird mistake I made.
User avatar
Yoda
Member
Member
Posts: 255
Joined: Tue Mar 09, 2010 8:57 am
Location: Moscow, Russia

Re: Error In EXT2 Documentation

Post by Yoda »

Pancakes wrote:The original text stated that if the blockSize is 1024 that the first group block descriptor will start at the 2nd block (zero indexed) or aka 2048, and if the bockSize was other than 1024 the first group block descriptor will start at the 1st block (zero indexed).

That's all right.

Pancakes wrote:but I discovered that instead (and this way makes more sense) that if the blockSize is 1024 that the first block group descriptor will start at 1024.

This is impossible because at 1024 there is always superblock, not BGDT. It is explicitly documented and tested. Superblock occupies 1024 bytes, that's why BGDT starts at least at position 2048.

Pancakes wrote:I am not sure and can not test but it maybe if the majorVersion field is >= 1 then you will have the extended super block (2048 byte superblock instead of 1024)

There is no such thing as extended superblock (no matter what version is).
Yet Other Developer of Architecture.
OS Boot Tools.
Russian national OSDev forum.
User avatar
Pancakes
Member
Member
Posts: 75
Joined: Mon Mar 19, 2012 1:52 pm

Re: Error In EXT2 Documentation

Post by Pancakes »

Yeah, but it says right here:


Extended Superblock Fields
These fields are only present if Major version (specified in the base superblock fields), is greater than or equal to 1...


Even the documentation said extended super block fields.

Edit:
I just pulled a page here: http://www.science.unitn.it/~fiorella/g ... ode95.html

It seems to depict a super block before every BGDT, which is quite confusing, lol. I am going to try to make my file system use a second BGDT and then see what everything does.
User avatar
Pancakes
Member
Member
Posts: 75
Joined: Mon Mar 19, 2012 1:52 pm

Re: Error In EXT2 Documentation

Post by Pancakes »

The table is located in the block immediately following the Superblock. So if the block size (determined from a field in the superblock) is 1024 bytes per block, the Block Group Descriptor Table will begin at block 2. For any other block size, it will begin at block 1. Remember that blocks are numbered starting at 0, and that block numbers don't usually correspond to physical block addresses.

Code: Select all

[1] It is located in the table immediately following the superblock.
[2] if block size == 1024:
     [0]
     [1] superbock
     [2] BGDT
[3] if block size == 2048:
    [0]
    [1] superblock ... BGDT will overwrite superbock


I maybe misinterpreting (of course) what he means by block in that paragraph. It is obvious that the way it is worded can be confusing right?
User avatar
Yoda
Member
Member
Posts: 255
Joined: Tue Mar 09, 2010 8:57 am
Location: Moscow, Russia

Re: Error In EXT2 Documentation

Post by Yoda »

Pancakes wrote:Extended Superblock Fields
These fields are only present if Major version (specified in the base superblock fields), is greater than or equal to 1...

Even the documentation said extended super block fields.

Yes. But that extended fields are located at the same 1024 bytes of superblock. Just used bytes that were free in previous versions.

Use this documentation instead: http://www.nongnu.org/ext2-doc/

Pancakes wrote:The table is located in the block immediately following the Superblock. So if the block size (determined from a field in the superblock) is 1024 bytes per block, the Block Group Descriptor Table will begin at block 2. For any other block size, it will begin at block 1.

Code: Select all

[1] It is located in the table immediately following the superblock.
[2] if block size == 1024:
     [0]
     [1] superbock
     [2] BGDT
[3] if block size == 2048:
    [0]
    [1] superblock ... BGDT will overwrite superbock

No, that's wrong.
If the block size is 1024 bytes, the 0 block is free (for boot code), the 1st block is superblock, the 2nd block is BGDT.
If the block size is 2048 bytes, the superblock will locate inside the 0 block and the 1st block will be BGDT. The same for blocks larger than 2048.
Yet Other Developer of Architecture.
OS Boot Tools.
Russian national OSDev forum.
User avatar
Pancakes
Member
Member
Posts: 75
Joined: Mon Mar 19, 2012 1:52 pm

Re: Error In EXT2 Documentation

Post by Pancakes »

Ok, let me meditate on this for some time. And, thank you for taking the time to help me.
Post Reply