fuse-overlayfs: create opaque whiteout file for dirs

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2019-04-27 09:31:59 +02:00
parent 064452bfba
commit 29877f7edf
No known key found for this signature in database
GPG Key ID: E4730F97F60286ED

13
main.c
View File

@ -417,15 +417,20 @@ has_prefix (const char *str, const char *pref)
static int static int
set_fd_opaque (int fd) set_fd_opaque (int fd)
{ {
if (fsetxattr (fd, PRIVILEGED_OPAQUE_XATTR, "y", 1, 0) < 0) cleanup_close int opq_whiteout_fd = -1;
int ret;
ret = fsetxattr (fd, PRIVILEGED_OPAQUE_XATTR, "y", 1, 0);
if (ret < 0)
{ {
if (errno == ENOTSUP) if (errno == ENOTSUP)
return 0; goto create_opq_whiteout;
if (errno != EPERM || fsetxattr (fd, OPAQUE_XATTR, "y", 1, 0) < 0 && errno != ENOTSUP) if (errno != EPERM || fsetxattr (fd, OPAQUE_XATTR, "y", 1, 0) < 0 && errno != ENOTSUP)
return -1; return -1;
} }
create_opq_whiteout:
return 0; opq_whiteout_fd = TEMP_FAILURE_RETRY (openat (fd, OPAQUE_WHITEOUT, O_CREAT|O_WRONLY|O_NONBLOCK, 0700));
return (opq_whiteout_fd >= 0 || ret == 0) ? 0 : -1;
} }
static int static int