Skip to content

Commit

Permalink
main: preserve errno for create_directory
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
  • Loading branch information
giuseppe committed Mar 3, 2020
1 parent 47218d0 commit 9660aae
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2418,6 +2418,7 @@ create_directory (struct ovl_data *lo, int dirfd, const char *name, const struct
struct ovl_node *parent, int xattr_sfd, uid_t uid, gid_t gid, mode_t mode, bool set_opaque, struct stat *st_out)
{
int ret;
int saved_errno;
cleanup_close int dfd = -1;
cleanup_free char *buf = NULL;
char wd_tmp_file_name[32];
Expand Down Expand Up @@ -2511,8 +2512,10 @@ create_directory (struct ovl_data *lo, int dirfd, const char *name, const struct
ret = renameat (lo->workdir_fd, wd_tmp_file_name, dirfd, name);
}
out:
saved_errno = errno;
if (ret < 0)
unlinkat (lo->workdir_fd, wd_tmp_file_name, AT_REMOVEDIR);
errno = saved_errno;

return ret;
}
Expand Down

0 comments on commit 9660aae

Please sign in to comment.