[4/5] btrfs-progs: add help command to btrfs rescue zero-log
diff mbox

Message ID 7902fde708c717f3cc963240a9b02f0f6aa6d542.1441357933.git.zhaolei@cn.fujitsu.com
State New
Headers show

Commit Message

Zhaolei Sept. 4, 2015, 1:24 p.m. UTC
To make it unified with other two rescue command, which support
--help option.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
---
 cmds-rescue.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

Patch
diff mbox

diff --git a/cmds-rescue.c b/cmds-rescue.c
index a709e1b..3ed63f6 100644
--- a/cmds-rescue.c
+++ b/cmds-rescue.c
@@ -165,6 +165,7 @@  const char * const cmd_rescue_zero_log_usage[] = {
 	"Clear the tree log. Usable if it's corrupted and prevents mount.",
 	"",
 	HELPINFO_EXTRA_DEV,
+	"-h                 Help",
 	NULL
 };
 
@@ -179,10 +180,22 @@  int cmd_rescue_zero_log(int argc, char **argv)
 	if (set_extra_dev_from_arg(&argc, argv))
 		usage(cmd_rescue_zero_log_usage);
 
-	if (check_argc_exact(argc, 2))
+	while (1) {
+		int c = getopt(argc, argv, "h");
+
+		if (c < 0)
+			break;
+		switch (c) {
+		case 'h':
+		default:
+			usage(cmd_rescue_zero_log_usage);
+		}
+	}
+
+	if (check_argc_exact(argc - optind, 1))
 		usage(cmd_rescue_zero_log_usage);
 
-	devname = argv[1];
+	devname = argv[optind];
 	ret = check_mounted(devname);
 	if (ret < 0) {
 		fprintf(stderr, "Could not check mount status: %s\n", strerror(-ret));