Lines Matching defs:file
2 * memfd_create system call and file sealing support
7 * This file is released under the GPL.
13 #include <linux/file.h>
136 static unsigned int *memfd_file_seals_ptr(struct file *file)
138 if (shmem_file(file))
139 return &SHMEM_I(file_inode(file))->seals;
142 if (is_file_hugepages(file))
143 return &HUGETLBFS_I(file_inode(file))->seals;
155 static int memfd_add_seals(struct file *file, unsigned int seals)
157 struct inode *inode = file_inode(file);
163 * Sealing allows multiple parties to share a tmpfs or hugetlbfs file
164 * but restrict access to a specific subset of file operations. Seals
172 * may prevent some kinds of access to the file. Currently, the
174 * SEAL_SEAL: Prevent further seals from being set on this file
175 * SEAL_SHRINK: Prevent the file from shrinking
176 * SEAL_GROW: Prevent the file from growing
177 * SEAL_WRITE: Prevent write access to the file
180 * must prevent seals from being removed. Therefore, sealing a file
181 * only adds a given set of seals to the file, it never touches
189 * no plan to support it on other file types.
192 if (!(file->f_mode & FMODE_WRITE))
199 file_seals = memfd_file_seals_ptr(file);
211 error = mapping_deny_writable(file->f_mapping);
215 error = memfd_wait_for_pins(file->f_mapping);
217 mapping_allow_writable(file->f_mapping);
230 static int memfd_get_seals(struct file *file)
232 unsigned int *seals = memfd_file_seals_ptr(file);
237 long memfd_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
247 error = memfd_add_seals(file, arg);
250 error = memfd_get_seals(file);
271 struct file *file;
318 file = hugetlb_file_setup(name, 0, VM_NORESERVE, &user,
323 file = shmem_file_setup(name, 0, VM_NORESERVE);
324 if (IS_ERR(file)) {
325 error = PTR_ERR(file);
328 file->f_mode |= FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE;
329 file->f_flags |= O_LARGEFILE;
332 file_seals = memfd_file_seals_ptr(file);
337 fd_install(fd, file);