mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-03 15:38:22 +00:00
Release Cosmopolitan v3.1.1
This commit is contained in:
parent
41c06c6325
commit
b7e1dc81c2
2 changed files with 22 additions and 21 deletions
|
@ -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__)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue