Changeset 152610a8 in mainline for uspace/srv/fs/minixfs/mfs_utils.c


Ignore:
Timestamp:
2011-03-29T18:03:51Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ba5beaf
Parents:
1f1cc9d
Message:

Improves read_map() to avoid the need to call the read_ind_block() function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/minixfs/mfs_utils.c

    r1f1cc9d r152610a8  
    6161}
    6262
    63 /*
    64  *Read an indirect block from disk and convert its
    65  *content to the native endian format.
    66  */
    67 int
    68 read_ind_block(void *data, struct mfs_instance *inst,
    69                         uint32_t block, mfs_version_t version)
    70 {
    71         int rc;
    72         unsigned i;
    73         block_t *b;
    74         uint32_t *ptr32;
    75         uint16_t *ptr16;
    76 
    77         assert(inst);
    78         devmap_handle_t handle = inst->handle;
    79         struct mfs_sb_info *sbi = inst->sbi;
    80 
    81         assert(sbi);
    82 
    83         rc = block_get(&b, handle, block, BLOCK_FLAGS_NONE);
    84 
    85         if (rc != EOK)
    86                 goto out;
    87 
    88         if (version == MFS_VERSION_V1) {
    89                 uint16_t *p = b->data;
    90                 ptr16 = data;
    91                 for (i = 0; i < sbi->block_size / sizeof(uint16_t); ++i)
    92                         ptr16[i] = conv16(sbi->native, p[i]);
    93         } else {
    94                 uint32_t *p = b->data;
    95                 ptr32 = data;
    96                 for (i = 0; i < sbi->block_size / sizeof(uint32_t); ++i)
    97                         ptr32[i] = conv32(sbi->native, p[i]);
    98 
    99         }
    100 
    101         rc = EOK;
    102 
    103 out:
    104         block_put(b);
    105         return rc;
    106 }
    107 
    10863/**
    10964 * @}
Note: See TracChangeset for help on using the changeset viewer.