diff --git a/fs/internal.h b/fs/internal.h index b71deeecea17939d85bce1c54f30da77f1c4d8a1..c8ca0c957743b587b9ad448b2ec43ad5da05608c 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -108,6 +108,7 @@ extern long do_handle_open(int mountdirfd, struct file_handle __user *ufh, int open_flag); extern int open_check_o_direct(struct file *f); extern int vfs_open(const struct path *, struct file *, const struct cred *); +extern struct file *filp_clone_open(struct file *); /* * inode.c diff --git a/fs/open.c b/fs/open.c index 17cb6b1dab753b9de6366f92b6ca3ba3cb204291..bfe6f2b8345f5eabcc24bb889d5023f9b64ff415 100644 --- a/fs/open.c +++ b/fs/open.c @@ -1002,6 +1002,26 @@ struct file *file_open_root(struct dentry *dentry, struct vfsmount *mnt, } EXPORT_SYMBOL(file_open_root); +struct file *filp_clone_open(struct file *oldfile) +{ + struct file *file; + int retval; + + file = get_empty_filp(); + if (IS_ERR(file)) + return file; + + file->f_flags = oldfile->f_flags; + retval = vfs_open(&oldfile->f_path, file, oldfile->f_cred); + if (retval) { + put_filp(file); + return ERR_PTR(retval); + } + + return file; +} +EXPORT_SYMBOL(filp_clone_open); + long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode) { struct open_flags op;