Changeset 5b16912 in mainline
- Timestamp:
- 2012-04-07T13:22:50Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ce6de59
- Parents:
- c6a44a3
- Location:
- uspace/lib/ext4
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_directory.c
rc6a44a3 r5b16912 260 260 } 261 261 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 block270 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 0276 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 299 262 void ext4_directory_write_entry(ext4_superblock_t *sb, 300 263 ext4_directory_entry_ll_t *entry, uint16_t entry_len, … … 388 351 // No free block found - needed to allocate next block 389 352 390 rc = ext4_ directory_append_block(parent, &fblock, &iblock);353 rc = ext4_filesystem_append_inode_block(parent, &fblock, &iblock); 391 354 if (rc != EOK) { 392 355 return rc; -
uspace/lib/ext4/libext4_directory.h
rc6a44a3 r5b16912 58 58 extern int ext4_directory_iterator_fini(ext4_directory_iterator_t *); 59 59 60 extern int ext4_directory_append_block(ext4_inode_ref_t *,61 uint32_t *, uint32_t *);62 63 60 extern void ext4_directory_write_entry(ext4_superblock_t *, 64 61 ext4_directory_entry_ll_t *, uint16_t, ext4_inode_ref_t *, -
uspace/lib/ext4/libext4_directory_index.c
rc6a44a3 r5b16912 523 523 } 524 524 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); 526 527 527 528 uint32_t new_fblock; 528 529 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); 530 531 if (rc != EOK) { 531 532 free(sort_array); … … 651 652 uint32_t new_fblock; 652 653 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); 654 656 if (rc != EOK) { 655 657 return rc; -
uspace/lib/ext4/libext4_filesystem.c
rc6a44a3 r5b16912 887 887 } 888 888 889 int 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 889 929 int ext4_filesystem_add_orphan(ext4_inode_ref_t *inode_ref) 890 930 { -
uspace/lib/ext4/libext4_filesystem.h
rc6a44a3 r5b16912 57 57 extern int ext4_filesystem_release_inode_block( 58 58 ext4_inode_ref_t *, uint32_t); 59 extern int ext4_filesystem_append_inode_block(ext4_inode_ref_t *, 60 uint32_t *, uint32_t *); 61 59 62 extern int ext4_filesystem_add_orphan(ext4_inode_ref_t *); 60 63 extern int ext4_filesystem_delete_orphan(ext4_inode_ref_t *);
Note:
See TracChangeset
for help on using the changeset viewer.