Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 5b16912 in mainline


Ignore:
Timestamp:
2012-04-07T13:22:50Z (10 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master
Children:
ce6de59
Parents:
c6a44a3
Message:

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

Location:
uspace/lib/ext4
Files:
5 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;
  • uspace/lib/ext4/libext4_directory.h

    rc6a44a3 r5b16912  
    5858extern int ext4_directory_iterator_fini(ext4_directory_iterator_t *);
    5959
    60 extern int ext4_directory_append_block(ext4_inode_ref_t *,
    61                 uint32_t *, uint32_t *);
    62 
    6360extern void ext4_directory_write_entry(ext4_superblock_t *,
    6461                ext4_directory_entry_ll_t *, uint16_t, ext4_inode_ref_t *,
  • uspace/lib/ext4/libext4_directory_index.c

    rc6a44a3 r5b16912  
    523523        }
    524524
    525         qsort(sort_array, idx, sizeof(ext4_dx_sort_entry_t), ext4_directory_dx_entry_comparator, NULL);
     525        qsort(sort_array, idx, sizeof(ext4_dx_sort_entry_t),
     526                        ext4_directory_dx_entry_comparator, NULL);
    526527
    527528        uint32_t new_fblock;
    528529        uint32_t new_iblock;
    529         rc = ext4_directory_append_block(inode_ref, &new_fblock, &new_iblock);
     530        rc = ext4_filesystem_append_inode_block(inode_ref, &new_fblock, &new_iblock);
    530531        if (rc != EOK) {
    531532                free(sort_array);
     
    651652                uint32_t new_fblock;
    652653                uint32_t new_iblock;
    653                 rc =  ext4_directory_append_block(inode_ref, &new_fblock, &new_iblock);
     654                rc =  ext4_filesystem_append_inode_block(
     655                                inode_ref, &new_fblock, &new_iblock);
    654656                if (rc != EOK) {
    655657                        return rc;
  • uspace/lib/ext4/libext4_filesystem.c

    rc6a44a3 r5b16912  
    887887}
    888888
     889int ext4_filesystem_append_inode_block(ext4_inode_ref_t *inode_ref,
     890                uint32_t *fblock, uint32_t *iblock)
     891{
     892
     893        // TODO append to extent
     894
     895        int rc;
     896
     897        ext4_superblock_t *sb = inode_ref->fs->superblock;
     898
     899        // Compute next block index and allocate data block
     900        uint64_t inode_size = ext4_inode_get_size(sb, inode_ref->inode);
     901        uint32_t block_size = ext4_superblock_get_block_size(sb);
     902
     903        assert(inode_size % block_size == 0);
     904
     905        // Logical blocks are numbered from 0
     906        uint32_t new_block_idx = inode_size / block_size;
     907
     908        uint32_t phys_block;
     909        rc =  ext4_balloc_alloc_block(inode_ref, &phys_block);
     910        if (rc != EOK) {
     911                return rc;
     912        }
     913
     914        rc = ext4_filesystem_set_inode_data_block_index(inode_ref, new_block_idx, phys_block);
     915        if (rc != EOK) {
     916                ext4_balloc_free_block(inode_ref, phys_block);
     917                return rc;
     918        }
     919
     920        ext4_inode_set_size(inode_ref->inode, inode_size + block_size);
     921
     922        inode_ref->dirty = true;
     923
     924        *fblock = phys_block;
     925        *iblock = new_block_idx;
     926        return EOK;
     927}
     928
    889929int ext4_filesystem_add_orphan(ext4_inode_ref_t *inode_ref)
    890930{
  • uspace/lib/ext4/libext4_filesystem.h

    rc6a44a3 r5b16912  
    5757extern int ext4_filesystem_release_inode_block(
    5858                ext4_inode_ref_t *, uint32_t);
     59extern int ext4_filesystem_append_inode_block(ext4_inode_ref_t *,
     60                uint32_t *, uint32_t *);
     61
    5962extern int ext4_filesystem_add_orphan(ext4_inode_ref_t *);
    6063extern int ext4_filesystem_delete_orphan(ext4_inode_ref_t *);
Note: See TracChangeset for help on using the changeset viewer.