linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@whamcloud.com>
To: tytso@mit.edu, linux-ext4@vger.kernel.org
Cc: Andreas Dilger <adilger@whamcloud.com>
Subject: [PATCH] mke2fs: Don't erase flash device if "-n" is given
Date: Tue,  7 Jun 2011 10:22:29 -0600	[thread overview]
Message-ID: <1307463749-16498-1-git-send-email-adilger@whamcloud.com> (raw)

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 <adilger@whamcloud.com>
---
 misc/mke2fs.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index ddfa929..9472016 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -2132,7 +2132,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)
-- 
1.7.3.4


             reply	other threads:[~2011-06-07 16:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-07 16:22 Andreas Dilger [this message]
2011-06-07 16:58 ` [PATCH] mke2fs: Don't erase flash device if "-n" is given Eric Sandeen
2011-06-07 17:37   ` Ted Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1307463749-16498-1-git-send-email-adilger@whamcloud.com \
    --to=adilger@whamcloud.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).