public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfsck: Exit and print error message when not able to open device
@ 2009-01-17  0:27 Thadeu Lima de Souza Cascardo
  2009-01-20 19:26 ` Zach Carter
  0 siblings, 1 reply; 2+ messages in thread
From: Thadeu Lima de Souza Cascardo @ 2009-01-17  0:27 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Thadeu Lima de Souza Cascardo

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-01-20 19:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-17  0:27 [PATCH] btrfsck: Exit and print error message when not able to open device Thadeu Lima de Souza Cascardo
2009-01-20 19:26 ` Zach Carter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox