From dfea3f9b638435fbfcb9332f6f73c49f44e8dad7 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 13 Jan 2020 22:24:32 +0100 Subject: [PATCH] main: fix fallocate for deleted files allow to use fallocate on an unlinked path if there is still a reference to it. Signed-off-by: Giuseppe Scrivano --- main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index b7ad961..329c67d 100644 --- a/main.c +++ b/main.c @@ -4719,6 +4719,7 @@ ovl_fallocate (fuse_req_t req, fuse_ino_t ino, int mode, off_t offset, off_t len struct ovl_data *lo = ovl_data (req); cleanup_close int fd = -1; struct ovl_node *node; + int dirfd; int ret; if (UNLIKELY (ovl_debug (req))) @@ -4739,7 +4740,8 @@ ovl_fallocate (fuse_req_t req, fuse_ino_t ino, int mode, off_t offset, off_t len return; } - fd = node->layer->ds->openat (node->layer, node->path, O_NONBLOCK|O_NOFOLLOW|O_WRONLY, 0755); + dirfd = node_dirfd (node); + fd = openat (dirfd, node->path, O_NONBLOCK|O_NOFOLLOW|O_WRONLY, 0755); if (fd < 0) { fuse_reply_err (req, errno);