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 #ifdef CONFIG_MEMFD_CREATE
8 extern long memfd_fcntl(struct file *file, unsigned int cmd, unsigned int arg);
9 struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx);
10 /*
11 * Check for any existing seals on mmap, return an error if access is denied due
12 * to sealing, or 0 otherwise.
13 *
14 * We also update VMA flags if appropriate by manipulating the VMA flags pointed
15 * to by vm_flags_ptr.
16 */
17 int memfd_check_seals_mmap(struct file *file, unsigned long *vm_flags_ptr);
18 #else
memfd_fcntl(struct file * f,unsigned int c,unsigned int a)19 static inline long memfd_fcntl(struct file *f, unsigned int c, unsigned int a)
20 {
21 return -EINVAL;
22 }
memfd_alloc_folio(struct file * memfd,pgoff_t idx)23 static inline struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx)
24 {
25 return ERR_PTR(-EINVAL);
26 }
memfd_check_seals_mmap(struct file * file,unsigned long * vm_flags_ptr)27 static inline int memfd_check_seals_mmap(struct file *file,
28 unsigned long *vm_flags_ptr)
29 {
30 return 0;
31 }
32 #endif
33
34 #endif /* __LINUX_MEMFD_H */
35