Changeset df22c36 in mainline for uspace/srv/fs/minixfs/mfs_inode.c


Ignore:
Timestamp:
2011-03-17T22:24:50Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cfff7a8f
Parents:
f213ae7
Message:

add function to read V2/V3 inodes on disk

File:
1 edited

Legend:

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

    rf213ae7 rdf22c36  
    55
    66struct mfs_inode *mfs_read_inode_raw(const struct mfs_instance *instance,
    7                                         uint32_t inum)
     7                                        uint16_t inum)
    88{
    99        struct mfs_inode *ino;
     
    2424                        BLOCK_FLAGS_NONE);
    2525
    26         memcpy(ino, (struct mfs_ino *) (((uint8_t *) b->data) +
    27                                         inum * ino_size), ino_size);
     26        memcpy(ino, ((uint8_t *) b->data) + inum * ino_size, ino_size);
    2827
    2928        ino->i_mode = conv16(sbi->native, ino->i_mode);
     
    4342}
    4443
     44struct mfs2_inode *mfs2_read_inode_raw(const struct mfs_instance *instance,
     45                                        uint32_t inum)
     46{
     47        struct mfs2_inode *ino;
     48        struct mfs_sb_info *sbi;
     49        block_t *b;
     50        int i;
     51
     52        const size_t ino_size = sizeof(struct mfs2_inode);
     53
     54        ino = (struct mfs2_inode *) malloc(ino_size);
     55
     56        if (!ino)
     57                return NULL;
     58
     59        sbi = instance->sbi;
     60
     61        block_get(&b, instance->handle,
     62                        2 + inum / V3_INODES_PER_BLOCK(sbi->block_size),
     63                        BLOCK_FLAGS_NONE);
     64
     65        memcpy(ino, ((uint8_t *)b->data) + inum * ino_size, ino_size);
     66
     67        ino->i_mode = conv16(sbi->native, ino->i_mode);
     68        ino->i_nlinks = conv16(sbi->native, ino->i_nlinks);
     69        ino->i_uid = conv16(sbi->native, ino->i_uid);
     70        ino->i_gid = conv16(sbi->native, ino->i_gid);
     71        ino->i_size = conv32(sbi->native, ino->i_size);
     72        ino->i_atime = conv32(sbi->native, ino->i_atime);
     73        ino->i_mtime = conv32(sbi->native, ino->i_mtime);
     74        ino->i_ctime = conv32(sbi->native, ino->i_ctime);
     75
     76        for (i = 0; i < V2_NR_DIRECT_ZONES; ++i)
     77                ino->i_dzone[i] = conv32(sbi->native, ino->i_dzone[i]);
     78
     79        for (i = 0; i < V2_NR_INDIRECT_ZONES; ++i)
     80                ino->i_izone[i] = conv32(sbi->native, ino->i_izone[i]);
     81
     82        block_put(b);
     83
     84        return ino;
     85}
     86
Note: See TracChangeset for help on using the changeset viewer.