Skip to contentSkip to conversation

btrfs-progs: Fix btrfs fi show by uuid and label

PATCH In review Justin Maggard 2 participants 2 messages Dec 23, 2014 – Dec 24, 2014 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs-progs: Fix btrfs fi show by uuid and label

Commit 8be2fff (btrfs-progs: apply realpath for btrfs fi show when mount point is given) changed the behavior of btrfs fi show to return an error if the call to realpath() failed. This broke the ability to specify a filesystem by uuid or label.

So let's not consider a failed call to realpath() as an error. If the user really specified a bad device, just return nothing like we did before.

---
 cmds-filesystem.c |    9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
cmds-filesystem.c +2 -7
index 8f037dd..a654e6f 100644
@@ -901,13 +901,8 @@ static int cmd_show(int argc, char **argv)
 		 *     realpath do  /mnt/btrfs/  => /mnt/btrfs
 		 *     which shall be recognized by btrfs_scan_kernel()
 		 */
-		if (!realpath(search, path)) {
-			fprintf(stderr, "ERROR: Could not show %s: %s\n",
-					search, strerror(errno));
-			return 1;
-		}
-
-		search = path;
+		if (realpath(search, path))
+			search = path;
 
 		/*
 		 * Needs special handling if input arg is block dev And if
Signature · 1 line
1.7.10.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Justin Maggard

Commit 8be2fff (btrfs-progs: apply realpath for btrfs fi show when mount point is given) changed the behavior of btrfs fi show to return an error if the call to realpath() failed. This broke the ability to specify a filesystem by uuid or label.

Oh, that's my fault, thanks for correcting this.

Quoted 14 lines

So let's not consider a failed call to realpath() as an error. If the user really specified a bad device, just return nothing like we did before.

---
 cmds-filesystem.c |    9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
cmds-filesystem.c +0 -0
index 8f037dd..a654e6f 100644
@@ -901,13 +901,8 @@ static int cmd_show(int argc, char **argv)
 		 *     realpath do  /mnt/btrfs/  => /mnt/btrfs
 		 *     which shall be recognized by btrfs_scan_kernel()

cmds-filesystem.c static int cmd_show(int argc, char **argv) · line 905

Quoted 10 lines
cmds-filesystem.c +2 -7
 		 */
-		if (!realpath(search, path)) {
-			fprintf(stderr, "ERROR: Could not show %s: %s\n",
-					search, strerror(errno));
-			return 1;
-		}
-
-		search = path;
+		if (realpath(search, path))
+			search = path;

This looks nice and stay consistent with the behavior before my faulty commit.

Thanks,
Gui

Quoted 2 lines
cmds-filesystem.c +0 -0
 		/*
 		 * Needs special handling if input arg is block dev And if