Changeset 930baca in mainline for uspace/srv/fs/minixfs/mfs_utils.c


Ignore:
Timestamp:
2011-03-19T19:15:28Z (14 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
155f792
Parents:
0d6ab10
Message:

the read_map() function returns the data block address on disk given the position into the file

File:
1 edited

Legend:

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

    r0d6ab10 r930baca  
    3232
    3333#include <byteorder.h>
     34#include <assert.h>
     35#include <errno.h>
     36#include "mfs.h"
    3437#include "mfs_utils.h"
    3538
     
    5861}
    5962
     63/*
     64 *Read an indirect block from disk and convert its
     65 *content to the native endian format.
     66 */
     67int read_ind_block(block_t *b, struct mfs_instance *inst, uint32_t block)
     68{
     69        int rc;
     70        unsigned i;
     71
     72        assert(inst);
     73        devmap_handle_t handle = inst->handle;
     74        struct mfs_sb_info *sbi = inst->sbi;
     75
     76        assert(sbi);
     77
     78        rc = block_get(&b, handle, block, BLOCK_FLAGS_NONE);
     79
     80        if (rc != EOK)
     81                return rc;
     82
     83        if (sbi->fs_version == MFS_VERSION_V1) {
     84                uint16_t *pt16 = b->data;
     85
     86                for (i = 0; i < MFS_BLOCKSIZE / sizeof(uint16_t); ++i)
     87                        pt16[i] = conv16(sbi->native, pt16[i]);
     88        } else {
     89                uint32_t *pt32 = b->data;
     90
     91                for (i = 0; i < sbi->block_size / sizeof(uint32_t); ++i)
     92                        pt32[i] = conv32(sbi->native, pt32[i]);
     93        }
     94
     95        return EOK;
     96}
     97
    6098/**
    6199 * @}
Note: See TracChangeset for help on using the changeset viewer.