Changeset f6fa2c2 in mainline


Ignore:
Timestamp:
2011-02-14T20:24:40Z (14 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3949e8a0
Parents:
c00e729
Message:

Added read support and code in ext2info for more superblock entries

Location:
uspace
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/ext2info/ext2info.c

    rc00e729 rf6fa2c2  
    117117        uint32_t first_inode;
    118118        uint16_t inode_size;
     119        uint32_t total_blocks;
     120        uint32_t reserved_blocks;
     121        uint32_t free_blocks;
     122        uint32_t total_inodes;
     123        uint32_t free_inodes;   
     124        uint32_t os;
    119125       
    120126        int pos;
     
    132138        first_inode = ext2_superblock_get_first_inode(superblock);
    133139        inode_size = ext2_superblock_get_inode_size(superblock);
     140        total_blocks = ext2_superblock_get_total_block_count(superblock);
     141        reserved_blocks = ext2_superblock_get_reserved_block_count(superblock);
     142        free_blocks = ext2_superblock_get_free_block_count(superblock);
     143        total_inodes = ext2_superblock_get_total_inode_count(superblock);
     144        free_inodes = ext2_superblock_get_free_inode_count(superblock);
     145        os = ext2_superblock_get_os(superblock);
    134146       
    135147        printf("Superblock:\n");
     
    144156        printf("  Revision: %u.%hu\n", rev_major, rev_minor);
    145157        printf("  State: %hu\n", state);
     158        printf("  Creator OS: %u\n", os);
    146159        printf("  First block: %u\n", first_block);
    147160        printf("  Block size: %u bytes (%u KiB)\n", block_size, block_size/1024);
    148161        printf("  Blocks per group: %u\n", blocks_per_group);
     162        printf("  Total blocks: %u\n", total_blocks);
     163        printf("  Reserved blocks: %u\n", reserved_blocks);
     164        printf("  Free blocks: %u\n", free_blocks);
    149165        printf("  Fragment size: %u bytes (%u KiB)\n", fragment_size,
    150166            fragment_size/1024);
     
    152168        printf("  First inode: %u\n", first_inode);
    153169        printf("  Inode size: %hu bytes\n", inode_size);
     170        printf("  Total inodes: %u\n", total_inodes);
     171        printf("  Free inodes: %u\n", free_inodes);
    154172       
    155         printf("  UUID: ");
    156         for (pos = 0; pos < 16; pos++) {
    157                 printf("%02x", superblock->uuid[pos]);
     173       
     174        if (rev_major == 1) {
     175                printf("  UUID: ");
     176                for (pos = 0; pos < 16; pos++) {
     177                        printf("%02x", superblock->uuid[pos]);
     178                }
     179                printf("\n");
     180               
     181                printf("  Volume label: ");
     182                for (pos = 0; pos < 16; pos++) {
     183                        c = superblock->volume_name[pos];
     184                        if (c >= 32 && c < 128) {
     185                                putchar(c);
     186                        }
     187                        else {
     188                                putchar(' ');
     189                        }
     190                }
     191                printf("\n");
    158192        }
    159         printf("\n");
    160        
    161         printf("  Volume label: ");
    162         for (pos = 0; pos < 16; pos++) {
    163                 c = superblock->volume_name[pos];
    164                 if (c >= 32 && c < 128) {
    165                         putchar(c);
    166                 }
    167                 else {
    168                         putchar(' ');
    169                 }
    170         }
    171         printf("\n");
    172193       
    173194}
  • uspace/lib/ext2/libext2.h

    rc00e729 rf6fa2c2  
    4141
    4242typedef struct ext2_superblock {
    43         uint8_t         unused[20];
     43        uint32_t        total_inode_count; // Total number of inodes
     44        uint32_t        total_block_count; // Total number of blocks
     45        uint32_t        reserved_block_count; // Total number of reserved blocks
     46        uint32_t        free_block_count; // Total number of free blocks
     47        uint32_t        free_inode_count; // Total number of free inodes
    4448        uint32_t        first_block; // Block containing the superblock (either 0 or 1)
    4549        uint32_t        block_size_log2; // log_2(block_size)
     
    5155        uint16_t        magic; // Magic value
    5256        uint16_t        state; // State (mounted/unmounted)
     57        uint16_t        error_behavior; // What to do when errors are encountered
    5358        uint16_t        rev_minor; // Minor revision level
    54         uint8_t         unused3[12];
    55         uint32_t        creator_os;
     59        uint8_t         unused3[8];
     60        uint32_t        os; // OS that created the filesystem
    5661        uint32_t        rev_major; // Major revision level
    57         uint8_t         unused4[8];
     62        uint8_t         unused4[4];
    5863       
    5964        // Following is for ext2 revision 1 only
     
    96101inline uint16_t ext2_superblock_get_rev_minor(ext2_superblock_t *);
    97102inline uint32_t ext2_superblock_get_rev_major(ext2_superblock_t *);
    98 inline uint32_t ext2_superblock_get_creator_os(ext2_superblock_t *);
     103inline uint32_t ext2_superblock_get_os(ext2_superblock_t *);
    99104inline uint32_t ext2_superblock_get_first_inode(ext2_superblock_t *);
    100105inline uint16_t ext2_superblock_get_inode_size(ext2_superblock_t *);
     106inline uint32_t ext2_superblock_get_total_inode_count(ext2_superblock_t *);
     107inline uint32_t ext2_superblock_get_total_block_count(ext2_superblock_t *);
     108inline uint32_t ext2_superblock_get_reserved_block_count(ext2_superblock_t *);
     109inline uint32_t ext2_superblock_get_free_block_count(ext2_superblock_t *);
     110inline uint32_t ext2_superblock_get_free_inode_count(ext2_superblock_t *);
    101111
    102112extern int ext2_superblock_read_direct(devmap_handle_t, ext2_superblock_t **);
  • uspace/lib/ext2/libext2_superblock.c

    rc00e729 rf6fa2c2  
    186186}
    187187
     188/**
     189 * Get total inode count
     190 *
     191 * @param sb pointer to superblock
     192 */
     193inline uint32_t ext2_superblock_get_total_inode_count(ext2_superblock_t *sb)
     194{
     195        return uint32_t_le2host(sb->total_inode_count);
     196}
     197
     198/**
     199 * Get total block count
     200 *
     201 * @param sb pointer to superblock
     202 */
     203inline uint32_t ext2_superblock_get_total_block_count(ext2_superblock_t *sb)
     204{
     205        return uint32_t_le2host(sb->total_block_count);
     206}
     207
     208/**
     209 * Get amount of blocks reserved for the superuser
     210 *
     211 * @param sb pointer to superblock
     212 */
     213inline uint32_t ext2_superblock_get_reserved_block_count(ext2_superblock_t *sb)
     214{
     215        return uint32_t_le2host(sb->reserved_block_count);
     216}
     217
     218/**
     219 * Get amount of free blocks
     220 *
     221 * @param sb pointer to superblock
     222 */
     223inline uint32_t ext2_superblock_get_free_block_count(ext2_superblock_t *sb)
     224{
     225        return uint32_t_le2host(sb->free_block_count);
     226}
     227
     228/**
     229 * Get amount of free inodes
     230 *
     231 * @param sb pointer to superblock
     232 */
     233inline uint32_t ext2_superblock_get_free_inode_count(ext2_superblock_t *sb)
     234{
     235        return uint32_t_le2host(sb->free_inode_count);
     236}
     237
     238/**
     239 * Get id of operating system that created the filesystem
     240 *
     241 * @param sb pointer to superblock
     242 */
     243inline uint32_t ext2_superblock_get_os(ext2_superblock_t *sb)
     244{
     245        return uint32_t_le2host(sb->os);
     246}
    188247
    189248/** Read a superblock directly from device (i.e. no libblock cache)
Note: See TracChangeset for help on using the changeset viewer.