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 unsigned int *memfd_file_seals_ptr(struct file *file); 11 #else 12 static inline long memfd_fcntl(struct file *f, unsigned int c, unsigned int a) 13 { 14 return -EINVAL; 15 } 16 static inline struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx) 17 { 18 return ERR_PTR(-EINVAL); 19 } 20 21 static inline unsigned int *memfd_file_seals_ptr(struct file *file) 22 { 23 return NULL; 24 } 25 #endif 26 27 /* Retrieve memfd seals associated with the file, if any. */ 28 static inline unsigned int memfd_file_seals(struct file *file) 29 { 30 unsigned int *sealsp = memfd_file_seals_ptr(file); 31 32 return sealsp ? *sealsp : 0; 33 } 34 35 #endif /* __LINUX_MEMFD_H */ 36