Whamcloud - gitweb
debugfs: Add -a option to close_filesys command
authorTheodore Ts'o <tytso@mit.edu>
Fri, 29 May 2009 02:03:33 +0000 (22:03 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 29 May 2009 02:03:33 +0000 (22:03 -0400)
Add an -a option to the close_filesys command which writes any changes
to the superblock or block group descriptors to all of the backup
superblock locations.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
debugfs/debugfs.8.in
debugfs/debugfs.c

index 89a9b88..8e6468f 100644 (file)
@@ -169,8 +169,12 @@ Change the current working directory to
 Change the root directory to be the directory 
 .IR filespec .
 .TP
-.I close
-Close the currently open file system.
+.I close [-a]
+Close the currently open file system.  If the 
+.I -a
+option is specified, write out any changes to the superblock and block
+group descriptors to all of the backup superblocks, not just to the
+master superblock.
 .TP
 .I clri file
 Clear the contents of the inode 
index 83acf92..cf4b71f 100644 (file)
@@ -220,8 +220,28 @@ static void close_filesystem(NOARGS)
 
 void do_close_filesys(int argc, char **argv)
 {
-       if (common_args_process(argc, argv, 1, 1, "close_filesys", "", 0))
+       int     c;
+
+       if (check_fs_open(argv[0]))
+               return;
+
+       reset_getopt();
+       while ((c = getopt (argc, argv, "a")) != EOF) {
+               switch (c) {
+               case 'a':
+                       current_fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
+                       break;
+               default:
+                       goto print_usage;
+               }
+       }
+
+       if (argc > optind) {
+       print_usage:
+               com_err(0, 0, "Usage: close_filesys [-a]");
                return;
+       }
+
        close_filesystem();
 }