From: Eric Sandeen <sandeen@redhat.com>
To: ext4 development <linux-ext4@vger.kernel.org>
Subject: [PATCH 2/4] e2fsprogs: Tidy up mmp handling in debugfs
Date: Thu, 10 Nov 2011 16:53:22 -0600 [thread overview]
Message-ID: <4EBC55E2.3080600@redhat.com> (raw)
In-Reply-To: <4EBC5524.3000105@redhat.com>
Several small fixes:
* Gracefully fail mmp commands if fs is not open
* Show magic number in dump_mmp command
* Fix header in output for set_mmp_value -l
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c
index eba3b69..1fb8f44 100644
--- a/debugfs/debugfs.c
+++ b/debugfs/debugfs.c
@@ -2165,11 +2165,15 @@ void do_punch(int argc, char *argv[])
void do_dump_mmp(int argc, char *argv[])
{
- struct ext2_super_block *sb = current_fs->super;
+ struct ext2_super_block *sb;
struct mmp_struct *mmp_s;
time_t t;
errcode_t retval = 0;
+ if (check_fs_open(argv[0]))
+ return;
+
+ sb = current_fs->super;
if (sb->s_mmp_block <= sb->s_first_data_block ||
sb->s_mmp_block >= ext2fs_blocks_count(sb)) {
com_err(argv[0], EXT2_ET_MMP_BAD_BLOCK, "while dumping it.\n");
@@ -2203,6 +2207,7 @@ void do_dump_mmp(int argc, char *argv[])
fprintf(stdout, "time: %lld -- %s", mmp_s->mmp_time, ctime(&t));
fprintf(stdout, "node_name: %s\n", mmp_s->mmp_nodename);
fprintf(stdout, "device_name: %s\n", mmp_s->mmp_bdevname);
+ fprintf(stdout, "magic: 0x%x\n", mmp_s->mmp_magic);
}
static int source_file(const char *cmd_file, int sci_idx)
diff --git a/debugfs/set_fields.c b/debugfs/set_fields.c
index d461275..0041160 100644
--- a/debugfs/set_fields.c
+++ b/debugfs/set_fields.c
@@ -242,6 +242,9 @@ static struct field_set_info ext4_bg_fields[] = {
{ 0, 0, 0, 0 }
};
+/* forward declaration */
+static struct field_set_info mmp_fields[];
+
static int check_suffix(const char *field)
{
int len = strlen(field);
@@ -561,6 +564,9 @@ static void print_possible_fields(struct field_set_info *fields)
} else if (fields == inode_fields) {
type = "Inode";
cmd = "set_inode";
+ } else if (fields == mmp_fields) {
+ type = "MMP";
+ cmd = "set_mmp_value";
} else {
type = "Block group descriptor";
cmd = "set_block_group";
@@ -768,6 +774,9 @@ void do_set_mmp_value(int argc, char *argv[])
return;
}
+ if (check_fs_open(argv[0]))
+ return;
+
if (current_fs->super->s_mmp_block == 0) {
com_err(argv[0], 0, "no MMP block allocated\n");
return;
next prev parent reply other threads:[~2011-11-10 22:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-10 22:50 [PATCH 0/4] cleanup various mmp cruft & bugs Eric Sandeen
2011-11-10 22:51 ` [PATCH 1/4] e2fsprogs: Document mmp commands in debugfs manpage Eric Sandeen
2011-11-12 2:12 ` Ted Ts'o
2011-11-10 22:53 ` Eric Sandeen [this message]
2011-11-12 2:12 ` [PATCH 2/4] e2fsprogs: Tidy up mmp handling in debugfs Ted Ts'o
2011-11-10 23:00 ` [PATCH 3/4] e2fsprogs: Fix write size in ext2fs_mmp_write Eric Sandeen
2011-11-12 2:13 ` Ted Ts'o
2011-11-10 23:04 ` [PATCH 4/4] e2fsprogs: fix mmp tests on hard 4k devices (resend) Eric Sandeen
2011-11-12 2:13 ` 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=4EBC55E2.3080600@redhat.com \
--to=sandeen@redhat.com \
--cc=linux-ext4@vger.kernel.org \
/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).