OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 18, 2024 3:22 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Ext2 size of block group descriptor table
PostPosted: Mon Dec 19, 2016 12:32 pm 
Offline
Member
Member
User avatar

Joined: Sun Nov 20, 2016 7:26 am
Posts: 155
Location: Somewhere
Hello again :D

In my ext2 implementation, I assume block group descriptor table is 1 block. Is that always correct? I'm not sure it is correct, because with the size of block group descriptor is 32 bytes, and with 1024 bytes of block size, a block can have only 32 block group descriptors. (1024 / 32 = 32) With 1024 bytes of block size, a block group descriptor can only handle 8 megabytes. With 32 block group descriptors, entire ext2 can handle only 256 megabytes. (8 * 32 = 256)

But I'm still not sure :|
In wiki.osdev.org/Ext2 it says we can find block group count with "Rounding up the total number of blocks divided by the number of blocks per block group".

If I round block group count to (block size in bytes / 32), can I found size of block group descriptor table in blocks?

If not, how can I?

Thanks :|

_________________
Keyboard not found!

Press F1 to run setup.
Press F2 to continue.


Last edited by Agola on Mon Dec 19, 2016 1:18 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Ext2 size of block group descriptor table
PostPosted: Mon Dec 19, 2016 12:43 pm 
Online
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
If you read the documentation ( http://www.nongnu.org/ext2-doc/ext2.html ) it explains that the table can be one or more blocks in size. That document should answer all your questions.


Top
 Profile  
 
 Post subject: Re: Ext2 size of block group descriptor table
PostPosted: Mon Dec 19, 2016 12:45 pm 
Offline
Member
Member
User avatar

Joined: Wed Aug 31, 2016 9:53 pm
Posts: 81
Location: San Diego, CA
You need to calculate how many blocks the block group descriptors occupy

Code:
num_to_read = ((num_block_groups * sizeof(struct ext2_group_desc)) / blocksize) + 1;

_________________
Some of my open-source projects:
Ext2/ELF32 bootloader
Lightweight x86 assembler, designed to be portable for osdev
Scheme in under 1000 lines of C


Top
 Profile  
 
 Post subject: Re: Ext2 size of block group descriptor table
PostPosted: Mon Dec 19, 2016 1:22 pm 
Offline
Member
Member
User avatar

Joined: Sun Nov 20, 2016 7:26 am
Posts: 155
Location: Somewhere
iansjack wrote:
If you read the documentation ( http://www.nongnu.org/ext2-doc/ext2.html ) it explains that the table can be one or more blocks in size. That document should answer all your questions.

Oh, that was my bad. I didn't read it, but I only read the disk organization and assumed it is only one block. ("1 block - block group descriptor table" from Chapter 3, Table 3-2. Sample 20mb Partition Layout)

Thanks

_________________
Keyboard not found!

Press F1 to run setup.
Press F2 to continue.


Last edited by Agola on Mon Dec 19, 2016 1:27 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Ext2 size of block group descriptor table
PostPosted: Mon Dec 19, 2016 1:27 pm 
Offline
Member
Member
User avatar

Joined: Sun Nov 20, 2016 7:26 am
Posts: 155
Location: Somewhere
crunch wrote:
You need to calculate how many blocks the block group descriptors occupy

Code:
num_to_read = ((num_block_groups * sizeof(struct ext2_group_desc)) / blocksize) + 1;

Thanks, that works, but it reads a block more.

With 32 block groups, and 32 bytes (size of group descriptor) (1024 / 1024) + 1 equals 2
I think the correct one is
Code:
num_to_read = ((num_block_groups * sizeof(struct ext2_group_desc)) - 1) / blocksize) + 1


That is (1023 / 1024) + 1 and results one.

Thanks

_________________
Keyboard not found!

Press F1 to run setup.
Press F2 to continue.


Top
 Profile  
 
 Post subject: Re: Ext2 size of block group descriptor table
PostPosted: Mon Dec 19, 2016 4:36 pm 
Offline
Member
Member
User avatar

Joined: Wed Aug 31, 2016 9:53 pm
Posts: 81
Location: San Diego, CA
I was just trying to see if you were paying attention :mrgreen:

_________________
Some of my open-source projects:
Ext2/ELF32 bootloader
Lightweight x86 assembler, designed to be portable for osdev
Scheme in under 1000 lines of C


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 347 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group