Merge pull request #272 from giuseppe/check-whiteout-already-exists

main: check if whiteout device already exists
This commit is contained in:
Daniel J Walsh 2021-01-25 13:48:21 -05:00 committed by GitHub
commit b104426786
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

15
main.c
View File

@ -733,6 +733,21 @@ create_whiteout (struct ovl_data *lo, struct ovl_node *parent, const char *name,
if (ret == 0)
return 0;
if (errno == EEXIST)
{
int saved_errno = errno;
struct stat st;
/* Check whether it is already a whiteout. */
if (TEMP_FAILURE_RETRY (fstatat (get_upper_layer (lo)->fd, whiteout_path, &st, AT_SYMLINK_NOFOLLOW)) == 0
&& (st.st_mode & S_IFMT) == S_IFCHR
&& major (st.st_rdev) == 0
&& minor (st.st_rdev) == 0)
return 0;
errno = saved_errno;
}
if (errno != EPERM && errno != ENOTSUP)
return -1;