Skip to contentSkip to conversation

btrfsck: decode error properly

PATCH New [email protected] 1 participant 1 message Aug 28, 2011 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfsck: decode error properly

From: Sergei Trofimovich <[email protected]>

check_mounted() returns kernel-style negative errors. Patch drops sign for strerror().

Before the patch:
check_mounted(): Could not open /dev/sdb2
Could not check mount status: Unknown error 18446744073709551603

After the patch:
check_mounted(): Could not open /dev/sdb2 Could not check mount status: Permission denied

---
 btrfs-select-super.c |    2 +-
 btrfs-zero-log.c     |    2 +-
 btrfsck.c            |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
btrfs-select-super.c +1 -1
index f12f36c..51eb9c9 100644
@@ -75,7 +75,7 @@ int main(int ac, char **av)
 	radix_tree_init();
 
 	if((ret = check_mounted(av[optind])) < 0) {
-		fprintf(stderr, "Could not check mount status: %s\n", strerror(ret));
+		fprintf(stderr, "Could not check mount status: %s\n", strerror(-ret));
 		return ret;
 	} else if(ret) {
 		fprintf(stderr, "%s is currently mounted. Aborting.\n", av[optind]);
btrfs-zero-log.c +1 -1
index f10438b..54d7858 100644
@@ -50,7 +50,7 @@ int main(int ac, char **av)
 	radix_tree_init();
 
 	if((ret = check_mounted(av[1])) < 0) {
-		fprintf(stderr, "Could not check mount status: %s\n", strerror(ret));
+		fprintf(stderr, "Could not check mount status: %s\n", strerror(-ret));
 		return ret;
 	} else if(ret) {
 		fprintf(stderr, "%s is currently mounted. Aborting.\n", av[1]);
btrfsck.c +1 -1
index fc2ac88..3a23e66 100644
@@ -2838,7 +2838,7 @@ int main(int ac, char **av)
 	cache_tree_init(&root_cache);
 
 	if((ret = check_mounted(av[optind])) < 0) {
-		fprintf(stderr, "Could not check mount status: %s\n", strerror(ret));
+		fprintf(stderr, "Could not check mount status: %s\n", strerror(-ret));
 		return ret;
 	} else if(ret) {
 		fprintf(stderr, "%s is currently mounted. Aborting.\n", av[optind]);
Signature · 1 line
1.7.3.4