Thadeu Lima de Souza Cascardo
2009-Jan-17 00:27 UTC
[PATCH] btrfsck: Exit and print error message when not able to open device
If btrfsck is not able to open a device, it segfaults. This fixes it and
prints an error message too.
---
btrfsck.c | 3 +++
disk-io.c | 1 +
2 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/btrfsck.c b/btrfsck.c
index 4a41e6d..cde0e68 100644
--- a/btrfsck.c
+++ b/btrfsck.c
@@ -2075,6 +2075,9 @@ int main(int ac, char **av)
radix_tree_init();
root = open_ctree(av[1], 0, 0);
+ if (root == NULL)
+ return 1;
+
ret = check_extents(root);
if (ret)
goto out;
diff --git a/disk-io.c b/disk-io.c
index c15cf53..e49c220 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -530,6 +530,7 @@ struct btrfs_root *open_ctree(const char *filename, u64
sb_bytenr, int writes)
fp = open(filename, flags, 0600);
if (fp < 0) {
+ fprintf (stderr, "Coult not open %s\n", filename);
return NULL;
}
root = open_ctree_fd(fp, filename, sb_bytenr, writes);
--
1.6.0.6
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs"
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Zach Carter
2009-Jan-20 19:26 UTC
Re: [PATCH] btrfsck: Exit and print error message when not able to open device
On Friday 16 January 2009 16:27:57 Thadeu Lima de Souza Cascardo wrote:> + fprintf (stderr, "Coult not open %s\n", filename);"Coult" should be "Could". Other than that, the patch seems to fix the segfault issue for me. thanks, -Zach -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html