X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=fs%2Fopen.c;h=937f4ec201809722a2b13cc6cd6dfbf00345f715;hb=015c3bbcd88df2305aae5b017a9c91c08b380aa1;hp=1540632d8387fe98a51d0193201346acb18ae70e;hpb=36ec9fbfe772ba8309ccd724bb7dd26c0923b6f7;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git diff --git a/fs/open.c b/fs/open.c index 1540632..937f4ec 100644 --- a/fs/open.c +++ b/fs/open.c @@ -771,87 +771,46 @@ static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt, } /** - * lookup_instantiate_filp - instantiates the open intent filp - * @nd: pointer to nameidata + * finish_open - finish opening a file + * @od: opaque open data * @dentry: pointer to dentry * @open: open callback * - * Helper for filesystems that want to use lookup open intents and pass back - * a fully instantiated struct file to the caller. - * This function is meant to be called from within a filesystem's - * lookup method. - * Beware of calling it for non-regular files! Those ->open methods might block - * (e.g. in fifo_open), leaving you with parent locked (and in case of fifo, - * leading to a deadlock, as nobody can open that fifo anymore, because - * another process to open fifo will block on locked parent when doing lookup). - * Note that in case of error, nd->intent.open.file is destroyed, but the - * path information remains valid. + * This can be used to finish opening a file passed to i_op->atomic_open(). + * * If the open callback is set to NULL, then the standard f_op->open() * filesystem callback is substituted. */ -struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry, - int (*open)(struct inode *, struct file *)) +struct file *finish_open(struct opendata *od, struct dentry *dentry, + int (*open)(struct inode *, struct file *)) { - const struct cred *cred = current_cred(); + struct file *res; - if (IS_ERR(nd->intent.open.file)) - goto out; - if (IS_ERR(dentry)) - goto out_err; - nd->intent.open.file = __dentry_open(dget(dentry), mntget(nd->path.mnt), - nd->intent.open.file, - open, cred); -out: - return nd->intent.open.file; -out_err: - release_open_intent(nd); - nd->intent.open.file = ERR_CAST(dentry); - goto out; + mntget(od->mnt); + dget(dentry); + + res = do_dentry_open(dentry, od->mnt, od->filp, open, current_cred()); + if (!IS_ERR(res)) + od->filp = NULL; + + return res; } -EXPORT_SYMBOL_GPL(lookup_instantiate_filp); +EXPORT_SYMBOL(finish_open); /** - * nameidata_to_filp - convert a nameidata to an open filp. - * @nd: pointer to nameidata - * @flags: open flags + * finish_no_open - finish ->atomic_open() without opening the file * - * Note that this function destroys the original nameidata + * @od: opaque open data + * @dentry: dentry or NULL (as returned from ->lookup()) + * + * This can be used to set the result of a successful lookup in ->atomic_open(). + * The filesystem's atomic_open() method shall return NULL after calling this. */ -struct file *nameidata_to_filp(struct nameidata *nd) +void finish_no_open(struct opendata *od, struct dentry *dentry) { - const struct cred *cred = current_cred(); - struct file *filp; - - /* Pick up the filp from the open intent */ - filp = nd->intent.open.file; - - /* Has the filesystem initialised the file for us? */ - if (filp->f_path.dentry != NULL) { - nd->intent.open.file = NULL; - } else { - struct file *res; - - path_get(&nd->path); - res = do_dentry_open(nd->path.dentry, nd->path.mnt, - filp, NULL, cred); - if (!IS_ERR(res)) { - int error; - - nd->intent.open.file = NULL; - BUG_ON(res != filp); - - error = open_check_o_direct(filp); - if (error) { - fput(filp); - filp = ERR_PTR(error); - } - } else { - /* Allow nd->intent.open.file to be recycled */ - filp = res; - } - } - return filp; + od->dentry = dentry; } +EXPORT_SYMBOL(finish_no_open); /* * dentry_open() will have done dput(dentry) and mntput(mnt) if it returns an