diff options
Diffstat (limited to 'libc/sysdeps/linux/common')
-rw-r--r-- | libc/sysdeps/linux/common/Makefile.in | 3 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/bits/fcntl-linux.h | 34 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/bits/mman-shared.h | 2 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/bits/stat.h | 4 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/fstat64.c | 3 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/fstatat64.c | 3 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/futimesat.c | 1 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/lseek.c | 2 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/memfd_create.c | 13 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/not-cancel.h | 2 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/process_vm_readv.c | 32 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/process_vm_writev.c | 32 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/sys/epoll.h | 14 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/sys/random.h | 4 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/utime.c | 4 | ||||
-rw-r--r-- | libc/sysdeps/linux/common/utimensat.c | 3 |
16 files changed, 146 insertions, 10 deletions
diff --git a/libc/sysdeps/linux/common/Makefile.in b/libc/sysdeps/linux/common/Makefile.in index 848bc1e4a..e0b280c33 100644 --- a/libc/sysdeps/linux/common/Makefile.in +++ b/libc/sysdeps/linux/common/Makefile.in @@ -30,6 +30,7 @@ CSRC-$(UCLIBC_LINUX_SPECIFIC) += \ inotify.c \ ioperm.c \ iopl.c \ + memfd_create.c \ modify_ldt.c \ module.c \ name_to_handle_at.c \ @@ -39,6 +40,8 @@ CSRC-$(UCLIBC_LINUX_SPECIFIC) += \ ppoll.c \ prctl.c \ prlimit.c \ + process_vm_readv.c \ + process_vm_writev.c \ readahead.c \ reboot.c \ remap_file_pages.c \ diff --git a/libc/sysdeps/linux/common/bits/fcntl-linux.h b/libc/sysdeps/linux/common/bits/fcntl-linux.h new file mode 100644 index 000000000..d0236fd8b --- /dev/null +++ b/libc/sysdeps/linux/common/bits/fcntl-linux.h @@ -0,0 +1,34 @@ +/* O_*, F_*, FD_* bit values for Linux. + Copyright (C) 2001-2024 Free Software Foundation, Inc. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#ifndef _FCNTL_H +# error "Never use <bits/fcntl-linux.h> directly; include <fcntl.h> instead." +#endif + +#ifdef __USE_GNU +/* Types of seals. */ +# define F_SEAL_SEAL 0x0001 /* Prevent further seals from being set. */ +# define F_SEAL_SHRINK 0x0002 /* Prevent file from shrinking. */ +# define F_SEAL_GROW 0x0004 /* Prevent file from growing. */ +# define F_SEAL_WRITE 0x0008 /* Prevent writes. */ +# define F_SEAL_FUTURE_WRITE 0x0010 /* Prevent future writes while + mapped. */ +# define F_SEAL_EXEC 0x0020 /* Prevent chmod modifying exec bits. */ + +# define F_ADD_SEALS 1033 /* Add seals to file. */ +# define F_GET_SEALS 1034 /* Get seals for file. */ +#endif diff --git a/libc/sysdeps/linux/common/bits/mman-shared.h b/libc/sysdeps/linux/common/bits/mman-shared.h index 98c9e1d3c..c40ae2d1e 100644 --- a/libc/sysdeps/linux/common/bits/mman-shared.h +++ b/libc/sysdeps/linux/common/bits/mman-shared.h @@ -40,11 +40,9 @@ __BEGIN_DECLS -#if 0 /* Create a new memory file descriptor. NAME is a name for debugging. FLAGS is a combination of the MFD_* constants. */ int memfd_create (const char *__name, unsigned int __flags) __THROW; -#endif /* Lock pages from ADDR (inclusive) to ADDR + LENGTH (exclusive) into memory. FLAGS is a combination of the MLOCK_* flags above. */ diff --git a/libc/sysdeps/linux/common/bits/stat.h b/libc/sysdeps/linux/common/bits/stat.h index 07c09f50a..fc76cc3e7 100644 --- a/libc/sysdeps/linux/common/bits/stat.h +++ b/libc/sysdeps/linux/common/bits/stat.h @@ -61,7 +61,7 @@ struct stat #else __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */ #endif -#ifdef __USE_MISC +#if defined(__USE_MISC) || defined(__USE_XOPEN2K8) /* Nanosecond resolution timestamps are stored in a format equivalent to 'struct timespec'. This is the type used whenever possible but the Unix namespace rules do not allow the @@ -107,7 +107,7 @@ struct stat64 __blksize_t st_blksize; /* Optimal block size for I/O. */ __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */ -#ifdef __USE_MISC +#if defined(__USE_MISC) || defined(__USE_XOPEN2K8) /* Nanosecond resolution timestamps are stored in a format equivalent to 'struct timespec'. This is the type used whenever possible but the Unix namespace rules do not allow the diff --git a/libc/sysdeps/linux/common/fstat64.c b/libc/sysdeps/linux/common/fstat64.c index 359c22af6..121b21fc8 100644 --- a/libc/sysdeps/linux/common/fstat64.c +++ b/libc/sysdeps/linux/common/fstat64.c @@ -8,8 +8,9 @@ #include <_lfs_64.h> #include <sys/syscall.h> +#include <linux/version.h> -#if defined(__NR_fstat64) && !defined(__UCLIBC_USE_TIME64__) +#if defined(__NR_fstat64) && (!defined(__UCLIBC_USE_TIME64__) || LINUX_VERSION_CODE <= KERNEL_VERSION(5,1,0)) # include <unistd.h> # include <sys/stat.h> # include "xstatconv.h" diff --git a/libc/sysdeps/linux/common/fstatat64.c b/libc/sysdeps/linux/common/fstatat64.c index 16dbf9215..739e84081 100644 --- a/libc/sysdeps/linux/common/fstatat64.c +++ b/libc/sysdeps/linux/common/fstatat64.c @@ -9,6 +9,7 @@ #include <_lfs_64.h> #include <bits/wordsize.h> #include <sys/syscall.h> +#include <linux/version.h> #if defined __mips__ # include <sgidefs.h> @@ -23,7 +24,7 @@ # define __NR_fstatat64 __NR_newfstatat #endif -#if defined(__NR_fstatat64) && !defined(__UCLIBC_USE_TIME64__) +#if defined(__NR_fstatat64) && (!defined(__UCLIBC_USE_TIME64__) || LINUX_VERSION_CODE <= KERNEL_VERSION(5,1,0)) # include <sys/stat.h> # include "xstatconv.h" int fstatat64(int fd, const char *file, struct stat64 *buf, int flag) diff --git a/libc/sysdeps/linux/common/futimesat.c b/libc/sysdeps/linux/common/futimesat.c index fd19fea7c..bf36550dd 100644 --- a/libc/sysdeps/linux/common/futimesat.c +++ b/libc/sysdeps/linux/common/futimesat.c @@ -7,6 +7,7 @@ */ #include <sys/syscall.h> +#include <sys/stat.h> #include <sys/time.h> #ifdef __NR_futimesat diff --git a/libc/sysdeps/linux/common/lseek.c b/libc/sysdeps/linux/common/lseek.c index 80d69318a..0fc99efae 100644 --- a/libc/sysdeps/linux/common/lseek.c +++ b/libc/sysdeps/linux/common/lseek.c @@ -40,6 +40,8 @@ off_t __NC(lseek)(int fd, off_t offset attribute_unused, int whence) case SEEK_SET: case SEEK_CUR: case SEEK_END: + case SEEK_DATA: + case SEEK_HOLE: break; default: __set_errno(EINVAL); diff --git a/libc/sysdeps/linux/common/memfd_create.c b/libc/sysdeps/linux/common/memfd_create.c new file mode 100644 index 000000000..7165f3278 --- /dev/null +++ b/libc/sysdeps/linux/common/memfd_create.c @@ -0,0 +1,13 @@ +/* + * memfd_create() for uClibc-ng + * + * Copyright (C) 2024 Waldemar Brodkorb <wbx@uclibc-ng.org> + * + * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. + */ + +#include <sys/syscall.h> +#include <sys/mman.h> +#if defined(__NR_memfd_create) +_syscall2(int, memfd_create, const char *, name, unsigned int, flags) +#endif diff --git a/libc/sysdeps/linux/common/not-cancel.h b/libc/sysdeps/linux/common/not-cancel.h index e4fb1d7fe..426edcc46 100644 --- a/libc/sysdeps/linux/common/not-cancel.h +++ b/libc/sysdeps/linux/common/not-cancel.h @@ -19,6 +19,7 @@ #include <sys/types.h> #include <sysdep.h> +#include <time.h> #ifdef NOT_IN_libc @@ -114,6 +115,7 @@ extern __typeof(pause) __pause_nocancel; # define nanosleep_not_cancel(requested_time, remaining) \ INLINE_SYSCALL (nanosleep, 2, requested_time, remaining) #else +extern int __nanosleep_nocancel (const struct timespec *requested_time, struct timespec *remaining); # define nanosleep_not_cancel(requested_time, remaining) \ __nanosleep_nocancel (requested_time, remaining) #endif diff --git a/libc/sysdeps/linux/common/process_vm_readv.c b/libc/sysdeps/linux/common/process_vm_readv.c new file mode 100644 index 000000000..b69c1c97a --- /dev/null +++ b/libc/sysdeps/linux/common/process_vm_readv.c @@ -0,0 +1,32 @@ +/* process_vm_readv - Linux specific syscall. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <sys/uio.h> +#include <sys/syscall.h> +#include <unistd.h> + +#ifdef __NR_process_vm_readv +ssize_t +process_vm_readv (pid_t pid, const struct iovec *local_iov, + unsigned long int liovcnt, + const struct iovec *remote_iov, + unsigned long int riovcnt, unsigned long int flags) +{ + return INLINE_SYSCALL (process_vm_readv, 6, pid, local_iov, + liovcnt, remote_iov, riovcnt, flags); +} +#endif diff --git a/libc/sysdeps/linux/common/process_vm_writev.c b/libc/sysdeps/linux/common/process_vm_writev.c new file mode 100644 index 000000000..e22817a8d --- /dev/null +++ b/libc/sysdeps/linux/common/process_vm_writev.c @@ -0,0 +1,32 @@ +/* process_vm_writev - Linux specific syscall. + Copyright (C) 2020-2024 Free Software Foundation, Inc. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <https://www.gnu.org/licenses/>. */ + +#include <sys/uio.h> +#include <sys/syscall.h> +#include <unistd.h> + +#ifdef __NR_process_vm_writev +ssize_t +process_vm_writev (pid_t pid, const struct iovec *local_iov, + unsigned long int liovcnt, + const struct iovec *remote_iov, + unsigned long int riovcnt, unsigned long int flags) +{ + return INLINE_SYSCALL (process_vm_writev, 6, pid, local_iov, + liovcnt, remote_iov, riovcnt, flags); +} +#endif diff --git a/libc/sysdeps/linux/common/sys/epoll.h b/libc/sysdeps/linux/common/sys/epoll.h index 5551bed0d..5138d77a9 100644 --- a/libc/sysdeps/linux/common/sys/epoll.h +++ b/libc/sysdeps/linux/common/sys/epoll.h @@ -19,6 +19,7 @@ #define _SYS_EPOLL_H 1 #include <stdint.h> +#include <sys/ioctl.h> #include <sys/types.h> /* Get __sigset_t. */ @@ -87,6 +88,19 @@ struct epoll_event epoll_data_t data; /* User data variable */ } __EPOLL_PACKED; +struct epoll_params +{ + uint32_t busy_poll_usecs; + uint16_t busy_poll_budget; + uint8_t prefer_busy_poll; + + /* pad the struct to a multiple of 64bits */ + uint8_t __pad; +}; + +#define EPOLL_IOC_TYPE 0x8A +#define EPIOCSPARAMS _IOW(EPOLL_IOC_TYPE, 0x01, struct epoll_params) +#define EPIOCGPARAMS _IOR(EPOLL_IOC_TYPE, 0x02, struct epoll_params) __BEGIN_DECLS diff --git a/libc/sysdeps/linux/common/sys/random.h b/libc/sysdeps/linux/common/sys/random.h index 3d12744ad..3d24e439b 100644 --- a/libc/sysdeps/linux/common/sys/random.h +++ b/libc/sysdeps/linux/common/sys/random.h @@ -9,7 +9,7 @@ __BEGIN_DECLS -#if defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU +#if defined __UCLIBC_LINUX_SPECIFIC__ # if 0 /*def __ASSUME_GETRANDOM_SYSCALL */ # include <linux/random.h> # else @@ -20,9 +20,11 @@ __BEGIN_DECLS * * GRND_NONBLOCK Don't block and return EAGAIN instead * GRND_RANDOM Use the /dev/random pool instead of /dev/urandom + * GRND_INSECURE Write random data that may not be cryptographically secure. */ # define GRND_NONBLOCK 0x0001 # define GRND_RANDOM 0x0002 +# define GRND_INSECURE 0x0004 # endif /* FIXME: aren't there a couple of __restrict and const missing ? */ extern int getrandom(void *__buf, size_t count, unsigned int flags) diff --git a/libc/sysdeps/linux/common/utime.c b/libc/sysdeps/linux/common/utime.c index e4ac0b269..c716388e8 100644 --- a/libc/sysdeps/linux/common/utime.c +++ b/libc/sysdeps/linux/common/utime.c @@ -9,7 +9,7 @@ #include <sys/syscall.h> #include <utime.h> -#if defined __NR_utimensat && !defined __NR_utime +#if (defined(__NR_utimensat) || defined(__NR_utimensat_time64)) && !defined __NR_utime # include <fcntl.h> # include <stddef.h> @@ -51,7 +51,7 @@ int utime(const char *file, const struct utimbuf *times) } #endif -#if (defined __NR_utimensat && !defined __NR_utime) || \ +#if ((defined(__NR_utimensat) || defined(__NR_utimensat_time64)) && !defined __NR_utime) || \ defined __NR_utime || defined __NR_utimes libc_hidden_def(utime) #endif diff --git a/libc/sysdeps/linux/common/utimensat.c b/libc/sysdeps/linux/common/utimensat.c index fa6f90e55..5816c7890 100644 --- a/libc/sysdeps/linux/common/utimensat.c +++ b/libc/sysdeps/linux/common/utimensat.c @@ -8,6 +8,7 @@ #include <sys/syscall.h> #include <sys/stat.h> +#include <stdint.h> #if defined(__UCLIBC_USE_TIME64__) #include "internal/time64_helpers.h" @@ -28,7 +29,7 @@ int utimensat(int fd, const char *path, const struct timespec times[2], int flag } }; - return INLINE_SYSCALL(utimensat_time64, 4, fd, path, times ? &__times64 : 0, flags); + return INLINE_SYSCALL(utimensat_time64, 4, fd, path, times ? (uintptr_t) &__times64 : 0, flags); } #else _syscall4(int, utimensat, int, fd, const char *, path, const struct timespec *, times, int, flags) |