Skip to contentSkip to conversation

btrfs-progs: Show error message if btrfs filesystem show failed to find any btrfs filesystem

PATCH Superseded Satoru Takeuchi 2 participants 2 messages Aug 11, 2014 – Aug 19, 2014 Btrfs file system

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 btrfs-progs: Show error message if btrfs filesystem show failed to find any btrfs filesystem

From: Satoru Takeuchi <[email protected]>

Current btrfs doesn't display any error message if this command failed to find any btrfs filesystem corresponding to <path>|<uuid>|<device>|<label> which user specified.

---
 cmds-filesystem.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
cmds-filesystem.c +10 -0
index 7633f1f..2f78e24 100644
@@ -695,6 +695,7 @@ static int cmd_show(int argc, char **argv)
 		ret = btrfs_scan_kernel(search);
 	if (search && !ret) {
 		/* since search is found we are done */
+		found = 1;
 		goto out;
 	}
 
@@ -729,6 +730,15 @@ devs_only:
 		btrfs_close_devices(fs_devices);
 	}
 out:
+	if (search && !found) {
+		fprintf(stderr,
+			"ERROR: Couldn't find any btrfs filesystem "
+			"matches with '%s'.\n", search);
+		fprintf(stderr,
+			"Please check if both '%s' and the range of scanning "
+			"are correct.\n", search);
+	}
+
 	printf("%s\n", BTRFS_BUILD_VERSION);
 	free_seen_fsid();
 	return ret;
Signature · 1 line
1.9.3
#1 lore raw
Quoted 5 lines · Satoru Takeuchi

From: Satoru Takeuchi <[email protected]>

Current btrfs doesn't display any error message if this command failed to find any btrfs filesystem corresponding to <path>|<uuid>|<device>|<label> which user specified.

I'm not sure if it is necessary to print anything. Like if grep printed "Sorry I did not find any lines, please check your regexp"

Although, we can add a non-zero return value if there was anything found or not.