summaryrefslogtreecommitdiff
path: root/builtin/range-diff.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-10-27 16:39:40 +0100
committerTaylor Blau <me@ttaylorr.com>2024-10-27 19:51:35 -0400
commita270cb1540a7f82d0c8c1de9e4103cb09e8642a8 (patch)
tree4f717fca43c1e0141333b7306bcdf15cfcd75114 /builtin/range-diff.c
parentb0b65ec59384a7b6fe473d052a05ce72c55cc71b (diff)
compat/mingw: allow deletion of most opened files
On Windows, we emulate open(3p) via `mingw_open()`. This function implements handling of some platform-specific quirks that are required to make it behave as closely as possible like open(3p) would, but for most cases we just call the Windows-specific `_wopen()` function. This function has a major downside though: it does not allow us to specify the sharing mode. While there is `_wsopen()` that allows us to pass sharing flags, those sharing flags are not the same `FILE_SHARE_*` flags as `CreateFileW()` accepts. Instead, `_wsopen()` only allows concurrent read- and write-access, but does not allow for concurrent deletions. Unfortunately though, we have to allow concurrent deletions if we want to have POSIX-style atomic renames on top of an existing file that has open file handles. Implement a new function that emulates open(3p) for existing files via `CreateFileW()` such that we can set the required sharing flags. While we have the same issue when calling open(3p) with `O_CREAT`, implementing that mode would be more complex due to the required permission handling. Furthermore, atomic updates via renames typically write to exclusive lockfile and then perform the rename, and thus we don't have to handle the case where the locked path has been created with `O_CREATE`. So while it would be nice to have proper POSIX semantics in all paths, we instead aim for a minimum viable fix here. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Taylor Blau <me@ttaylorr.com>
Diffstat (limited to 'builtin/range-diff.c')
0 files changed, 0 insertions, 0 deletions