From 29877f7edfde2e785dc52cab666d584b7f555f91 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Sat, 27 Apr 2019 09:31:59 +0200 Subject: [PATCH] fuse-overlayfs: create opaque whiteout file for dirs Signed-off-by: Giuseppe Scrivano --- main.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 3b8e00e..1e53af6 100644 --- a/main.c +++ b/main.c @@ -417,15 +417,20 @@ has_prefix (const char *str, const char *pref) static int 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) - return 0; + goto create_opq_whiteout; if (errno != EPERM || fsetxattr (fd, OPAQUE_XATTR, "y", 1, 0) < 0 && errno != ENOTSUP) return -1; } - - return 0; + create_opq_whiteout: + 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