// $Id: readsuper.c,v 1.1 2004/11/17 09:59:56 kaiya Exp kaiya $ /* Spec Read information in Super Block Usage ./a.out < filesystem_file Limit filesytem_file should be simple ext2 file system dump; i.e. block size=1024B, number of blocks=1440. Comple gcc -I/usr/src/linux-2.4/include/ thisfile.c */ #include #include #include #include //#include #include "ext2_os2006.h" #define BLOCKSIZE 1024 readsuper(unsigned char* block){ struct ext2_super_block sb; bcopy(block, &sb, sizeof(sb)); printf("inode_count = %d, inodes_per_group = %d, block_count = %d\n", rev32(sb.s_inodes_count), rev32(sb.s_inodes_per_group), rev32(sb.s_blocks_count) ); } main(){ unsigned char block[BLOCKSIZE]; int c; for(c=0; read(0, block, BLOCKSIZE)==BLOCKSIZE; c++){ if(c==1){ readsuper(block); break; } } }