Lines Matching refs:file

10 #include <linux/file.h>
40 loff_t length, unsigned int time_attrs, struct file *filp)
56 /* Remove suid, sgid, and file capabilities on truncate too */
156 long do_ftruncate(struct file *file, loff_t length, int small)
163 if (file->f_flags & O_LARGEFILE)
166 dentry = file->f_path.dentry;
168 if (!S_ISREG(inode->i_mode) || !(file->f_mode & FMODE_WRITE))
171 /* Cannot ftruncate over 2^31 bytes without large file support */
176 if (IS_APPEND(file_inode(file)))
179 error = security_file_truncate(file);
181 error = do_truncate(file_mnt_idmap(file), dentry, length,
182 ATTR_MTIME | ATTR_CTIME, file);
196 if (!f.file)
199 error = do_ftruncate(f.file, length, small);
246 int vfs_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
248 struct inode *inode = file_inode(file);
283 if (!(file->f_mode & FMODE_WRITE))
305 ret = security_file_permission(file, MAY_WRITE);
309 ret = fsnotify_file_area_perm(file, MAY_WRITE, &offset, len);
326 if (!file->f_op->fallocate)
329 file_start_write(file);
330 ret = file->f_op->fallocate(file, mode, offset, len);
336 * This implies that events are even created if the file size remains
340 fsnotify_modify(file);
342 file_end_write(file);
352 if (f.file) {
353 error = vfs_fallocate(f.file, mode, offset, len);
584 if (!f.file)
588 if (!d_can_lookup(f.file->f_path.dentry))
591 error = file_permission(f.file, MAY_EXEC | MAY_CHDIR);
593 set_fs_pwd(current->fs, &f.file->f_path);
663 int vfs_fchmod(struct file *file, umode_t mode)
665 audit_file(file);
666 return chmod_common(&file->f_path, mode);
674 if (f.file) {
675 err = vfs_fchmod(f.file, mode);
850 int vfs_fchown(struct file *file, uid_t user, gid_t group)
854 error = mnt_want_write_file(file);
857 audit_file(file);
858 error = chown_common(&file->f_path, user, group);
859 mnt_drop_write_file(file);
868 if (f.file) {
869 error = vfs_fchown(f.file, user, group);
880 static inline int file_get_write_access(struct file *f)
904 static int do_dentry_open(struct file *f,
905 int (*open)(struct inode *, struct file *))
981 * cache for this file before processing writes.
1008 * Once we return a file with FMODE_OPENED, __fput() will call
1028 * finish_open - finish opening a file
1029 * @file: file pointer
1033 * This can be used to finish opening a file passed to i_op->atomic_open().
1044 int finish_open(struct file *file, struct dentry *dentry,
1045 int (*open)(struct inode *, struct file *))
1047 BUG_ON(file->f_mode & FMODE_OPENED); /* once it's opened, it's opened */
1049 file->f_path.dentry = dentry;
1050 return do_dentry_open(file, open);
1055 * finish_no_open - finish ->atomic_open() without opening the file
1057 * @file: file pointer
1068 int finish_no_open(struct file *file, struct dentry *dentry)
1070 file->f_path.dentry = dentry;
1075 char *file_path(struct file *filp, char *buf, int buflen)
1082 * vfs_open - open the file at the given path
1084 * @file: newly allocated file with f_flag initialized
1086 int vfs_open(const struct path *path, struct file *file)
1088 file->f_path = *path;
1089 return do_dentry_open(file, NULL);
1092 struct file *dentry_open(const struct path *path, int flags,
1096 struct file *f;
1114 * dentry_create - Create and open a file
1117 * @mode: mode bits for new file
1121 * a negative dentry, placed in @path->dentry, for the new file.
1124 * the new file is to be created. The parent directory and the
1127 * On success, returns a "struct file *". Otherwise a ERR_PTR
1130 struct file *dentry_create(const struct path *path, int flags, umode_t mode,
1133 struct file *f;
1155 * kernel_file_open - open a file for kernel internal use
1156 * @path: path of the file to open
1160 * Open a file for use by in-kernel consumers. The file is not accounted
1161 * against nr_files and must not be installed into the file descriptor
1164 * Return: Opened file on success, an error pointer on failure.
1166 struct file *kernel_file_open(const struct path *path, int flags,
1169 struct file *f;
1333 * file_open_name - open file and return file pointer
1337 * @mode: mode for the new file if O_CREAT is set, else ignored
1339 * This is the helper to open a file from kernelspace if you really
1343 struct file *file_open_name(struct filename *name, int flags, umode_t mode)
1354 * filp_open - open file and return file pointer
1358 * @mode: mode for the new file if O_CREAT is set, else ignored
1360 * This is the helper to open a file from kernelspace if you really
1364 struct file *filp_open(const char *filename, int flags, umode_t mode)
1367 struct file *file = ERR_CAST(name);
1370 file = file_open_name(name, flags, mode);
1373 return file;
1377 struct file *file_open_root(const struct path *root,
1405 struct file *f = do_filp_open(dfd, tmp, &op);
1504 static int filp_flush(struct file *filp, fl_owner_t id)
1509 "VFS: Close: file count is 0 (f_op=%ps)",
1524 int filp_close(struct file *filp, fl_owner_t id)
1536 * Careful here! We test whether the file pointer is NULL before
1543 struct file *file;
1545 file = file_close_fd(fd);
1546 if (!file)
1549 retval = filp_flush(file, current->files);
1555 __fput_sync(file);
1557 /* can't restart close syscall because file table entry was cleared */
1568 * sys_close_range() - Close all file descriptors in a given range.
1570 * @fd: starting file descriptor to close
1571 * @max_fd: last file descriptor to close
1574 * This closes a range of file descriptors. All file descriptors
1576 * Currently, errors to close a given file descriptor are ignored.
1603 int generic_file_open(struct inode * inode, struct file * filp)
1614 * file descriptors. The function is not supposed to ever fail, the only
1618 int nonseekable_open(struct inode *inode, struct file *filp)
1627 * stream_open is used by subsystems that want stream-like file descriptors.
1628 * Such file descriptors are not seekable and don't have notion of position
1629 * (file.f_pos is always 0 and ppos passed to .read()/.write() is always NULL).
1630 * Contrary to file descriptors of other regular files, .read() and .write()
1636 int stream_open(struct inode *inode, struct file *filp)