From: Yongqiang Yang Date: Wed, 14 Sep 2011 15:55:59 +0000 (-0400) Subject: resize2fs: add support for new in-kernel online resize ioctl X-Git-Tag: android-x86-6.0-r1~26^2~703 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=9f6ba888f027ba;p=android-x86%2Fexternal-e2fsprogs.git resize2fs: add support for new in-kernel online resize ioctl This is needed to support online resizing for > 32-bit file systems Signed-off-by: Yongqiang Yang Signed-off-by: "Theodore Ts'o" --- diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h index 54cb3d4b..4fec5db0 100644 --- a/lib/ext2fs/ext2_fs.h +++ b/lib/ext2fs/ext2_fs.h @@ -327,6 +327,7 @@ struct ext4_new_group_input { #define EXT2_IOC_GROUP_EXTEND _IOW('f', 7, unsigned long) #define EXT2_IOC_GROUP_ADD _IOW('f', 8,struct ext2_new_group_input) #define EXT4_IOC_GROUP_ADD _IOW('f', 8,struct ext4_new_group_input) +#define EXT4_IOC_RESIZE_FS _IOW('f', 16, __u64) /* * Structure of an inode on the disk diff --git a/resize/online.c b/resize/online.c index 1d8d4ecf..1b3589bc 100644 --- a/resize/online.c +++ b/resize/online.c @@ -51,7 +51,7 @@ errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt, fs->super->s_first_data_block, EXT2_BLOCKS_PER_GROUP(fs->super)), EXT2_DESC_PER_BLOCK(fs->super)); - printf("old desc_blocks = %lu, new_desc_blocks = %lu\n", + printf("old_desc_blocks = %lu, new_desc_blocks = %lu\n", fs->desc_blocks, new_desc_blocks); if (!(fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_RESIZE_INODE) && @@ -69,6 +69,23 @@ errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt, } size=ext2fs_blocks_count(sb); + + if (ioctl(fd, EXT4_IOC_RESIZE_FS, new_size)) { + if (errno != ENOTTY) { + if (errno == EPERM) + com_err(program_name, 0, + _("Permission denied to resize filesystem")); + else + com_err(program_name, errno, + _("While checking for on-line resizing " + "support")); + exit(1); + } + } else { + close(fd); + return 0; + } + if (ioctl(fd, EXT2_IOC_GROUP_EXTEND, &size)) { if (errno == EPERM) com_err(program_name, 0,