mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 22:02:27 +00:00
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:
parent
b8d26e2418
commit
417797d218
42 changed files with 361 additions and 241 deletions
|
@ -21,6 +21,7 @@
|
|||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
#include "libc/x/x.h"
|
||||
|
||||
|
@ -68,3 +69,13 @@ TEST(makedirs, testEmptyString_ENOENT) {
|
|||
EXPECT_EQ(-1, makedirs("", 0755));
|
||||
EXPECT_EQ(ENOENT, errno);
|
||||
}
|
||||
|
||||
TEST(mkdirat, testRelativePath_opensRelativeToDirFd) {
|
||||
int dirfd;
|
||||
ASSERT_NE(-1, mkdir("foo", 0755));
|
||||
ASSERT_NE(-1, (dirfd = open("foo", O_RDONLY | O_DIRECTORY)));
|
||||
EXPECT_NE(-1, mkdirat(dirfd, "bar", 0755));
|
||||
EXPECT_TRUE(isdirectory("foo/bar"));
|
||||
EXPECT_EQ(-1, makedirs("", 0755));
|
||||
EXPECT_NE(-1, close(dirfd));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue