Lines Matching refs:file

35 #include <linux/file.h>
89 * file does succeed in both HP-UX and SunOs, but not in Solaris
385 * Used to check for read/write/execute permissions on a file.
478 * Separate out file-system wide checks from inode-specific permission checks.
515 * Nobody gets write access to an immutable file.
650 * Rename can sometimes move a file or directory outside of a bind
910 * resolved file was inside the root at some point).
1138 * - inode is not a regular file
1217 * @inode: the inode of the file to open
1219 * Block an O_CREAT open of a FIFO (or a regular file) when:
1221 * - the file already exists
1223 * - we don't own the file
1224 * - the owner of the directory doesn't own the file
1267 * Given a path, find the mountpoint of its source file system.
1356 * create a file of any type under the mountpoint, wants to
2420 if (!f.file)
2423 dentry = f.file->f_path.dentry;
2430 nd->path = f.file->f_path;
2637 * vfs_path_lookup - lookup a file path relative to a dentry-vfsmount pair
2640 * @name: pointer to file name
3126 * @type: type of file to be created
3152 * file to be created before we call into the filesystem.
3161 * vfs_create - create new file
3165 * @mode: mode of the new file
3166 * @want_excl: whether the file must not yet exist
3168 * Create a new file.
3267 * An append-only file must be opened in append mode for writing.
3283 static int handle_truncate(struct mnt_idmap *idmap, struct file *filp)
3328 * Attempt to atomically look up, create and open a file from a negative
3331 * Returns 0 if successful. The file will have been created and attached to
3332 * @file by the filesystem calling finish_open().
3334 * If the file was looked up only or didn't need creating, FMODE_OPENED won't
3341 struct file *file,
3351 file->f_path.dentry = DENTRY_NOT_SET;
3352 file->f_path.mnt = nd->path.mnt;
3353 error = dir->i_op->atomic_open(dir, dentry, file,
3357 if (file->f_mode & FMODE_OPENED) {
3358 if (unlikely(dentry != file->f_path.dentry)) {
3360 dentry = dget(file->f_path.dentry);
3362 } else if (WARN_ON(file->f_path.dentry == DENTRY_NOT_SET)) {
3365 if (file->f_path.dentry) {
3367 dentry = file->f_path.dentry;
3386 * the file was successfully atomically created (if necessary) and opened, or
3387 * the file was not completely opened at this time, though lookups and
3389 * These case are distinguished by presence of FMODE_OPENED on file->f_mode.
3395 static struct dentry *lookup_open(struct nameidata *nd, struct file *file,
3411 file->f_mode &= ~FMODE_CREATED;
3439 * file exists. But checking existence breaks atomicity. The trick is
3461 dentry = atomic_open(nd, dentry, file, open_flag, mode);
3481 /* Negative dentry, just create the file */
3483 file->f_mode |= FMODE_CREATED;
3507 struct file *file, const struct open_flags *op)
3558 dentry = lookup_open(nd, file, op, got_write);
3559 if (!IS_ERR(dentry) && (file->f_mode & FMODE_CREATED))
3572 if (file->f_mode & (FMODE_OPENED | FMODE_CREATED)) {
3591 struct file *file, const struct open_flags *op)
3599 if (!(file->f_mode & (FMODE_OPENED | FMODE_CREATED))) {
3604 if (!(file->f_mode & FMODE_CREATED))
3608 if ((open_flag & O_EXCL) && !(file->f_mode & FMODE_CREATED))
3622 if (file->f_mode & FMODE_CREATED) {
3633 if (!error && !(file->f_mode & FMODE_OPENED))
3634 error = vfs_open(&nd->path, file);
3636 error = ima_file_check(file, op->acc_mode);
3638 error = handle_truncate(idmap, file);
3652 * @file: file descriptor of the new tmpfile
3655 * Create a temporary file.
3665 struct file *file, umode_t mode)
3671 int open_flag = file->f_flags;
3682 file->f_path.mnt = parentpath->mnt;
3683 file->f_path.dentry = child;
3685 error = dir->i_op->tmpfile(idmap, dir, file, mode);
3690 error = may_open(idmap, &file->f_path, 0, file->f_flags);
3693 inode = file_inode(file);
3711 * Create and open a temporary file. The file is not accounted in nr_files,
3713 * file tables or such.
3715 struct file *kernel_tmpfile_open(struct mnt_idmap *idmap,
3720 struct file *file;
3723 file = alloc_empty_file_noaccount(open_flag, cred);
3724 if (IS_ERR(file))
3725 return file;
3727 error = vfs_tmpfile(idmap, parentpath, file, mode);
3729 fput(file);
3730 file = ERR_PTR(error);
3732 return file;
3738 struct file *file)
3748 error = vfs_tmpfile(mnt_idmap(path.mnt), &path, file, op->mode);
3751 audit_inode(nd->name, file->f_path.dentry, 0);
3759 static int do_o_path(struct nameidata *nd, unsigned flags, struct file *file)
3765 error = vfs_open(&path, file);
3771 static struct file *path_openat(struct nameidata *nd,
3774 struct file *file;
3777 file = alloc_empty_file(op->open_flag, current_cred());
3778 if (IS_ERR(file))
3779 return file;
3781 if (unlikely(file->f_flags & __O_TMPFILE)) {
3782 error = do_tmpfile(nd, flags, op, file);
3783 } else if (unlikely(file->f_flags & O_PATH)) {
3784 error = do_o_path(nd, flags, file);
3788 (s = open_last_lookups(nd, file, op)) != NULL)
3791 error = do_open(nd, file, op);
3795 if (likely(file->f_mode & FMODE_OPENED))
3796 return file;
3800 fput(file);
3810 struct file *do_filp_open(int dfd, struct filename *pathname,
3815 struct file *filp;
3827 struct file *do_file_open_root(const struct path *root,
3831 struct file *file;
3843 file = path_openat(&nd, op, flags | LOOKUP_RCU);
3844 if (unlikely(file == ERR_PTR(-ECHILD)))
3845 file = path_openat(&nd, op, flags);
3846 if (unlikely(file == ERR_PTR(-ESTALE)))
3847 file = path_openat(&nd, op, flags | LOOKUP_REVAL);
3850 return file;
3953 * vfs_mknod - create device node or file
3957 * @mode: mode of the new device node or file
3960 * Create a device node or file.
4350 * Make sure that the actual truncation of the file will occur outside its
4449 * @oldname: name of the file to link to
4535 * If vfs_link discovers a delegation on the to-be-linked file in need
4570 * A link to an append-only or immutable file cannot be created.
4591 /* Make sure we don't allow creating hardlink to an unlinked file */