[PATCH] btrfs-progs: deal with conflict options for btrfs fi show

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

 



For btrfs fi show, -d|--all-devices & -m|--mounted will
overwrite each other, so if specified both, let the user
know that he should not use them at the same time.

Signed-off-by: Gui Hecheng <guihc.fnst@xxxxxxxxxxxxxx>
---
 cmds-filesystem.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index 69c1ca5..78aeacc 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -526,16 +526,23 @@ static int cmd_show(int argc, char **argv)
 			break;
 		switch (c) {
 		case 'd':
-			where = BTRFS_SCAN_PROC;
+			where &= ~BTRFS_SCAN_LBLKID;
+			where |= BTRFS_SCAN_PROC;
 			break;
 		case 'm':
-			where = BTRFS_SCAN_MOUNTED;
+			where &= ~BTRFS_SCAN_LBLKID;
+			where |= BTRFS_SCAN_MOUNTED;
 			break;
 		default:
 			usage(cmd_show_usage);
 		}
 	}
 
+	if ((where & BTRFS_SCAN_PROC) && (where & BTRFS_SCAN_MOUNTED)) {
+		fprintf(stderr, "don't use -d|--all-devices and -m|--mounted options at the same time\n");
+		usage(cmd_show_usage);
+	}
+
 	if (check_argc_max(argc, optind + 1))
 		usage(cmd_show_usage);
 
-- 
1.8.1.4

--
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