Tested impl: works! Thoudh... XXX: man says `FD_CLOEXEC` should be passable to `memfd_secret()`, but it fails with `EINVAL` if passed `FD_CLOEXEC`...? Find out why?

Fortune for memfd_secret-shim's current commit: Blessing − 吉
master
Avril 7 months ago
parent fde7eb2ee5
commit 9ea30b0cb2
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -12,7 +12,7 @@
#define READ_ONCE(slot) ((__typeof__(slot))(*(const volatile __typeof__(slot)*)&(slot)))
#define WRITE_ONCE(slot, value) (*((volatile __typeof__(slot)*)&(slot)) = (value))
__attribute__((gnu_inline))
__attribute__((gnu_inline/*, always_inline*/))
static inline
int _memfd_secret_raw(unsigned int flags)
{
@ -29,7 +29,7 @@ static inline
int _has_memfd_secret_raw()
{
// Attempt syscall
int fd = _memfd_secret_raw(FD_CLOEXEC);
int fd = _memfd_secret(0); //XXX: NOTE: man page says `FD_CLOEXEC` is a valid flag, but using it returns `EINVAL`?
// If failure to create new fd was caused by `ENOSYS`, it is not available.
if(fd < 0 && errno == ENOSYS)

Loading…
Cancel
Save