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);
21#else
22static inline long memfd_fcntl(struct file *f, unsigned int c, unsigned int a)
23{
24 return -EINVAL;
25}
26static inline struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx)
27{
28 return ERR_PTR(-EINVAL);
29}
30static inline int memfd_check_seals_mmap(struct file *file,
31 vm_flags_t *vm_flags_ptr)
32{
33 return 0;
34}
35
36static inline struct file *memfd_alloc_file(const char *name, unsigned int flags)
37{
38 return ERR_PTR(-EINVAL);
39}
40#endif
41
42#endif /* __LINUX_MEMFD_H */