Final Year Project:
Using Linux Filesystems Under Windows
Chris Bryden
BEng. Electronics and Software Engineering
School of Computer Science
University of Birmingham
12
3.3.2 The Superblock
The superblock is a structure found at the beginning of each block group,
it contains information vital to mounting and accessing the filesystem. Currently
the superblock size is 1024 bytes. The structure of the superblock, shown below,
is defined in ext2_fs.h.
·
=s_inodes_count - The total number of inodes on the filesystem.
·
=s_blocks_count - The total number of blocks on the filesystem.
·
=s_r_blocks_count
- The total number of blocks reserved for use by the
superuser.
·
=s_free_blocks_count - The total number of free blocks on the filesystem.
·
=s_free_inodes_count - The total number of free inodes on the filesystem.
·
=s_first_data_block - The position on the filesystem of the first data block.
Usually this is block 1 for a filesystem with a block size of 1024 bytes, and 0
for larger block sizes.
·
=s_log_block_size - This is used to calculate the logical block size (in bytes).
The actual block size is given by: 1024 << s_log_block_size.
/*
* Structure of the super block
*/
struct ext2_super_block {
unsigned long s_inodes_count;
unsigned long s_blocks_count;
unsigned long s_r_blocks_count
unsigned long s_free_blocks_count
unsigned long s_free_inodes_count
unsigned long s_first_data_block
unsigned long s_log_block_size
long
s_log_frag_size;
unsigned long s_blocks_per_group
unsigned long s_frags_per_group
unsigned long s_inodes_per_group
unsigned long s_mtime;
unsigned long s_wtime;
unsigned short s_mnt_count;
short
s_max_mnt_count;
unsigned short s_magic;
unsigned short s_state;
unsigned short s_errors;
unsigned short s_pad;
unsigned long s_lastcheck;
unsigned long s_checkinterval;
unsigned long s_creator_os;
unsigned long s_rev_level;
unsigned short s_def_resuid;
unsigned short s_def_resgid;
unsigned long s_reserved[235];
};