mirror of
https://github.com/Zygo/bees.git
synced 2025-06-15 17:26:15 +02:00
openat2: supply the missing definitions for building with old headers and new kernel
Apparently Ubuntu 20 has upgraded to kernel 5.15, but still builds things with 5.4 headers. Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
@ -1,5 +1,27 @@
|
||||
#include "crucible/openat2.h"
|
||||
|
||||
#include <sys/syscall.h>
|
||||
|
||||
// Compatibility for building on old libc for new kernel
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0)
|
||||
|
||||
// Every arch that defines this uses 437, except Alpha, where 437 is
|
||||
// mq_getsetattr.
|
||||
|
||||
#ifndef SYS_openat2
|
||||
#ifdef __alpha__
|
||||
#define SYS_openat2 547
|
||||
#else
|
||||
#define SYS_openat2 437
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif // Linux version >= v5.6
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
int
|
||||
@ -7,7 +29,12 @@ __attribute__((weak))
|
||||
openat2(int const dirfd, const char *const pathname, struct open_how *const how, size_t const size)
|
||||
throw()
|
||||
{
|
||||
#ifdef SYS_openat2
|
||||
return syscall(SYS_openat2, dirfd, pathname, how, size);
|
||||
#else
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user