]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
Use BLOCK_FLAG_READ_ONLY flag in debugfs, e2image, and tune2fs
authorTheodore Ts'o <tytso@mit.edu>
Thu, 7 Feb 2008 19:37:17 +0000 (14:37 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 19 Feb 2008 01:05:55 +0000 (20:05 -0500)
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" <tytso@mit.edu>
debugfs/debugfs.c
debugfs/htree.c
debugfs/icheck.c
debugfs/lsdel.c
misc/e2image.c
misc/tune2fs.c

index bcd9a9be6e219cb3478e1ce7979bbdc022f2ed7c..79998a20ff22a68dfda7772a9696358882c476ee 100644 (file)
@@ -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,
index d0e673eb511545474218052af0f4a952e35697a2..a46bae77333257f58193f7d02afbe65bb995c66e 100644 (file)
@@ -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);
 }
index a6b182d0c0e0459140483a90b42d9818c49c0527..01c78bcbd9650931072802616ac0cf6575c5931d 100644 (file)
@@ -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,
index b3293b85bad981bbc06500ddd8f833898fd07967..f703c6b30c489d88089673ec2687ebc4ba5f51ee 100644 (file)
@@ -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,
index 1695d6edd046d096a24525fd9dcc986a21df69f5..27507532c268ff928777e5b7e9ddf50662175f2a 100644 (file)
@@ -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,
index ee7ab3864c4ec10d109ea0842c3db46cf4d04885..fb5a1a450ff9db670b8f9ac647ea55d31dfdb021 100644 (file)
@@ -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,