From 41fb6e678320f556f43e9dc1eb2a518560b83be5 Mon Sep 17 00:00:00 2001 From: David Howells Date: Thu, 14 Jun 2012 16:13:46 +0100 Subject: [PATCH] --- yaml --- r: 312924 b: refs/heads/master c: 1acf0af9b981027f3e73e93f0d3f85abdc794f71 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/namei.c | 29 ++++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index 9c2d869a2de0..f7a6b185071d 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 312b63fba9e88a0dcf800834b8ede8716bcc1e17 +refs/heads/master: 1acf0af9b981027f3e73e93f0d3f85abdc794f71 diff --git a/trunk/fs/namei.c b/trunk/fs/namei.c index ffcd4e114b6e..5abab9176903 100644 --- a/trunk/fs/namei.c +++ b/trunk/fs/namei.c @@ -2192,6 +2192,19 @@ static int may_o_create(struct path *dir, struct dentry *dentry, umode_t mode) return security_inode_create(dir->dentry->d_inode, dentry, mode); } +/* + * Attempt to atomically look up, create and open a file from a negative + * dentry. + * + * Returns 0 if successful. The file will have been created and attached to + * @file by the filesystem calling finish_open(). + * + * Returns 1 if the file was looked up only or didn't need creating. The + * caller will need to perform the open themselves. @path will have been + * updated to point to the new dentry. This may be negative. + * + * Returns an error code otherwise. + */ static int atomic_open(struct nameidata *nd, struct dentry *dentry, struct path *path, struct file *file, const struct open_flags *op, @@ -2336,12 +2349,22 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry, } /* - * Lookup, maybe create and open the last component + * Look up and maybe create and open the last component. * * Must be called with i_mutex held on parent. * - * Returns open file or NULL on success, error otherwise. NULL means no open - * was performed, only lookup. + * Returns 0 if the file was successfully atomically created (if necessary) and + * opened. In this case the file will be returned attached to @file. + * + * Returns 1 if the file was not completely opened at this time, though lookups + * and creations will have been performed and the dentry returned in @path will + * be positive upon return if O_CREAT was specified. If O_CREAT wasn't + * specified then a negative dentry may be returned. + * + * An error code is returned otherwise. + * + * FILE_CREATE will be set in @*opened if the dentry was created and will be + * cleared otherwise prior to returning. */ static int lookup_open(struct nameidata *nd, struct path *path, struct file *file,