[PATCH] Don't unlink + rename on CIFS mounts during copy operations
authorKevin Ottens <kevin.ottens@enioka.com>
Thu, 24 Aug 2023 16:42:19 +0000 (18:42 +0200)
committerAurélien COUDERC <coucouf@debian.org>
Thu, 23 May 2024 21:13:17 +0000 (23:13 +0200)
commit2ded74de12d4f0748c4eb0a6988197366da98f12
tree63293a893773a2189d3259e75ed115bf08acf4b3
parentc902b82797634323ccaffbaa5906cb71f2b45308
[PATCH] Don't unlink + rename on CIFS mounts during copy operations

It turns out that the behavior of unlink() on CIFS mounts can be a bit
"interesting". If the file one tries to unlink is opened then the
operation is claimed to have succeeded but the filename is still visible
in the file hierarchy until the last handle is closed.

Since we rightfully attempt to copy under a temporary name + unlink +
rename during copy() operations this would end badly (as the unlink()
would "succeed" but the rename() would fail!). For instance Okular would
constantly hit this case but it's likely not the only one to be affected.

So instead we detect if the destination is a CIFS mount, in such cases
we now overwrite the file directly since this actually succeed.

BUG: 454693
(cherry picked from commit d248949eea3e3dcbb9283f30eebcb9ae86412cd1)

Gbp-Pq: Name upstream_3e6800b3_fix_cifs_copy.patch
src/ioslaves/file/file_unix.cpp