diff options
author | Goffredo Baroncelli <kreijack@inwind.it> | 2010-03-11 21:51:36 +0100 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2010-03-11 22:09:46 -0500 |
commit | e584004d3c350cdb7e489c330e03386b816719fe (patch) | |
tree | f4ba7cc819a318f9af2a3c75c5cc4a697f7567cd | |
parent | 7ebebb7bb14ad3a5e78d8d9047350591fa96f585 (diff) |
Avoid the exit(2) function; instead return with an appropriate value;
-rw-r--r-- | btrfs-list.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/btrfs-list.c b/btrfs-list.c index 6305d3c5..f2f119be 100644 --- a/btrfs-list.c +++ b/btrfs-list.c @@ -66,7 +66,7 @@ struct root_info { char name[]; }; -void root_lookup_init(struct root_lookup *tree) +static void root_lookup_init(struct root_lookup *tree) { tree->root.rb_node = NULL; } @@ -275,9 +275,9 @@ static int lookup_ino_path(int fd, struct root_info *ri) ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args); if (ret) { - fprintf(stderr, "Failed to lookup path for root %llu\n", + fprintf(stderr, "ERROR: Failed to lookup path for root %llu\n", (unsigned long long)ri->ref_tree); - exit(1); + return ret; } if (args.name[0]) { @@ -346,8 +346,8 @@ int list_subvols(int fd) while(1) { ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args); if (ret < 0) { - perror("ioctl:"); - break; + fprintf(stderr, "ERROR: can't perform the search\n"); + return ret; } /* the ioctl returns the number of item it found in nr_items */ if (sk->nr_items == 0) @@ -398,8 +398,11 @@ int list_subvols(int fd) n = rb_first(&root_lookup.root); while (n) { struct root_info *entry; + int ret; entry = rb_entry(n, struct root_info, rb_node); - lookup_ino_path(fd, entry); + ret = lookup_ino_path(fd, entry); + if(ret < 0) + return ret; n = rb_next(n); } |