mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git
synced 2024-11-28 06:34:17 +08:00
btrfs-progs: fix improper error handling in btrfs filesystem usage
I was seeing test-cli/016 failures because it claimed we were getting EPERM from the TREE_SEARCH ioctl to get the chunk info out of the file system. This turned out to be because errno was already set going into this function, the ioctl itself wasn't actually failing. Fix this by checking for a return value from the ioctl first, and then returning -EPERM if appropriate. This fixed the failures in my setup. Signed-off-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
db7157d912
commit
0ba50a27f4
@ -145,7 +145,7 @@ static int load_chunk_info(int fd, struct chunk_info **chunkinfo_ret,
|
||||
struct btrfs_ioctl_search_key *sk = &args.key;
|
||||
struct btrfs_ioctl_search_header *sh;
|
||||
unsigned long off = 0;
|
||||
int i, e;
|
||||
int i;
|
||||
|
||||
memset(&args, 0, sizeof(args));
|
||||
|
||||
@ -168,11 +168,9 @@ static int load_chunk_info(int fd, struct chunk_info **chunkinfo_ret,
|
||||
|
||||
while (1) {
|
||||
ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
|
||||
e = errno;
|
||||
if (e == EPERM)
|
||||
return -e;
|
||||
|
||||
if (ret < 0) {
|
||||
if (errno == EPERM)
|
||||
return -errno;
|
||||
error("cannot look up chunk tree info: %m");
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user