Patchwork [22/25] tune2fs: handle inode and/or block bitmap read failures in resize_inode()

login
register
mail settings
Submitter Eric Sandeen
Date Sept. 16, 2011, 8:49 p.m.
Message ID <1316206180-6375-23-git-send-email-sandeen@redhat.com>
Download mbox | patch
Permalink /patch/115044/
State Accepted
Headers show

Comments

Eric Sandeen - Sept. 16, 2011, 8:49 p.m.
Handle these failures in resize_inode, and handle the propagated
error in the caller.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
 misc/tune2fs.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
Theodore Ts'o - Sept. 16, 2011, 11:57 p.m.
On Fri, Sep 16, 2011 at 03:49:37PM -0500, Eric Sandeen wrote:
> Handle these failures in resize_inode, and handle the propagated
> error in the caller.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Applied, thanks.

					- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 6d879f3..346e2d1 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -1589,8 +1589,16 @@  static int resize_inode(ext2_filsys fs, unsigned long new_size)
 	int new_ino_blks_per_grp;
 	ext2fs_block_bitmap bmap;
 
-	ext2fs_read_inode_bitmap(fs);
-	ext2fs_read_block_bitmap(fs);
+	retval = ext2fs_read_inode_bitmap(fs);
+	if (retval) {
+		fputs(_("Failed to read inode bitmap\n"), stderr);
+		return retval;
+	}
+	retval = ext2fs_read_block_bitmap(fs);
+	if (retval) {
+		fputs(_("Failed to read blockbitmap\n"), stderr);
+		return retval;
+	}
 	INIT_LIST_HEAD(&blk_move_list);
 
 
@@ -1989,6 +1997,9 @@  retry_open:
 		if (resize_inode(fs, new_inode_size) == 0) {
 			printf(_("Setting inode size %lu\n"),
 							new_inode_size);
+		} else {
+			printf(_("Failed to change inode size\n"));
+			exit(1);
 		}
 	}