Changeset 930baca in mainline


Ignore:
Timestamp:
2011-03-19T19:15:28Z (13 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

Location:
uspace/srv/fs/minixfs
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/minixfs/Makefile

    r0d6ab10 r930baca  
    3737        mfs_ops.c \
    3838        mfs_inode.c \
     39        mfs_read.c \
    3940        mfs_utils.c
    4041
  • uspace/srv/fs/minixfs/mfs.h

    r0d6ab10 r930baca  
    7474        int dirsize;
    7575        int block_size;
    76         int fs_version;
     76        mfs_version_t fs_version;
    7777        uint32_t max_file_size;
    7878        uint16_t magic;
     
    121121                                        uint32_t inum);
    122122
     123/*mfs_read.c*/
     124int read_map(uint32_t *b, const struct mfs_node *mnode, const uint32_t pos);
    123125
    124126#endif
  • 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 * @}
  • uspace/srv/fs/minixfs/mfs_utils.h

    r0d6ab10 r930baca  
    4040uint32_t conv32(bool native, uint32_t n);
    4141uint64_t conv64(bool native, uint64_t n);
     42int read_ind_block(block_t *b, struct mfs_instance *inst, uint32_t block);
    4243
    4344#endif
Note: See TracChangeset for help on using the changeset viewer.