[PATCH V2] btrfs-progs: fix btrfstune silence on failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Originally, btrfstune will fail without any options, like this:

	# btrfstune /dev/sdb

An error prompt & usage should show up upon this condition.

Signed-off-by: Gui Hecheng <guihc.fnst@xxxxxxxxxxxxxx>
---
V1 -> V2:
	add optind assignment to make reviewers happy;
	print error msg if no options provided
---
 btrfstune.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/btrfstune.c b/btrfstune.c
index 50724ba..da82f36 100644
--- a/btrfstune.c
+++ b/btrfstune.c
@@ -115,6 +115,7 @@ int main(int argc, char *argv[])
 	int skinny_flag = 0;
 	int ret;
 
+	optind = 1;
 	while(1) {
 		int c = getopt(argc, argv, "S:rx");
 		if (c < 0)
@@ -143,6 +144,13 @@ int main(int argc, char *argv[])
 		return 1;
 	}
 
+	if (!(seeding_flag + extrefs_flag + skinny_flag)) {
+		fprintf(stderr,
+			"ERROR: At least one option should be assigned.\n");
+		print_usage();
+		return 1;
+	}
+
 	if (check_mounted(device)) {
 		fprintf(stderr, "%s is mounted\n", device);
 		return 1;
@@ -176,6 +184,7 @@ int main(int argc, char *argv[])
 	} else {
 		root->fs_info->readonly = 1;
 		ret = 1;
+		fprintf(stderr, "btrfstune failed\n");
 	}
 	close_ctree(root);
 
-- 
1.8.0.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux