From b7e1dc81c21e65e0a4bb981442b7e8312c320d85 Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Wed, 29 Nov 2023 02:03:02 -0800 Subject: [PATCH] Release Cosmopolitan v3.1.1 --- libc/integral/normalize.inc | 2 +- test/libc/calls/fchmodat_test.c | 41 +++++++++++++++++---------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/libc/integral/normalize.inc b/libc/integral/normalize.inc index 38d192213a3..12c4272ad79 100644 --- a/libc/integral/normalize.inc +++ b/libc/integral/normalize.inc @@ -4,7 +4,7 @@ #define __COSMOPOLITAN_MAJOR__ 3 #define __COSMOPOLITAN_MINOR__ 1 -#define __COSMOPOLITAN_PATCH__ 0 +#define __COSMOPOLITAN_PATCH__ 1 #define __COSMOPOLITAN__ \ (100000000 * __COSMOPOLITAN_MAJOR__ + 1000000 * __COSMOPOLITAN_MINOR__ + \ __COSMOPOLITAN_PATCH__) diff --git a/test/libc/calls/fchmodat_test.c b/test/libc/calls/fchmodat_test.c index 3e8736717e4..2724ecd36c5 100644 --- a/test/libc/calls/fchmodat_test.c +++ b/test/libc/calls/fchmodat_test.c @@ -16,53 +16,54 @@ │ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │ │ PERFORMANCE OF THIS SOFTWARE. │ ╚─────────────────────────────────────────────────────────────────────────────*/ - #include "libc/calls/calls.h" +#include "libc/calls/struct/stat.h" #include "libc/dce.h" #include "libc/errno.h" #include "libc/macros.internal.h" -#include "libc/sysv/consts/s.h" -// #include "libc/mem/gc.internal.h" -#include "libc/calls/struct/stat.h" #include "libc/runtime/runtime.h" #include "libc/sysv/consts/at.h" #include "libc/sysv/consts/o.h" +#include "libc/sysv/consts/s.h" #include "libc/testlib/testlib.h" #include "libc/x/x.h" void SetUpOnce(void) { testlib_enable_tmp_setup_teardown(); - // ASSERT_SYS(0, 0, pledge("stdio rpath wpath cpath", 0)); -} - -static void ExpectMode(const char *filename, uint32_t mode) { - struct stat st; - ASSERT_SYS(0, 0, fstatat(AT_FDCWD, filename, &st, AT_SYMLINK_NOFOLLOW)); - ASSERT_TRUE((st.st_mode & 0777) == mode); + ASSERT_SYS(0, 0, pledge("stdio rpath wpath cpath fattr", 0)); } TEST(fchmodat, testFchmodat) { + if (IsWindows()) return; // not advanced enough yet + struct stat st; + umask(022); ASSERT_SYS(0, 3, open("regfile", O_WRONLY | O_CREAT | O_EXCL | O_TRUNC, 0644)); ASSERT_SYS(0, 0, close(3)); ASSERT_SYS(0, 0, symlink("regfile", "symlink")); - ExpectMode("regfile", 0644); - struct stat st; + ASSERT_SYS(0, 0, fstatat(AT_FDCWD, "regfile", &st, AT_SYMLINK_NOFOLLOW)); + ASSERT_EQ(0644, st.st_mode & 0777); ASSERT_SYS(0, 0, fstatat(AT_FDCWD, "symlink", &st, AT_SYMLINK_NOFOLLOW)); uint32_t sym_mode = st.st_mode & 0777; ASSERT_SYS(0, 0, fchmodat(AT_FDCWD, "regfile", 0640, 0)); - ExpectMode("regfile", 0640); + ASSERT_SYS(0, 0, fstatat(AT_FDCWD, "regfile", &st, AT_SYMLINK_NOFOLLOW)); + ASSERT_EQ(0640, st.st_mode & 0777); ASSERT_SYS(0, 0, fchmodat(AT_FDCWD, "regfile", 0600, AT_SYMLINK_NOFOLLOW)); - ExpectMode("regfile", 0600); + ASSERT_SYS(0, 0, fstatat(AT_FDCWD, "regfile", &st, AT_SYMLINK_NOFOLLOW)); + ASSERT_EQ(0600, st.st_mode & 0777); ASSERT_SYS(0, 0, fchmodat(AT_FDCWD, "symlink", 0640, 0)); - ExpectMode("regfile", 0640); - ExpectMode("symlink", sym_mode); + ASSERT_SYS(0, 0, fstatat(AT_FDCWD, "regfile", &st, AT_SYMLINK_NOFOLLOW)); + ASSERT_EQ(0640, st.st_mode & 0777); + ASSERT_SYS(0, 0, fstatat(AT_FDCWD, "symlink", &st, AT_SYMLINK_NOFOLLOW)); + ASSERT_EQ(sym_mode, st.st_mode & 0777); int rc = fchmodat(AT_FDCWD, "symlink", 0600, AT_SYMLINK_NOFOLLOW); if (rc == -1) { - ASSERT_TRUE(errno == ENOTSUP); + ASSERT_EQ(ENOTSUP, errno); errno = 0; } else { - ExpectMode("symlink", 0600); + ASSERT_SYS(0, 0, fstatat(AT_FDCWD, "symlink", &st, AT_SYMLINK_NOFOLLOW)); + ASSERT_EQ(0600, st.st_mode & 0777); } - ExpectMode("regfile", 0640); + ASSERT_SYS(0, 0, fstatat(AT_FDCWD, "regfile", &st, AT_SYMLINK_NOFOLLOW)); + ASSERT_EQ(0640, st.st_mode & 0777); }