From patchwork Fri Oct 17 09:21:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 3259 Received: (qmail 28108 invoked by alias); 17 Oct 2014 09:21:51 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 28098 invoked by uid 89); 17 Oct 2014 09:21:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_WEB, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f169.google.com X-Received: by 10.194.90.210 with SMTP id by18mr9185363wjb.34.1413537706178; Fri, 17 Oct 2014 02:21:46 -0700 (PDT) From: David Herrmann To: libc-alpha@sourceware.org Cc: David Herrmann Subject: [PATCH RFC] Add support for linux memfd_create syscall Date: Fri, 17 Oct 2014 11:21:34 +0200 Message-Id: <1413537694-30556-1-git-send-email-dh.herrmann@gmail.com> The memfd_create() syscall was released with linux-3.17. It's a linux-only syscall and returns a shmem file-descriptor backed by anonymous memory in a kernel-internal shmem mount. --- ChangeLog | 7 +++++++ NEWS | 2 ++ sysdeps/unix/sysv/linux/Makefile | 2 +- sysdeps/unix/sysv/linux/Versions | 3 +++ sysdeps/unix/sysv/linux/sys/memfd.h | 32 ++++++++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/syscalls.list | 2 ++ 6 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 sysdeps/unix/sysv/linux/sys/memfd.h diff --git a/ChangeLog b/ChangeLog index 6c6d9d8..e11c875 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2014-10-17 David Herrmann + + * sysdeps/unix/sysv/linux/Makefile: add sys/memfd.h + * sysdeps/unix/sysv/linux/Versions: export memfd_create + * sysdeps/unix/sysv/linux/syscalls.list: add entry for memfd_create + * sysdeps/unix/sysv/linux/sys/memfd.h: new file + 2014-10-16 Roland McGrath * sysdeps/arm/soft-fp/sfp-machine.h: Filed moved ... diff --git a/NEWS b/NEWS index 987f306..b6af068 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,8 @@ using `glibc' in the "product" field. Version 2.21 +* New Linux interfaces: memfd_create + * The following bugs are resolved with this release: 6652, 12926, 14171, 17266, 17363, 17370, 17371, 17411, 17460. diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 9ad6d22..850ef9b 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -43,7 +43,7 @@ sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h \ sys/timerfd.h sys/fanotify.h bits/eventfd.h bits/inotify.h \ bits/signalfd.h bits/timerfd.h bits/epoll.h \ bits/socket_type.h bits/syscall.h bits/sysctl.h \ - bits/mman-linux.h + bits/mman-linux.h sys/memfd.h tests += tst-clone tst-fanotify diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions index 16bb281..15c04b5 100644 --- a/sysdeps/unix/sysv/linux/Versions +++ b/sysdeps/unix/sysv/linux/Versions @@ -166,6 +166,9 @@ libc { GLIBC_2.15 { process_vm_readv; process_vm_writev; } + GLIBC_2.21 { + memfd_create; + } GLIBC_PRIVATE { # functions used in other libraries __syscall_rt_sigqueueinfo; diff --git a/sysdeps/unix/sysv/linux/sys/memfd.h b/sysdeps/unix/sysv/linux/sys/memfd.h new file mode 100644 index 0000000..3f10df4 --- /dev/null +++ b/sysdeps/unix/sysv/linux/sys/memfd.h @@ -0,0 +1,32 @@ +/* Copyright (C) 2010-2014 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#ifndef _SYS_MEMFD_H +#define _SYS_MEMFD_H 1 + +#include +#include + +__BEGIN_DECLS + +/* Create and initialize an anonymous memory object. */ +extern int memfd_create (const char *__name, unsigned int __flags) + __THROW; + +__END_DECLS + +#endif /* sys/memfd.h */ diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list index a0b8de8..f881f37 100644 --- a/sysdeps/unix/sysv/linux/syscalls.list +++ b/sysdeps/unix/sysv/linux/syscalls.list @@ -123,3 +123,5 @@ setns EXTRA setns i:ii setns process_vm_readv EXTRA process_vm_readv i:ipipii process_vm_readv process_vm_writev EXTRA process_vm_writev i:ipipii process_vm_writev + +memfd_create EXTRA memfd_create i:si memfd_create