From 6dce532867a0f8d6a99a2c6fe049de411dc109f2 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 28 May 2009 22:03:33 -0400 Subject: [PATCH] debugfs: Add -a option to close_filesys command 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" --- debugfs/debugfs.8.in | 8 ++++++-- debugfs/debugfs.c | 22 +++++++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/debugfs/debugfs.8.in b/debugfs/debugfs.8.in index 89a9b88..8e6468f 100644 --- a/debugfs/debugfs.8.in +++ b/debugfs/debugfs.8.in @@ -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 diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index 83acf92..cf4b71f 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -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(); } -- 1.8.3.1