Ignore:
File:
1 edited

Legend:

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

    rc2e50d7 r7a46bfe  
    4242static int
    4343mfs_read_inode_raw(const struct mfs_instance *instance,
    44     struct mfs_ino_info **ino_ptr, uint16_t inum);
     44                struct mfs_ino_info **ino_ptr, uint16_t inum);
    4545
    4646static int
    4747mfs2_read_inode_raw(const struct mfs_instance *instance,
    48     struct mfs_ino_info **ino_ptr, uint32_t inum);
    49 
    50 /**Read a MINIX inode from disk
    51  *
    52  * @param inst          Pointer to the filesystem instance.
    53  * @param ino_i         Pointer to the generic MINIX inode
    54  *                      where the inode content will be stored.
    55  * @param index         index of the inode to read.
    56  *
    57  * @return              EOK on success or a negative error code.
    58  */
     48                struct mfs_ino_info **ino_ptr, uint32_t inum);
     49
     50
    5951int
    6052mfs_get_inode(struct mfs_instance *inst, struct mfs_ino_info **ino_i,
    61     fs_index_t index)
     53          fs_index_t index)
    6254{
    6355        struct mfs_sb_info *sbi = inst->sbi;
     
    6557
    6658        if (sbi->fs_version == MFS_VERSION_V1) {
    67                 /* Read a MFS V1 inode */
     59                /*Read a MFS V1 inode*/
    6860                r = mfs_read_inode_raw(inst, ino_i, index);
    6961        } else {
    70                 /* Read a MFS V2/V3 inode */
     62                /*Read a MFS V2/V3 inode*/
    7163                r = mfs2_read_inode_raw(inst, ino_i, index);
    7264        }
     
    7769static int
    7870mfs_read_inode_raw(const struct mfs_instance *instance,
    79     struct mfs_ino_info **ino_ptr, uint16_t inum)
    80 {
     71                struct mfs_ino_info **ino_ptr, uint16_t inum) {
    8172        struct mfs_inode *ino;
    8273        struct mfs_ino_info *ino_i = NULL;
     
    8677
    8778        sbi = instance->sbi;
    88 
    89         /* inode 0 does not exist */
     79        assert(sbi);
     80
     81        /*inode 0 does not exist*/
    9082        inum -= 1;
    9183
     
    10294
    10395        r = block_get(&b, instance->service_id,
    104             itable_off + inum / sbi->ino_per_block,
    105             BLOCK_FLAGS_NONE);
    106 
     96                      itable_off + inum / sbi->ino_per_block,
     97                      BLOCK_FLAGS_NONE);
    10798        if (r != EOK)
    10899                goto out_err;
     
    136127static int
    137128mfs2_read_inode_raw(const struct mfs_instance *instance,
    138     struct mfs_ino_info **ino_ptr, uint32_t inum)
    139 {
     129                struct mfs_ino_info **ino_ptr, uint32_t inum) {
    140130        struct mfs2_inode *ino;
    141131        struct mfs_ino_info *ino_i = NULL;
     
    152142
    153143        sbi = instance->sbi;
    154 
    155         /* inode 0 does not exist */
     144        assert(sbi);
     145
     146        /*inode 0 does not exist*/
    156147        inum -= 1;
    157148
     
    160151
    161152        r = block_get(&b, instance->service_id,
    162             itable_off + inum / sbi->ino_per_block,
    163             BLOCK_FLAGS_NONE);
    164 
     153                      itable_off + inum / sbi->ino_per_block,
     154                      BLOCK_FLAGS_NONE);
    165155        if (r != EOK)
    166156                goto out_err;
     
    195185}
    196186
    197 /**Write a MINIX inode on disk (if marked as dirty)
    198  *
    199  * @param mnode         Pointer to the generic MINIX inode in memory.
    200  *
    201  * @return              EOK on success or a negative error code.
    202  */
    203187int
    204 mfs_put_inode(struct mfs_node *mnode)
     188mfs_put_inode_core(struct mfs_node *mnode)
    205189{
    206190        int rc = EOK;
     191
     192        assert(mnode);
     193        assert(mnode->ino_i);
    207194
    208195        if (!mnode->ino_i->dirty)
     
    210197
    211198        struct mfs_instance *inst = mnode->instance;
     199        assert(inst);
    212200        struct mfs_sb_info *sbi = inst->sbi;
     201        assert(sbi);
    213202
    214203        if (sbi->fs_version == MFS_VERSION_V1)
     
    235224
    236225        r = block_get(&b, mnode->instance->service_id,
    237             itable_off + inum / sbi->ino_per_block,
    238             BLOCK_FLAGS_NONE);
     226                      itable_off + inum / sbi->ino_per_block,
     227                      BLOCK_FLAGS_NONE);
    239228
    240229        if (r != EOK)
     
    278267
    279268        r = block_get(&b, mnode->instance->service_id,
    280             itable_off + inum / sbi->ino_per_block,
    281             BLOCK_FLAGS_NONE);
     269                      itable_off + inum / sbi->ino_per_block,
     270                      BLOCK_FLAGS_NONE);
    282271
    283272        if (r != EOK)
     
    310299}
    311300
    312 /**Reduce the inode size of a given number of bytes
    313  *
    314  * @param mnode         Pointer to the generic MINIX inode in memory.
    315  * @param size_shrink   Number of bytes that will be subtracted to the inode.
    316  *
    317  * @return              EOK on success or a negative error code.
    318  */
    319301int
    320302mfs_inode_shrink(struct mfs_node *mnode, size_t size_shrink)
     
    326308
    327309        if (size_shrink == 0) {
    328                 /* Nothing to be done */
     310                /*File is empty*/
    329311                return EOK;
    330312        }
     
    337319        ino_i->dirty = true;
    338320
    339         /* Compute the number of zones to free */
     321        /*Compute the number of zones to free*/
    340322        unsigned zones_to_free;
    341323
     
    358340
    359341                if (old_zone == 0)
    360                         continue; /* Sparse block */
     342                        continue; /*Sparse block*/
    361343
    362344                r = mfs_free_zone(mnode->instance, old_zone);
Note: See TracChangeset for help on using the changeset viewer.