Changeset 5b16912 in mainline for uspace/lib/ext4/libext4_directory.c


Ignore:
Timestamp:
2012-04-07T13:22:50Z (13 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ce6de59
Parents:
c6a44a3
Message:

Moved append block function because of more common usage in the next commits

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext4/libext4_directory.c

    rc6a44a3 r5b16912  
    260260}
    261261
    262 int ext4_directory_append_block(ext4_inode_ref_t *inode_ref,
    263                 uint32_t *fblock, uint32_t *iblock)
    264 {
    265         int rc;
    266 
    267         ext4_superblock_t *sb = inode_ref->fs->superblock;
    268 
    269         // Compute next block index and allocate data block
    270         uint64_t inode_size = ext4_inode_get_size(sb, inode_ref->inode);
    271         uint32_t block_size = ext4_superblock_get_block_size(sb);
    272 
    273         assert(inode_size % block_size == 0);
    274 
    275         // Logical blocks are numbered from 0
    276         uint32_t new_block_idx = inode_size / block_size;
    277 
    278         uint32_t phys_block;
    279         rc =  ext4_balloc_alloc_block(inode_ref, &phys_block);
    280         if (rc != EOK) {
    281                 return rc;
    282         }
    283 
    284         rc = ext4_filesystem_set_inode_data_block_index(inode_ref, new_block_idx, phys_block);
    285         if (rc != EOK) {
    286                 ext4_balloc_free_block(inode_ref, phys_block);
    287                 return rc;
    288         }
    289 
    290         ext4_inode_set_size(inode_ref->inode, inode_size + block_size);
    291 
    292         inode_ref->dirty = true;
    293 
    294         *fblock = phys_block;
    295         *iblock = new_block_idx;
    296         return EOK;
    297 }
    298 
    299262void ext4_directory_write_entry(ext4_superblock_t *sb,
    300263                ext4_directory_entry_ll_t *entry, uint16_t entry_len,
     
    388351        // No free block found - needed to allocate next block
    389352
    390         rc = ext4_directory_append_block(parent, &fblock, &iblock);
     353        rc = ext4_filesystem_append_inode_block(parent, &fblock, &iblock);
    391354        if (rc != EOK) {
    392355                return rc;
Note: See TracChangeset for help on using the changeset viewer.