Skip to content

Commit

Permalink
store errno immediately after ioctl
Browse files Browse the repository at this point in the history
Signed-off-by: Oleg Freedholm <overlayfs@gmail.com>
  • Loading branch information
22oleg committed Apr 3, 2016
1 parent 8ba6dc5 commit 58232f8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/lxc/bdev/lxcbtrfs.c
Expand Up @@ -568,7 +568,7 @@ static int btrfs_recursive_destroy(const char *path)
struct btrfs_ioctl_search_header sh;
struct btrfs_root_ref *ref;
struct my_btrfs_tree *tree;
int ret, i;
int ret, e, i;
unsigned long off = 0;
int name_len;
char *name;
Expand All @@ -582,8 +582,9 @@ static int btrfs_recursive_destroy(const char *path)
}

if (btrfs_list_get_path_rootid(fd, &root_id)) {
e = errno;
close(fd);
if (errno == EPERM || errno == EACCES) {
if (e == EPERM || e == EACCES) {
WARN("Will simply try removing");
goto ignore_search;
}
Expand Down Expand Up @@ -614,10 +615,11 @@ static int btrfs_recursive_destroy(const char *path)

while(1) {
ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
e = errno;
if (ret < 0) {
close(fd);
free_btrfs_tree(tree);
if (errno == EPERM || errno == EACCES) {
if (e == EPERM || e == EACCES) {
WARN("Warn: can't perform the search under %s. Will simply try removing", path);
goto ignore_search;
}
Expand Down

0 comments on commit 58232f8

Please sign in to comment.