[PATCH] Linux: Add memfd_create system call wrapper

Florian Weimer fweimer@redhat.com
Sun Nov 19 13:49:00 GMT 2017


On 11/19/2017 02:47 AM, Rical Jasan wrote:
> On 11/18/2017 09:32 AM, Florian Weimer wrote:
>> diff --git a/manual/llio.texi b/manual/llio.texi
>> index 8c7c58c216..625fe49ac1 100644
>> --- a/manual/llio.texi
>> +++ b/manual/llio.texi
>> @@ -1808,6 +1808,69 @@ the given @var{name} previously created by @code{shm_open}.
>>   On failure @code{errno} is set.
>>   @end deftypefn
>>   
>> +@deftypefn Function int memfd_create (const char *@var{name}, unsigned int flags)
> 
> "@var{flags}"
> 
> Use @deftypefun, and drop "Function" (shortcut).

Both fixed.

>> +@standards{Linux, sys/mman.h}
>> +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{@acsfd{}}}
>> +The @code{memfd_create} function returns a file descriptor which can be
>> +used to create memory mappings using the @code{mmap} function.  It is
>> +similar to the @code{shm_open} function in the sense that these mappings
>> +are not backed by actual files.  However, the descriptor return by
> 
> "returned"

Fixed.

>> +@code{memfd_create} does not correspond to a named object; the
>> +@var{name} argument is used for informative purposes only.  The
> 
> I see in mman-linux.h, "NAME is a name for debugging."  Can we say
> "debugging purposes" here?  As-is, it sounds ignored, and doesn't really
> hint at what type of information one could get from it or how.

Well, that is exactly what I want to convey: The name is unused and just 
shows up in /proc in a few places.  I want to make sure that there is no 
expectation that you get same underlying file if you specify the same name.

>> +descriptor can be passed between processes (for example, over local
>> +domain sockets), and mappings at the same offset refer to the same
>> +memory, or the descriptor can be used to create alias mappings within
>> +the same process.
> 
> The and/or here is odd.  What about: "...the same memory.  The
> descriptor can also be used..."

Good idea.

>> +This flag is incompatible with @code{MFD_ALLOW_SEALING}.
>> +@end vtable
>> +
>> +@code{memfd_create} returns a file descriptor on success, and @math{-1}
> 
> I think @code for return values is more appropriate.

I've been using @math for constants.  I like it for these small decimal 
constants because the typewriter font stands out some much.

New patch attached.  I think I have addressed all concerns raised 
regarding the documentation.  Is there anything left to do for the 
implementation?

Thanks,
Florian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: memfd_create.patch
Type: text/x-patch
Size: 23525 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20171119/842034cb/attachment.bin>


More information about the Libc-alpha mailing list