X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=resize%2Fmain.c;h=e4b44354d121476cff6e0540dd53af4742b2759d;hb=5b5bd2c251d1f999eddebb4d35fc1fba6004562a;hp=711e37547486474b43eb5a533c3e1985e637af95;hpb=42519becdafda2be9ca3fcfc8188b85592c71d86;p=tools%2Fe2fsprogs.git diff --git a/resize/main.c b/resize/main.c index 711e375..e4b4435 100644 --- a/resize/main.c +++ b/resize/main.c @@ -36,7 +36,8 @@ extern int optind; #include "../version.h" -char *program_name, *device_name, *io_options; +char *program_name; +static char *device_name, *io_options; static void usage (char *prog) { @@ -147,6 +148,18 @@ static void determine_fs_stride(ext2_filsys fs) #endif } +static void bigalloc_check(ext2_filsys fs, int force) +{ + if (!force && EXT2_HAS_RO_COMPAT_FEATURE(fs->super, + EXT4_FEATURE_RO_COMPAT_BIGALLOC)) { + fprintf(stderr, "%s", _("\nResizing bigalloc file systems has " + "not been fully tested. Proceed at\n" + "your own risk! Use the force option " + "if you want to go ahead anyway.\n\n")); + exit(1); + } +} + int main (int argc, char ** argv) { errcode_t retval; @@ -300,12 +313,23 @@ int main (int argc, char ** argv) retval = ext2fs_open2(device_name, io_options, io_flags, 0, 0, io_ptr, &fs); if (retval) { - com_err (program_name, retval, _("while trying to open %s"), - device_name); - printf (_("Couldn't find valid filesystem superblock.\n")); + com_err(program_name, retval, _("while trying to open %s"), + device_name); + printf("%s", _("Couldn't find valid filesystem superblock.\n")); exit (1); } + if (!(mount_flags & EXT2_MF_MOUNTED)) { + if (!force && ((fs->super->s_lastcheck < fs->super->s_mtime) || + (fs->super->s_state & EXT2_ERROR_FS) || + ((fs->super->s_state & EXT2_VALID_FS) == 0))) { + fprintf(stderr, + _("Please run 'e2fsck -f %s' first.\n\n"), + device_name); + exit(1); + } + } + /* * Check for compatibility with the feature sets. We need to * be more stringent than ext2fs_open(). @@ -316,16 +340,9 @@ int main (int argc, char ** argv) exit(1); } - min_size = calculate_minimum_resize_size(fs); + min_size = calculate_minimum_resize_size(fs, flags); if (print_min_size) { - if (!force && ((fs->super->s_state & EXT2_ERROR_FS) || - ((fs->super->s_state & EXT2_VALID_FS) == 0))) { - fprintf(stderr, - _("Please run 'e2fsck -f %s' first.\n\n"), - device_name); - exit(1); - } printf(_("Estimated minimum size of the filesystem: %llu\n"), min_size); exit(0); @@ -351,7 +368,7 @@ int main (int argc, char ** argv) retval = ext2fs_get_device_size2(device_name, fs->blocksize, &max_size); if (retval) { - com_err(program_name, retval, + com_err(program_name, retval, "%s", _("while trying to determine filesystem size")); exit(1); } @@ -377,7 +394,7 @@ int main (int argc, char ** argv) if (new_size == (1ULL << 32)) new_size--; else if (new_size > (1ULL << 32)) { - com_err(program_name, 0, + com_err(program_name, 0, "%s", _("New size too large to be " "expressed in 32 bits\n")); exit(1); @@ -391,7 +408,7 @@ int main (int argc, char ** argv) } if (use_stride >= 0) { if (use_stride >= (int) fs->super->s_blocks_per_group) { - com_err(program_name, 0, + com_err(program_name, 0, "%s", _("Invalid stride length")); exit(1); } @@ -428,16 +445,10 @@ int main (int argc, char ** argv) exit(0); } if (mount_flags & EXT2_MF_MOUNTED) { + bigalloc_check(fs, force); retval = online_resize_fs(fs, mtpt, &new_size, flags); } else { - if (!force && ((fs->super->s_lastcheck < fs->super->s_mtime) || - (fs->super->s_state & EXT2_ERROR_FS) || - ((fs->super->s_state & EXT2_VALID_FS) == 0))) { - fprintf(stderr, - _("Please run 'e2fsck -f %s' first.\n\n"), - device_name); - exit(1); - } + bigalloc_check(fs, force); printf(_("Resizing the filesystem on " "%s to %llu (%dk) blocks.\n"), device_name, new_size, fs->blocksize / 1024); @@ -453,7 +464,7 @@ int main (int argc, char ** argv) _("Please run 'e2fsck -fy %s' to fix the filesystem\n" "after the aborted resize operation.\n"), device_name); - ext2fs_close(fs); + ext2fs_close_free(&fs); exit(1); } printf(_("The filesystem on %s is now %llu blocks long.\n\n"),