mirror of
https://github.com/containers/fuse-overlayfs.git
synced 2025-09-12 16:57:05 -04:00
main: check if whiteout device already exists
on newer kernels unprivileged users can create whiteout devices. If the whiteout device creation failed with EEXIST, check whether the existing file is already a whiteout. Closes: https://github.com/containers/fuse-overlayfs/issues/271 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
865b3b9dfb
commit
6f2af48a03
15
main.c
15
main.c
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user