[PATCH] btrfsck open_ctree sanity check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




i.e  Permission denied, open_ctree will return NULL, then lead
to a segment fault later.

Signed-off-by Yongli He <heyongli@xxxxxxxxx>
---
 btrfsck.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/btrfsck.c b/btrfsck.c
index 801249b..86c2eeb 100644
--- a/btrfsck.c
+++ b/btrfsck.c
@@ -770,6 +770,11 @@ int main(int ac, char **av) {
 	cache_tree_init(&reada);

 	root = open_ctree(av[1], 0, 0);
+	if(!root){
+		perror("open");
+		exit(1);
+	}
+	

 	bits_nr = 1024;
 	bits = malloc(bits_nr * sizeof(struct block_info));
--
1.5.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux