public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
To: linux-btrfs@vger.kernel.org
Cc: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Subject: [PATCH] btrfsck: Exit and print error message when not able to open device
Date: Fri, 16 Jan 2009 22:27:57 -0200	[thread overview]
Message-ID: <1232152077-3862-1-git-send-email-cascardo@holoscopio.com> (raw)

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


             reply	other threads:[~2009-01-17  0:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-17  0:27 Thadeu Lima de Souza Cascardo [this message]
2009-01-20 19:26 ` [PATCH] btrfsck: Exit and print error message when not able to open device Zach Carter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1232152077-3862-1-git-send-email-cascardo@holoscopio.com \
    --to=cascardo@holoscopio.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox