2017-11-01 21:08:43 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
|
shm: add memfd_create() syscall
memfd_create() is similar to mmap(MAP_ANON), but returns a file-descriptor
that you can pass to mmap(). It can support sealing and avoids any
connection to user-visible mount-points. Thus, it's not subject to quotas
on mounted file-systems, but can be used like malloc()'ed memory, but with
a file-descriptor to it.
memfd_create() returns the raw shmem file, so calls like ftruncate() can
be used to modify the underlying inode. Also calls like fstat() will
return proper information and mark the file as regular file. If you want
sealing, you can specify MFD_ALLOW_SEALING. Otherwise, sealing is not
supported (like on all other regular files).
Compared to O_TMPFILE, it does not require a tmpfs mount-point and is not
subject to a filesystem size limit. It is still properly accounted to
memcg limits, though, and to the same overcommit or no-overcommit
accounting as all user memory.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Acked-by: Hugh Dickins <hughd@google.com>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Cc: Ryan Lortie <desrt@desrt.ca>
Cc: Lennart Poettering <lennart@poettering.net>
Cc: Daniel Mack <zonque@gmail.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-08-09 04:25:29 +07:00
|
|
|
#ifndef _UAPI_LINUX_MEMFD_H
|
|
|
|
#define _UAPI_LINUX_MEMFD_H
|
|
|
|
|
2017-09-07 06:24:16 +07:00
|
|
|
#include <asm-generic/hugetlb_encode.h>
|
|
|
|
|
shm: add memfd_create() syscall
memfd_create() is similar to mmap(MAP_ANON), but returns a file-descriptor
that you can pass to mmap(). It can support sealing and avoids any
connection to user-visible mount-points. Thus, it's not subject to quotas
on mounted file-systems, but can be used like malloc()'ed memory, but with
a file-descriptor to it.
memfd_create() returns the raw shmem file, so calls like ftruncate() can
be used to modify the underlying inode. Also calls like fstat() will
return proper information and mark the file as regular file. If you want
sealing, you can specify MFD_ALLOW_SEALING. Otherwise, sealing is not
supported (like on all other regular files).
Compared to O_TMPFILE, it does not require a tmpfs mount-point and is not
subject to a filesystem size limit. It is still properly accounted to
memcg limits, though, and to the same overcommit or no-overcommit
accounting as all user memory.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Acked-by: Hugh Dickins <hughd@google.com>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Cc: Ryan Lortie <desrt@desrt.ca>
Cc: Lennart Poettering <lennart@poettering.net>
Cc: Daniel Mack <zonque@gmail.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-08-09 04:25:29 +07:00
|
|
|
/* flags for memfd_create(2) (unsigned int) */
|
|
|
|
#define MFD_CLOEXEC 0x0001U
|
|
|
|
#define MFD_ALLOW_SEALING 0x0002U
|
2017-09-07 06:24:16 +07:00
|
|
|
#define MFD_HUGETLB 0x0004U
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Huge page size encoding when MFD_HUGETLB is specified, and a huge page
|
|
|
|
* size other than the default is desired. See hugetlb_encode.h.
|
|
|
|
* All known huge page size encodings are provided here. It is the
|
|
|
|
* responsibility of the application to know which sizes are supported on
|
|
|
|
* the running system. See mmap(2) man page for details.
|
|
|
|
*/
|
|
|
|
#define MFD_HUGE_SHIFT HUGETLB_FLAG_ENCODE_SHIFT
|
|
|
|
#define MFD_HUGE_MASK HUGETLB_FLAG_ENCODE_MASK
|
|
|
|
|
|
|
|
#define MFD_HUGE_64KB HUGETLB_FLAG_ENCODE_64KB
|
|
|
|
#define MFD_HUGE_512KB HUGETLB_FLAG_ENCODE_512KB
|
|
|
|
#define MFD_HUGE_1MB HUGETLB_FLAG_ENCODE_1MB
|
|
|
|
#define MFD_HUGE_2MB HUGETLB_FLAG_ENCODE_2MB
|
|
|
|
#define MFD_HUGE_8MB HUGETLB_FLAG_ENCODE_8MB
|
|
|
|
#define MFD_HUGE_16MB HUGETLB_FLAG_ENCODE_16MB
|
2018-10-06 05:51:54 +07:00
|
|
|
#define MFD_HUGE_32MB HUGETLB_FLAG_ENCODE_32MB
|
2017-09-07 06:24:16 +07:00
|
|
|
#define MFD_HUGE_256MB HUGETLB_FLAG_ENCODE_256MB
|
2018-10-06 05:51:54 +07:00
|
|
|
#define MFD_HUGE_512MB HUGETLB_FLAG_ENCODE_512MB
|
2017-09-07 06:24:16 +07:00
|
|
|
#define MFD_HUGE_1GB HUGETLB_FLAG_ENCODE_1GB
|
|
|
|
#define MFD_HUGE_2GB HUGETLB_FLAG_ENCODE_2GB
|
|
|
|
#define MFD_HUGE_16GB HUGETLB_FLAG_ENCODE_16GB
|
shm: add memfd_create() syscall
memfd_create() is similar to mmap(MAP_ANON), but returns a file-descriptor
that you can pass to mmap(). It can support sealing and avoids any
connection to user-visible mount-points. Thus, it's not subject to quotas
on mounted file-systems, but can be used like malloc()'ed memory, but with
a file-descriptor to it.
memfd_create() returns the raw shmem file, so calls like ftruncate() can
be used to modify the underlying inode. Also calls like fstat() will
return proper information and mark the file as regular file. If you want
sealing, you can specify MFD_ALLOW_SEALING. Otherwise, sealing is not
supported (like on all other regular files).
Compared to O_TMPFILE, it does not require a tmpfs mount-point and is not
subject to a filesystem size limit. It is still properly accounted to
memcg limits, though, and to the same overcommit or no-overcommit
accounting as all user memory.
Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Acked-by: Hugh Dickins <hughd@google.com>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Cc: Ryan Lortie <desrt@desrt.ca>
Cc: Lennart Poettering <lennart@poettering.net>
Cc: Daniel Mack <zonque@gmail.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-08-09 04:25:29 +07:00
|
|
|
|
|
|
|
#endif /* _UAPI_LINUX_MEMFD_H */
|