]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
debugfs: tidy up mmp handling
authorEric Sandeen <sandeen@redhat.com>
Sat, 12 Nov 2011 02:06:04 +0000 (21:06 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 12 Nov 2011 02:06:04 +0000 (21:06 -0500)
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>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debugfs/debugfs.c
debugfs/set_fields.c

index eba3b697efd844c3b31e3f6977d9834573a18213..1fb8f448bea2ba7ae48ce5d52ea6d357429b43d5 100644 (file)
@@ -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)
index d461275904753ba3da20981bb8675557bb503eae..00411605456448f6665272856daecf3e05cd4180 100644 (file)
@@ -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;