Skip to content

Commit

Permalink
musl 1.2.5: stub missing syscalls, add time64 versions for 32bit
Browse files Browse the repository at this point in the history
- stub faccessat, faccessat2, fchmodat2, pwritev2, preadv2, statx
- include time64 versions of calls to time functions.

As it looks like IncludeOS is already using 64 bit time on 32 bit,
the *_time64 calls just redirect to the existing calls. On 64 bit systems
there should be no change, as the regular calls are 64 bit.
  • Loading branch information
MagnusS committed Jun 17, 2024
1 parent 43ebe58 commit ffa226e
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/musl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ set(MUSL_OBJECTS
msync.cpp mincore.cpp syscall_n.cpp sigmask.cpp gettid.cpp
socketcall.cpp rt_sigaction.cpp
stat.cpp fstat.cpp fstatat.cpp
statx.cpp
access.cpp
chmod.cpp
chown.cpp
Expand All @@ -19,7 +20,10 @@ set(MUSL_OBJECTS
fchdir.cpp
fchmod.cpp
fchmodat.cpp
fchmodat2.cpp
fchown.cpp
faccessat.cpp
faccessat2.cpp
fsync.cpp
ftruncate.cpp
getdents.cpp
Expand Down
5 changes: 5 additions & 0 deletions src/musl/clock_gettime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ extern "C"
long syscall_SYS_clock_gettime(clockid_t clk_id, struct timespec* tp) {
return strace(sys_clock_gettime, "clock_gettime", clk_id, tp);
}

extern "C"
long syscall_SYS_clock_gettime64(clockid_t clk_id, struct timespec* tp) {
return strace(sys_clock_gettime, "clock_gettime", clk_id, tp);
}
14 changes: 14 additions & 0 deletions src/musl/faccessat.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "common.hpp"
#include <sys/stat.h>
#include <fcntl.h>

static long sys_faccessat(int /*fd*/, const char* /*path*/, mode_t, int /*flag*/)
{
// TODO Same as access(), but path is relative to fd
return -EROFS;
}

extern "C"
long syscall_SYS_faccessat(int fd, const char *path, mode_t mode, int flag) {
return strace(sys_faccessat, "faccessat", fd, path, mode, flag);
}
14 changes: 14 additions & 0 deletions src/musl/faccessat2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "common.hpp"
#include <sys/stat.h>
#include <fcntl.h>

static long sys_faccessat2(int /*fd*/, const char* /*path*/, mode_t, int /*flag*/)
{
// TODO Same as access(), but path is relative to fd
return -EROFS;
}

extern "C"
long syscall_SYS_faccessat2(int fd, const char *path, mode_t mode, int flag) {
return strace(sys_faccessat2, "faccessat2", fd, path, mode, flag);
}
14 changes: 14 additions & 0 deletions src/musl/fchmodat2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "common.hpp"
#include <sys/stat.h>
#include <fcntl.h>

static long sys_fchmodat2(int /*fd*/, const char* /*path*/, mode_t, int /*flag*/)
{
// currently makes no sense, especially since we're read-only
return -EROFS;
}

extern "C"
long syscall_SYS_fchmodat2(int fd, const char *path, mode_t mode, int flag) {
return strace(sys_fchmodat2, "fchmodat2", fd, path, mode, flag);
}
7 changes: 7 additions & 0 deletions src/musl/futex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,10 @@ int syscall_SYS_futex(int *uaddr, int futex_op, int val,
{
return stubtrace(sys_futex, "futex", uaddr, futex_op, val, timeout, val3);
}

extern "C"
int syscall_SYS_futex_time64(int *uaddr, int futex_op, int val,
const struct timespec *timeout, int val3)
{
return stubtrace(sys_futex, "futex_time64", uaddr, futex_op, val, timeout, val3);
}
7 changes: 7 additions & 0 deletions src/musl/nanosleep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,10 @@ long syscall_SYS_clock_nanosleep(clockid_t, int,
{
return strace(sys_nanosleep, "clock_nanosleep", req, rem);
}

extern "C"
long syscall_SYS_clock_nanosleep_time64(clockid_t, int,
const struct timespec *req, struct timespec *rem)
{
return strace(sys_nanosleep, "clock_nanosleep_time64", req, rem);
}
15 changes: 15 additions & 0 deletions src/musl/statx.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "common.hpp"
#include <sys/stat.h>

long sys_statx(int /*dirfd*/, const char* /*pathname*/, int /*flags*/,
unsigned int /*mask*/, struct statx* /*statxbuf*/)
{
return -ENOSYS;
}

extern "C"
long syscall_SYS_statx(int dirfd, const char *pathname, int flags,
unsigned int mask, struct statx *statxbuf) {
return strace(sys_statx, "statx", dirfd, pathname, flags, mask, statxbuf);
}

0 comments on commit ffa226e

Please sign in to comment.