diff options
Diffstat (limited to 'fs/open.c')
-rw-r--r-- | fs/open.c | 42 |
1 files changed, 42 insertions, 0 deletions
@@ -811,6 +811,48 @@ out_err: | |||
811 | EXPORT_SYMBOL_GPL(lookup_instantiate_filp); | 811 | EXPORT_SYMBOL_GPL(lookup_instantiate_filp); |
812 | 812 | ||
813 | /** | 813 | /** |
814 | * finish_open - finish opening a file | ||
815 | * @od: opaque open data | ||
816 | * @dentry: pointer to dentry | ||
817 | * @open: open callback | ||
818 | * | ||
819 | * This can be used to finish opening a file passed to i_op->atomic_open(). | ||
820 | * | ||
821 | * If the open callback is set to NULL, then the standard f_op->open() | ||
822 | * filesystem callback is substituted. | ||
823 | */ | ||
824 | struct file *finish_open(struct opendata *od, struct dentry *dentry, | ||
825 | int (*open)(struct inode *, struct file *)) | ||
826 | { | ||
827 | struct file *res; | ||
828 | |||
829 | mntget(od->mnt); | ||
830 | dget(dentry); | ||
831 | |||
832 | res = do_dentry_open(dentry, od->mnt, *od->filp, open, current_cred()); | ||
833 | if (!IS_ERR(res)) | ||
834 | *od->filp = NULL; | ||
835 | |||
836 | return res; | ||
837 | } | ||
838 | EXPORT_SYMBOL(finish_open); | ||
839 | |||
840 | /** | ||
841 | * finish_no_open - finish ->atomic_open() without opening the file | ||
842 | * | ||
843 | * @od: opaque open data | ||
844 | * @dentry: dentry or NULL (as returned from ->lookup()) | ||
845 | * | ||
846 | * This can be used to set the result of a successful lookup in ->atomic_open(). | ||
847 | * The filesystem's atomic_open() method shall return NULL after calling this. | ||
848 | */ | ||
849 | void finish_no_open(struct opendata *od, struct dentry *dentry) | ||
850 | { | ||
851 | od->dentry = dentry; | ||
852 | } | ||
853 | EXPORT_SYMBOL(finish_no_open); | ||
854 | |||
855 | /** | ||
814 | * nameidata_to_filp - convert a nameidata to an open filp. | 856 | * nameidata_to_filp - convert a nameidata to an open filp. |
815 | * @nd: pointer to nameidata | 857 | * @nd: pointer to nameidata |
816 | * @flags: open flags | 858 | * @flags: open flags |