From 43323be95742298b8229be728c3812e95c90629c Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 7 Feb 2008 14:37:17 -0500 Subject: Use BLOCK_FLAG_READ_ONLY flag in debugfs, e2image, and tune2fs Pass BLOCK_FLAG_READ_ONLY to ext2fs_block_iterate2() so that debugfs, e2image, and tune2fs will work well with filesystems containing extents. Signed-off-by: "Theodore Ts'o" --- debugfs/debugfs.c | 6 +++--- debugfs/htree.c | 3 ++- debugfs/icheck.c | 3 ++- debugfs/lsdel.c | 3 ++- misc/e2image.c | 10 ++++++---- misc/tune2fs.c | 3 ++- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index bcd9a9be..79998a20 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -509,7 +509,7 @@ static void dump_blocks(FILE *f, const char *prefix, ext2_ino_t inode) lb.first_block = 0; lb.f = f; lb.first = 1; - ext2fs_block_iterate2(current_fs, inode, 0, NULL, + ext2fs_block_iterate2(current_fs, inode, BLOCK_FLAG_READ_ONLY, NULL, list_blocks_proc, (void *)&lb); finish_range(&lb); if (lb.total) @@ -1108,7 +1108,7 @@ void do_undel(int argc, char *argv[]) if (debugfs_write_inode(ino, &inode, argv[0])) return; - ext2fs_block_iterate(current_fs, ino, 0, NULL, + ext2fs_block_iterate(current_fs, ino, BLOCK_FLAG_READ_ONLY, NULL, mark_blocks_proc, NULL); ext2fs_inode_alloc_stats2(current_fs, ino, +1, 0); @@ -1501,7 +1501,7 @@ static void kill_file_by_inode(ext2_ino_t inode) if (!ext2fs_inode_has_valid_blocks(&inode_buf)) return; - ext2fs_block_iterate(current_fs, inode, 0, NULL, + ext2fs_block_iterate(current_fs, inode, BLOCK_FLAG_READ_ONLY, NULL, release_blocks_proc, NULL); printf("\n"); ext2fs_inode_alloc_stats2(current_fs, inode, -1, diff --git a/debugfs/htree.c b/debugfs/htree.c index d0e673eb..a46bae77 100644 --- a/debugfs/htree.c +++ b/debugfs/htree.c @@ -347,7 +347,8 @@ void do_dirsearch(int argc, char *argv[]) pb.search_name = argv[2]; pb.len = strlen(pb.search_name); - ext2fs_block_iterate2(current_fs, inode, 0, 0, search_dir_block, &pb); + ext2fs_block_iterate2(current_fs, inode, BLOCK_FLAG_READ_ONLY, 0, + search_dir_block, &pb); free(pb.buf); } diff --git a/debugfs/icheck.c b/debugfs/icheck.c index a6b182d0..01c78bcb 100644 --- a/debugfs/icheck.c +++ b/debugfs/icheck.c @@ -127,7 +127,8 @@ void do_icheck(int argc, char **argv) if (inode.i_dtime) goto next; - retval = ext2fs_block_iterate2(current_fs, ino, 0, block_buf, + retval = ext2fs_block_iterate2(current_fs, ino, + BLOCK_FLAG_READ_ONLY, block_buf, icheck_proc, &bw); if (retval) { com_err("icheck", retval, diff --git a/debugfs/lsdel.c b/debugfs/lsdel.c index b3293b85..f703c6b3 100644 --- a/debugfs/lsdel.c +++ b/debugfs/lsdel.c @@ -140,7 +140,8 @@ void do_lsdel(int argc, char **argv) lsd.free_blocks = 0; lsd.bad_blocks = 0; - retval = ext2fs_block_iterate2(current_fs, ino, 0, block_buf, + retval = ext2fs_block_iterate2(current_fs, ino, + BLOCK_FLAG_READ_ONLY, block_buf, lsdel_proc, &lsd); if (retval) { com_err("ls_deleted_inodes", retval, diff --git a/misc/e2image.c b/misc/e2image.c index 1695d6ed..27507532 100644 --- a/misc/e2image.c +++ b/misc/e2image.c @@ -514,8 +514,9 @@ static void write_raw_image_file(ext2_filsys fs, int fd, int scramble_flag) (LINUX_S_ISLNK(inode.i_mode) && ext2fs_inode_has_valid_blocks(&inode)) || ino == fs->super->s_journal_inum) { - retval = ext2fs_block_iterate2(fs, ino, 0, - block_buf, process_dir_block, &pb); + retval = ext2fs_block_iterate2(fs, ino, + BLOCK_FLAG_READ_ONLY, block_buf, + process_dir_block, &pb); if (retval) { com_err(program_name, retval, "while iterating over inode %u", @@ -523,11 +524,12 @@ static void write_raw_image_file(ext2_filsys fs, int fd, int scramble_flag) exit(1); } } else { - if (inode.i_block[EXT2_IND_BLOCK] || + if ((inode.i_flags & EXT4_EXTENTS_FL) || + inode.i_block[EXT2_IND_BLOCK] || inode.i_block[EXT2_DIND_BLOCK] || inode.i_block[EXT2_TIND_BLOCK]) { retval = ext2fs_block_iterate2(fs, - ino, 0, block_buf, + ino, BLOCK_FLAG_READ_ONLY, block_buf, process_file_block, &pb); if (retval) { com_err(program_name, retval, diff --git a/misc/tune2fs.c b/misc/tune2fs.c index ee7ab386..fb5a1a45 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -251,7 +251,8 @@ static void remove_journal_inode(ext2_filsys fs) _("while reading bitmaps")); exit(1); } - retval = ext2fs_block_iterate(fs, ino, 0, NULL, + retval = ext2fs_block_iterate(fs, ino, + BLOCK_FLAG_READ_ONLY, NULL, release_blocks_proc, NULL); if (retval) { com_err(program_name, retval, -- cgit v1.2.3