Ignore:
File:
1 edited

Legend:

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

    r7a46bfe rc2e50d7  
    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 
     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 */
    5159int
    5260mfs_get_inode(struct mfs_instance *inst, struct mfs_ino_info **ino_i,
    53           fs_index_t index)
     61    fs_index_t index)
    5462{
    5563        struct mfs_sb_info *sbi = inst->sbi;
     
    5765
    5866        if (sbi->fs_version == MFS_VERSION_V1) {
    59                 /*Read a MFS V1 inode*/
     67                /* Read a MFS V1 inode */
    6068                r = mfs_read_inode_raw(inst, ino_i, index);
    6169        } else {
    62                 /*Read a MFS V2/V3 inode*/
     70                /* Read a MFS V2/V3 inode */
    6371                r = mfs2_read_inode_raw(inst, ino_i, index);
    6472        }
     
    6977static int
    7078mfs_read_inode_raw(const struct mfs_instance *instance,
    71                 struct mfs_ino_info **ino_ptr, uint16_t inum) {
     79    struct mfs_ino_info **ino_ptr, uint16_t inum)
     80{
    7281        struct mfs_inode *ino;
    7382        struct mfs_ino_info *ino_i = NULL;
     
    7786
    7887        sbi = instance->sbi;
    79         assert(sbi);
    80 
    81         /*inode 0 does not exist*/
     88
     89        /* inode 0 does not exist */
    8290        inum -= 1;
    8391
     
    94102
    95103        r = block_get(&b, instance->service_id,
    96                       itable_off + inum / sbi->ino_per_block,
    97                       BLOCK_FLAGS_NONE);
     104            itable_off + inum / sbi->ino_per_block,
     105            BLOCK_FLAGS_NONE);
     106
    98107        if (r != EOK)
    99108                goto out_err;
     
    127136static int
    128137mfs2_read_inode_raw(const struct mfs_instance *instance,
    129                 struct mfs_ino_info **ino_ptr, uint32_t inum) {
     138    struct mfs_ino_info **ino_ptr, uint32_t inum)
     139{
    130140        struct mfs2_inode *ino;
    131141        struct mfs_ino_info *ino_i = NULL;
     
    142152
    143153        sbi = instance->sbi;
    144         assert(sbi);
    145 
    146         /*inode 0 does not exist*/
     154
     155        /* inode 0 does not exist */
    147156        inum -= 1;
    148157
     
    151160
    152161        r = block_get(&b, instance->service_id,
    153                       itable_off + inum / sbi->ino_per_block,
    154                       BLOCK_FLAGS_NONE);
     162            itable_off + inum / sbi->ino_per_block,
     163            BLOCK_FLAGS_NONE);
     164
    155165        if (r != EOK)
    156166                goto out_err;
     
    185195}
    186196
     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 */
    187203int
    188 mfs_put_inode_core(struct mfs_node *mnode)
     204mfs_put_inode(struct mfs_node *mnode)
    189205{
    190206        int rc = EOK;
    191 
    192         assert(mnode);
    193         assert(mnode->ino_i);
    194207
    195208        if (!mnode->ino_i->dirty)
     
    197210
    198211        struct mfs_instance *inst = mnode->instance;
    199         assert(inst);
    200212        struct mfs_sb_info *sbi = inst->sbi;
    201         assert(sbi);
    202213
    203214        if (sbi->fs_version == MFS_VERSION_V1)
     
    224235
    225236        r = block_get(&b, mnode->instance->service_id,
    226                       itable_off + inum / sbi->ino_per_block,
    227                       BLOCK_FLAGS_NONE);
     237            itable_off + inum / sbi->ino_per_block,
     238            BLOCK_FLAGS_NONE);
    228239
    229240        if (r != EOK)
     
    267278
    268279        r = block_get(&b, mnode->instance->service_id,
    269                       itable_off + inum / sbi->ino_per_block,
    270                       BLOCK_FLAGS_NONE);
     280            itable_off + inum / sbi->ino_per_block,
     281            BLOCK_FLAGS_NONE);
    271282
    272283        if (r != EOK)
     
    299310}
    300311
     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 */
    301319int
    302320mfs_inode_shrink(struct mfs_node *mnode, size_t size_shrink)
     
    308326
    309327        if (size_shrink == 0) {
    310                 /*File is empty*/
     328                /* Nothing to be done */
    311329                return EOK;
    312330        }
     
    319337        ino_i->dirty = true;
    320338
    321         /*Compute the number of zones to free*/
     339        /* Compute the number of zones to free */
    322340        unsigned zones_to_free;
    323341
     
    340358
    341359                if (old_zone == 0)
    342                         continue; /*Sparse block*/
     360                        continue; /* Sparse block */
    343361
    344362                r = mfs_free_zone(mnode->instance, old_zone);
Note: See TracChangeset for help on using the changeset viewer.