From: Theodore Ts'o Date: Sat, 22 Dec 2001 18:06:02 +0000 (-0500) Subject: Update the group descriptor free block and inode counts when X-Git-Tag: E2FSPROGS-1_26-WIP-1224~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=344368911e118ffacde509d63bb8e617f91ea7cf;p=thirdparty%2Fe2fsprogs.git Update the group descriptor free block and inode counts when deleting or killing a file. --- diff --git a/debugfs/ChangeLog b/debugfs/ChangeLog index 9f510cfc4..d4228ceb1 100644 --- a/debugfs/ChangeLog +++ b/debugfs/ChangeLog @@ -1,3 +1,9 @@ +2001-12-22 Theodore Tso + + * debugfs.c (kill_file_by_inode, release_blocks_proc): Update the + group descriptor free block and inode counts when deleting + or killing a file. + 2001-12-16 Theodore Tso * setsuper.c (print_possible_fields), diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index cc13b068c..ebd02f272 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -1340,14 +1340,22 @@ void do_rmdir(int argc, char *argv[]) static int release_blocks_proc(ext2_filsys fs, blk_t *blocknr, int blockcnt, void *private) { - printf("%d ", *blocknr); - ext2fs_unmark_block_bitmap(fs->block_map,*blocknr); + blk_t block; + int group; + + block = *blocknr; + printf("%d ", block); + ext2fs_unmark_block_bitmap(fs->block_map,block); + group = ext2fs_group_of_blk(fs, block); + fs->group_desc[group].bg_free_blocks_count++; + fs->super->s_free_blocks_count++; return 0; } static void kill_file_by_inode(ext2_ino_t inode) { struct ext2_inode inode_buf; + int group; ext2fs_read_inode(current_fs, inode, &inode_buf); inode_buf.i_dtime = time(NULL); @@ -1358,7 +1366,11 @@ static void kill_file_by_inode(ext2_ino_t inode) release_blocks_proc, NULL); printf("\n"); ext2fs_unmark_inode_bitmap(current_fs->inode_map, inode); - + group = ext2fs_group_of_ino(current_fs, inode); + current_fs->group_desc[group].bg_free_inodes_count++; + current_fs->super->s_free_inodes_count++; + + ext2fs_mark_super_dirty(current_fs); ext2fs_mark_bb_dirty(current_fs); ext2fs_mark_ib_dirty(current_fs); }