From: Andreas Dilger Date: Tue, 7 Jun 2011 16:22:29 +0000 (-0600) Subject: mke2fs: Don't erase flash device if "-n" is given X-Git-Tag: v1.41.90.wc4~8 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=23537a11dff73d6bd9c87debac5a0345e81e719a;p=tools%2Fe2fsprogs.git mke2fs: Don't erase flash device if "-n" is given If "mke2fs -n" is used, there should be no changes to the underlying device. Unfortunately, when the "discard" option was added in commit c7cd908be59f48c66b4f3ac9a631ffe3dde4f1ab, it did not check for the "-n" flag, and will discard all data on a flash device even if "-n" is given. Check for the "noaction" flag before discarding any filesystem data. Signed-off-by: Andreas Dilger Reviewed-by: Eric Sandeen Signed-off-by: Theodore Ts'o Change-Id: I8ed6cfa06b6c6dd9ef3e64f1153eb1ec925ac312 --- diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 1da9305..172da14 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -2099,7 +2099,7 @@ int main (int argc, char *argv[]) } /* Can't undo discard ... */ - if (discard && (io_ptr != undo_io_manager)) { + if (!noaction && discard && (io_ptr != undo_io_manager)) { retval = mke2fs_discard_device(fs); if (!retval && io_channel_discard_zeroes_data(fs->io)) { if (verbose)