linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@dilger.ca>
To: tytso@mit.edu
Cc: linux-ext4@vger.kernel.org, Andreas Dilger <adilger@dilger.ca>
Subject: [PATCH 2/6] debugfs: improve dump_mmp handling
Date: Sat,  5 Mar 2016 17:38:32 -0700	[thread overview]
Message-ID: <1457224716-72388-2-git-send-email-adilger@dilger.ca> (raw)
In-Reply-To: <1457224716-72388-1-git-send-email-adilger@dilger.ca>

If MMP is not enabled on a filesystem (s_mmp_block == 0), print this
clearly rather than "MMP: block number beyond filesystem range".

Add an option to "debugfs dump_mmp" to specify the MMP block number
instead of getting it from the superblock s_mmp_block field.

Signed-off-by: Andreas Dilger <adilger@dilger.ca>
---
 debugfs/debugfs.8.in |  9 +++++++--
 debugfs/debugfs.c    | 25 ++++++++++++++++++++++---
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/debugfs/debugfs.8.in b/debugfs/debugfs.8.in
index bae14db..4928791 100644
--- a/debugfs/debugfs.8.in
+++ b/debugfs/debugfs.8.in
@@ -221,8 +221,13 @@ option is given set the owner, group and permissions information on
 to match
 .IR filespec .
 .TP
-.B dump_mmp
-Display the multiple-mount protection (mmp) field values.
+.BI dump_mmp " [mmp_block]"
+Display the multiple-mount protection (mmp) field values.  If
+.I mmp_block
+is specified then verify and dump the MMP values from the given block
+number, otherwise use the
+.B s_mmp_block
+field in the superblock to locate and use the existing MMP block.
 .TP
 .BI dx_hash " [-h hash_alg] [-s hash_seed] filename"
 Calculate the directory hash of
diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c
index 5423634..260698c 100644
--- a/debugfs/debugfs.c
+++ b/debugfs/debugfs.c
@@ -2351,12 +2351,31 @@ try_again:
 void do_dump_mmp(int argc EXT2FS_ATTR((unused)), char *argv[])
 {
 	struct mmp_struct *mmp_s;
+	unsigned long long mmp_block;
 	time_t t;
 	errcode_t retval = 0;
 
 	if (check_fs_open(argv[0]))
 		return;
 
+	if (argc > 1) {
+		char *end = NULL;
+		mmp_block = strtoull(argv[1], &end, 0);
+		if (end == argv[0] || mmp_block == 0) {
+			fprintf(stderr, "%s: invalid MMP block '%s' given\n",
+				argv[0], argv[1]);
+			return;
+		}
+	} else {
+		mmp_block = current_fs->super->s_mmp_block;
+	}
+
+	if (mmp_block == 0) {
+		fprintf(stderr, "%s: MMP: not active on this filesystem.\n",
+			argv[0]);
+		return;
+	}
+
 	if (current_fs->mmp_buf == NULL) {
 		retval = ext2fs_get_mem(current_fs->blocksize,
 					&current_fs->mmp_buf);
@@ -2368,10 +2387,10 @@ void do_dump_mmp(int argc EXT2FS_ATTR((unused)), char *argv[])
 
 	mmp_s = current_fs->mmp_buf;
 
-	retval = ext2fs_mmp_read(current_fs, current_fs->super->s_mmp_block,
-				 current_fs->mmp_buf);
+	retval = ext2fs_mmp_read(current_fs, mmp_block, current_fs->mmp_buf);
 	if (retval) {
-		com_err(argv[0], retval, "reading MMP block.\n");
+		com_err(argv[0], retval, "reading MMP block %llu.\n",
+			mmp_block);
 		return;
 	}
 
-- 
1.8.0


  reply	other threads:[~2016-03-06  0:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-06  0:38 [PATCH 1/6] blkid: fix ZFS device detection Andreas Dilger
2016-03-06  0:38 ` Andreas Dilger [this message]
2016-03-06 23:11   ` [PATCH 2/6] debugfs: improve dump_mmp handling Theodore Ts'o
2016-03-06  0:38 ` [PATCH 3/6] misc: add missing declarations on maint Andreas Dilger
2016-03-06 23:12   ` Theodore Ts'o
2016-03-06  0:38 ` [PATCH 4/6] lsattr: treat inode generation as an unsigned int Andreas Dilger
2016-03-06 23:13   ` Theodore Ts'o
2016-03-06  0:38 ` [PATCH 5/6] findsuper: improve output if s_mkfs_time unset Andreas Dilger
2016-03-06 23:16   ` Theodore Ts'o
2016-03-06  0:38 ` [PATCH 6/6] debugfs: update to handle newer inode fields Andreas Dilger
2016-03-07  0:54   ` Theodore Ts'o
2016-03-06 23:10 ` [PATCH 1/6] blkid: fix ZFS device detection Theodore 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=1457224716-72388-2-git-send-email-adilger@dilger.ca \
    --to=adilger@dilger.ca \
    --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).