Backported memfd_create() system call
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#ifndef __SHMEM_FS_H
|
||||
#define __SHMEM_FS_H
|
||||
|
||||
#include <linux/file.h>
|
||||
#include <linux/swap.h>
|
||||
#include <linux/mempolicy.h>
|
||||
#include <linux/pagemap.h>
|
||||
@@ -11,6 +12,7 @@
|
||||
|
||||
struct shmem_inode_info {
|
||||
spinlock_t lock;
|
||||
unsigned int seals; /* shmem seals */
|
||||
unsigned long flags;
|
||||
unsigned long alloced; /* data pages alloced to file */
|
||||
union {
|
||||
@@ -62,4 +64,19 @@ static inline struct page *shmem_read_mapping_page(
|
||||
mapping_gfp_mask(mapping));
|
||||
}
|
||||
|
||||
#ifdef CONFIG_TMPFS
|
||||
|
||||
extern int shmem_add_seals(struct file *file, unsigned int seals);
|
||||
extern int shmem_get_seals(struct file *file);
|
||||
extern long shmem_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
|
||||
|
||||
#else
|
||||
|
||||
static inline long shmem_fcntl(struct file *f, unsigned int c, unsigned long a)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -782,6 +782,7 @@ asmlinkage long sys_timerfd_settime(int ufd, int flags,
|
||||
asmlinkage long sys_timerfd_gettime(int ufd, struct itimerspec __user *otmr);
|
||||
asmlinkage long sys_eventfd(unsigned int count);
|
||||
asmlinkage long sys_eventfd2(unsigned int count, int flags);
|
||||
asmlinkage long sys_memfd_create(const char __user *uname_ptr, unsigned int flags);
|
||||
asmlinkage long sys_fallocate(int fd, int mode, loff_t offset, loff_t len);
|
||||
asmlinkage long sys_old_readdir(unsigned int, struct old_linux_dirent __user *, unsigned int);
|
||||
asmlinkage long sys_pselect6(int, fd_set __user *, fd_set __user *,
|
||||
|
||||
@@ -704,9 +704,11 @@ __SYSCALL(__NR_renameat2, sys_renameat2)
|
||||
__SYSCALL(__NR_seccomp, sys_seccomp)
|
||||
#define __NR_getrandom 278
|
||||
__SYSCALL(__NR_getrandom, sys_getrandom)
|
||||
#define __NR_memfd_create 279
|
||||
__SYSCALL(__NR_memfd_create, sys_memfd_create)
|
||||
|
||||
#undef __NR_syscalls
|
||||
#define __NR_syscalls 279
|
||||
#define __NR_syscalls 280
|
||||
|
||||
/*
|
||||
* All syscalls below here should go away really,
|
||||
|
||||
@@ -27,6 +27,21 @@
|
||||
#define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7)
|
||||
#define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8)
|
||||
|
||||
/*
|
||||
* Set/Get seals
|
||||
*/
|
||||
#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
|
||||
#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
|
||||
|
||||
/*
|
||||
* Types of seals
|
||||
*/
|
||||
#define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */
|
||||
#define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */
|
||||
#define F_SEAL_GROW 0x0004 /* prevent file from growing */
|
||||
#define F_SEAL_WRITE 0x0008 /* prevent writes */
|
||||
/* (1U << 31) is reserved for signed error codes */
|
||||
|
||||
/*
|
||||
* Types of directory notifications that may be requested.
|
||||
*/
|
||||
|
||||
8
include/uapi/linux/memfd.h
Normal file
8
include/uapi/linux/memfd.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef _UAPI_LINUX_MEMFD_H
|
||||
#define _UAPI_LINUX_MEMFD_H
|
||||
|
||||
/* flags for memfd_create(2) (unsigned int) */
|
||||
#define MFD_CLOEXEC 0x0001U
|
||||
#define MFD_ALLOW_SEALING 0x0002U
|
||||
|
||||
#endif /* _UAPI_LINUX_MEMFD_H */
|
||||
Reference in New Issue
Block a user