From: Eric Sandeen Date: Mon, 18 May 2009 22:11:28 +0000 (-0500) Subject: resize2fs: don't try to resize below calculated minimum X-Git-Tag: v1.41.6~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d04d88a8d88fc11120746bc72a5ffb7d7f05cb0;p=thirdparty%2Fe2fsprogs.git resize2fs: don't try to resize below calculated minimum Without a force flag, don't allow resize2fs to even start resizing below what it thinks the minimum safe value is. This may stop resizes which could otherwise proceed with a bit of space still left, but seems like a reasonably safe thing to do. Signed-off-by: Eric Sandeen Signed-off-by: Theodore Ts'o --- diff --git a/resize/main.c b/resize/main.c index 6977d8483..330e3ea74 100644 --- a/resize/main.c +++ b/resize/main.c @@ -160,6 +160,7 @@ int main (int argc, char ** argv) int fd, ret; blk_t new_size = 0; blk_t max_size = 0; + blk_t min_size = 0; io_manager io_ptr; char *new_size_str = 0; int use_stride = -1; @@ -341,9 +342,11 @@ int main (int argc, char ** argv) exit(1); } + min_size = calculate_minimum_resize_size(fs); + if (print_min_size) { printf(_("Estimated minimum size of the filesystem: %u\n"), - calculate_minimum_resize_size(fs)); + min_size); exit(0); } @@ -388,6 +391,11 @@ int main (int argc, char ** argv) new_size &= ~((sys_page_size / fs->blocksize)-1); } + if (!force && new_size < min_size) { + com_err(program_name, 0, + _("New size smaller than minimum (%u)\n"), min_size); + exit(1); + } if (use_stride >= 0) { if (use_stride >= (int) fs->super->s_blocks_per_group) { com_err(program_name, 0,