Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef __LINUX_MEMFD_H
3#define __LINUX_MEMFD_H
4
5#include <linux/file.h>
6
7#define MEMFD_ANON_NAME "[memfd]"
8
9#ifdef CONFIG_MEMFD_CREATE
10extern long memfd_fcntl(struct file *file, unsigned int cmd, unsigned int arg);
11struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx);
12/*
13 * Check for any existing seals on mmap, return an error if access is denied due
14 * to sealing, or 0 otherwise.
15 *
16 * We also update VMA flags if appropriate by manipulating the VMA flags pointed
17 * to by vm_flags_ptr.
18 */
19int memfd_check_seals_mmap(struct file *file, vm_flags_t *vm_flags_ptr);
20struct file *memfd_alloc_file(const char *name, unsigned int flags);
21int memfd_get_seals(struct file *file);
22int memfd_add_seals(struct file *file, unsigned int seals);
23#else
24static inline long memfd_fcntl(struct file *f, unsigned int c, unsigned int a)
25{
26 return -EINVAL;
27}
28static inline struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx)
29{
30 return ERR_PTR(-EINVAL);
31}
32static inline int memfd_check_seals_mmap(struct file *file,
33 vm_flags_t *vm_flags_ptr)
34{
35 return 0;
36}
37
38static inline struct file *memfd_alloc_file(const char *name, unsigned int flags)
39{
40 return ERR_PTR(-EINVAL);
41}
42
43static inline int memfd_get_seals(struct file *file)
44{
45 return -EINVAL;
46}
47
48static inline int memfd_add_seals(struct file *file, unsigned int seals)
49{
50 return -EINVAL;
51}
52#endif
53
54#endif /* __LINUX_MEMFD_H */