Support dirfd relative iops on Windows

We always favor calling functions like openat(), fstatat(), etc. because
Linux, XNU, FreeBSD, and OpenBSD all elected to support them, while some
systems like Android love them so much, that they stopped supporting the
old interfaces.

This change ensures that when dirfd is actually a dirfd and not AT_FDCWD
we'll do the right thing on Windows NT. We use an API that's been around
since Vista to accomplish that.

This change also adds exponential backoff to chdir() on Windows since it
seems almost as flaky on Windows 7 as the rmdir() function.
This commit is contained in:
Justine Tunney 2021-01-30 01:49:43 -08:00
parent b8d26e2418
commit 417797d218
42 changed files with 361 additions and 241 deletions

View file

@ -200,13 +200,13 @@ bool32 WriteFileGather(int64_t hFileOpenedWithOverlappedAndNoBuffering,
struct NtOverlapped inout_lpOverlapped) paramsnonnull();
#define kNtFileNameNormalized 0x0
#define kNtVolumeNameDos 0x0
#define kNtVolumeNameGuid 0x1
#define kNtVolumeNameNt 0x2
#define kNtVolumeNameNone 0x4
#define kNtFileNameOpened 0x8
#define kNtVolumeNameDos 0x0 /* e.g. \\?\C:\Users\jart */
#define kNtVolumeNameGuid 0x1 /* e.g. \\?\Volume{ea38-etc.}\Users\jart */
#define kNtVolumeNameNt 0x2 /* e.g. \Device\HarddiskVolume4\Users\jart */
#define kNtVolumeNameNone 0x4 /* e.g. \Users\jart */
uint32_t GetFinalPathNameByHandle(int64_t hFile, char16_t *out_path,
uint32_t size, uint32_t flags);
uint32_t arraylen, uint32_t flags);
#if ShouldUseMsabiAttribute()
#include "libc/nt/thunk/files.inc"