Changeset 36bca8eb in mainline for uspace/app/ext2info/ext2info.c


Ignore:
Timestamp:
2011-02-13T18:55:00Z (14 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e272949
Parents:
d5e2763
Message:

Add some more superblock members and function to read a superblock

File:
1 edited

Legend:

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

    rd5e2763 r36bca8eb  
    6060        char *dev_path;
    6161        devmap_handle_t handle;
    62         size_t block_size;
    63         aoff64_t dev_nblocks;
    64         uint8_t *data;
    6562        ext2_superblock_t *superblock;
    6663       
     
    9592        }
    9693
    97         rc = block_get_bsize(handle, &block_size);
    98         if (rc != EOK) {
    99                 printf(NAME ": Error determining device block size.\n");
    100                 return 2;
    101         }
    102 
    103         rc = block_get_nblocks(handle, &dev_nblocks);
    104         if (rc != EOK) {
    105                 printf(NAME ": Warning, failed to obtain block device size.\n");
    106         }
    107 
    108         data = malloc(block_size);
    109         if (data == NULL) {
    110                 printf(NAME ": Error allocating data buffer of %" PRIuOFF64 " bytes", (aoff64_t) block_size);
    111                 block_fini(handle);
     94        rc = ext2_superblock_read_direct(&superblock, handle);
     95        if (rc != EOK)  {
     96                printf(NAME ": Error reading superblock.\n");
    11297                return 3;
    11398        }
    114        
    115         // TODO: don't assume device block size of 512 bytes
    116         rc = block_read_direct(handle, 2, 1, data);
    117         if (rc != EOK) {
    118                 printf(NAME ": Error reading block");
    119                 free(data);
    120                 return 3;
    121         }
    122        
    123         superblock = (ext2_superblock_t *) data;
    12499       
    125100        printf("Superblock:\n");
     
    133108       
    134109       
    135         free(data);
     110        free(superblock);
    136111
    137112        block_fini(handle);
Note: See TracChangeset for help on using the changeset viewer.