mirror of
https://github.com/containers/fuse-overlayfs.git
synced 2025-09-08 14:52:31 -04:00
fuse-overlayfs: fix renameat2(RENAME_NOREPLACE)
when device whiteouts are created (supported for unprivileged users in newer Linux kernels) make sure the RENAME_NOREPLACE flag is dropped when renaming the file on top of an existing whiteout. Closes: https://github.com/containers/fuse-overlayfs/issues/273 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
parent
b104426786
commit
450b0d790f
4
main.c
4
main.c
@ -757,7 +757,6 @@ create_whiteout (struct ovl_data *lo, struct ovl_node *parent, const char *name,
|
||||
|
||||
strconcat3 (whiteout_wh_path, PATH_MAX, parent->path, "/.wh.", name);
|
||||
|
||||
|
||||
fd = get_upper_layer (lo)->ds->openat (get_upper_layer (lo), whiteout_wh_path, O_CREAT|O_WRONLY|O_NONBLOCK, 0700);
|
||||
if (fd < 0 && errno != EEXIST)
|
||||
return -1;
|
||||
@ -4532,6 +4531,9 @@ ovl_rename_direct (fuse_req_t req, fuse_ino_t parent, const char *name,
|
||||
rename+mknod separately. */
|
||||
ret = direct_renameat2 (srcfd, name, destfd,
|
||||
newname, flags|RENAME_WHITEOUT);
|
||||
/* If the destination is a whiteout, just overwrite it. */
|
||||
if (ret < 0 && errno == EEXIST)
|
||||
ret = direct_renameat2 (srcfd, name, destfd, newname, flags & ~RENAME_NOREPLACE);
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = direct_renameat2 (srcfd, name, destfd,
|
||||
|
@ -206,3 +206,8 @@ sleep 30 < merged/toremove &
|
||||
sleep_pid=$!
|
||||
rm merged/toremove
|
||||
grep 12345 /proc/$sleep_pid/fd/0
|
||||
|
||||
RUN touch merged/a merged/b
|
||||
RUN chmod 6 merged/a
|
||||
RUN mv merged/a merged/x
|
||||
RUN mv merged/b merged/a
|
||||
|
Loading…
x
Reference in New Issue
Block a user