Changeset ebcaff4 in mainline
- Timestamp:
- 2011-12-03T10:42:28Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2449396
- Parents:
- 1e48a07e
- Location:
- uspace/lib/ext4
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_filesystem.c
r1e48a07e rebcaff4 783 783 } 784 784 785 int ext4_filesystem_add_orphan(ext4_filesystem_t *fs, 786 ext4_inode_ref_t *inode_ref) 787 { 788 uint32_t next_orphan = ext4_superblock_get_last_orphan(fs->superblock); 789 ext4_inode_set_deletion_time(inode_ref->inode, next_orphan); 790 ext4_superblock_set_last_orphan(fs->superblock, inode_ref->index); 791 inode_ref->dirty = true; 792 793 return EOK; 794 } 795 796 int ext4_filesystem_delete_orphan(ext4_filesystem_t *fs, 797 ext4_inode_ref_t *inode_ref) 798 { 799 int rc; 800 801 uint32_t last_orphan = ext4_superblock_get_last_orphan(fs->superblock); 802 assert(last_orphan > 0); 803 804 uint32_t next_orphan = ext4_inode_get_deletion_time(inode_ref->inode); 805 806 if (last_orphan == inode_ref->index) { 807 ext4_superblock_set_last_orphan(fs->superblock, next_orphan); 808 ext4_inode_set_deletion_time(inode_ref->inode, 0); 809 inode_ref->dirty = true; 810 return EOK; 811 } 812 813 ext4_inode_ref_t *current; 814 rc = ext4_filesystem_get_inode_ref(fs, last_orphan, ¤t); 815 if (rc != EOK) { 816 return rc; 817 } 818 next_orphan = ext4_inode_get_deletion_time(current->inode); 819 820 bool found; 821 822 while (next_orphan != 0) { 823 if (next_orphan == inode_ref->index) { 824 next_orphan = ext4_inode_get_deletion_time(inode_ref->inode); 825 ext4_inode_set_deletion_time(current->inode, next_orphan); 826 current->dirty = true; 827 found = true; 828 break; 829 } 830 831 ext4_filesystem_put_inode_ref(current); 832 833 rc = ext4_filesystem_get_inode_ref(fs, next_orphan, ¤t); 834 if (rc != EOK) { 835 return rc; 836 } 837 next_orphan = ext4_inode_get_deletion_time(current->inode); 838 839 } 840 841 ext4_inode_set_deletion_time(inode_ref->inode, 0); 842 843 rc = ext4_filesystem_put_inode_ref(current); 844 if (rc != EOK) { 845 return rc; 846 } 847 848 if (!found) { 849 return ENOENT; 850 } 851 852 return EOK; 853 } 854 785 855 /** 786 856 * @} -
uspace/lib/ext4/libext4_filesystem.h
r1e48a07e rebcaff4 70 70 extern int ext4_filesystem_release_inode_block(ext4_filesystem_t *, 71 71 ext4_inode_ref_t *, uint32_t); 72 extern int ext4_filesystem_add_orphan(ext4_filesystem_t *, 73 ext4_inode_ref_t *); 74 extern int ext4_filesystem_delete_orphan(ext4_filesystem_t *, 75 ext4_inode_ref_t *); 72 76 #endif 73 77 -
uspace/lib/ext4/libext4_superblock.c
r1e48a07e rebcaff4 354 354 } 355 355 356 uint32_t ext4_superblock_get_last_orphan(ext4_superblock_t *sb) 357 { 358 return uint32_t_le2host(sb->last_orphan); 359 } 360 361 void ext4_superblock_set_last_orphan(ext4_superblock_t *sb, uint32_t last_orphan) 362 { 363 sb->last_orphan = host2uint32_t_le(last_orphan); 364 } 365 356 366 uint32_t* ext4_superblock_get_hash_seed(ext4_superblock_t *sb) 357 367 { -
uspace/lib/ext4/libext4_superblock.h
r1e48a07e rebcaff4 272 272 uint32_t s_journal_inum; // Inode number of journal file 273 273 uint32_t s_journal_dev; // Device number of journal file 274 uint32_t s_last_orphan; // Head of list of inodes to delete275 274 */ 275 extern uint32_t ext4_superblock_get_last_orphan(ext4_superblock_t *); 276 extern void ext4_superblock_set_last_orphan(ext4_superblock_t *, uint32_t); 276 277 extern uint32_t* ext4_superblock_get_hash_seed(ext4_superblock_t *); 277 278 /*
Note:
See TracChangeset
for help on using the changeset viewer.