This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Linux: Add memfd_create system call wrapper


* Adhemerval Zanella:

>> 2017-11-03  Florian Weimer  <fweimer@redhat.com>
>> 
>> 	Linux: Add memfd_create system call wrapper
>> 	* sysdeps/unix/sysv/linux/Makefile [misc] (sysdep_headers): Add
>> 	sys/memfd.h.
>> 	(tests): Add tst-memfd_create.
>> 	* sysdeps/unix/sysv/linux/Versions (GLIBC_2.27): Add memfd_create.
>> 	* sysdeps/unix/sysv/linux/syscalls.list (memfd_create): Add.
>> 	* sysdeps/unix/sysv/linux/sys/memfd.h: New file.
>> 	* sysdeps/unix/sysv/linux/**.abilist: Update.
>> 	* manual/llio.texi (Memory-mapped I/O): Document memfd_create.
>> 	* support/Makefile (libsupport-routines): Add xreadlink, xstrndup,
>> 	xunlink.
>> 	(tests): Add tst-xreadlink.
>> 	* support/support.h (xstrndup): Declare.
>> 	* support/xunistd.h (xunlink, xreadlink): Declare.
>> 	* support/temp_file.h (support_create_temp_directory): Declare.
>> 	* support/temp_file.c (support_create_temp_directory): New function.
>> 	* support/support_chroot.c (support_chroot_create): Use it.
>> 	* support/xreadlink.c: New file.
>> 	* support/xstrndup.c: Likewise.
>> 	* support/xunlink.c: Likewise.
>> 	* support/tst-xreadlink.c: Likewise.
>> 
>
> Missing sysdeps/unix/sysv/linux/tst-memfd_create.c entry.

Fixed locally.

>> diff --git a/support/tst-xreadlink.c b/support/tst-xreadlink.c
>> new file mode 100644
>> index 0000000000..cb2c12a888
>> --- /dev/null
>> +++ b/support/tst-xreadlink.c

> I think it is better to split this test and the xreadlink 
> addition on another patch.

Okay, I will commit this separately soon.

>> +#ifndef _SYS_MEMFD_H
>> +#define _SYS_MEMFD_H
>> +
>> +#include <linux/memfd.h>
>
> How do we handle the case of installed kernels version being lower 
> than 3.16 (the one that provides this header)?

Then applications will not be able to use this header.

If that's not acceptable, we should probably not add <sys/memfd.h> at
all, but replicate the UAPI constants in <sys/mman.h>.

I see that this also affects the test.  So we probably should go the
<sys/mman.h> route.

>> +static int
>> +do_test (void)
>> +{
>> +  /* Initialized by the first call to memfd_create to 0 (memfd_create
>> +     unsupported) or 1 (memfd_create is implemented in the kernel).
>> +     Subsequent iterations check that the success/failure state is
>> +     consistent.  */
>> +  int supported = -1;
>
> I am not following why adding this extra logic and the one which
> checks SYS_memfd_create.  If __NR_memfd_create is not defined by
> kernel headers a stub which returns ENOSYS will be created.  Why
> not just bail out with EXIT_UNSUPPORTED if errno is ENOSYS on
> first call? Is there any expectation that memfd_create won't
> return ENOSYS with different flags?

I wanted to test that the results are consistent independent of the
flags.  Doesn't this make sense?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]