提交 00a07c15 编写于 作者: A Al Viro

switch atomic_open() and lookup_open() to returning 0 in all success cases

caller can tell "opened" from "open it yourself" by looking at ->f_mode.
Acked-by: NLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 6c9b1de1
...@@ -3027,9 +3027,9 @@ static int may_o_create(const struct path *dir, struct dentry *dentry, umode_t m ...@@ -3027,9 +3027,9 @@ static int may_o_create(const struct path *dir, struct dentry *dentry, umode_t m
* Returns 0 if successful. The file will have been created and attached to * Returns 0 if successful. The file will have been created and attached to
* @file by the filesystem calling finish_open(). * @file by the filesystem calling finish_open().
* *
* Returns 1 if the file was looked up only or didn't need creating. The * If the file was looked up only or didn't need creating, FMODE_OPENED won't
* caller will need to perform the open themselves. @path will have been * be set. The caller will need to perform the open themselves. @path will
* updated to point to the new dentry. This may be negative. * have been updated to point to the new dentry. This may be negative.
* *
* Returns an error code otherwise. * Returns an error code otherwise.
*/ */
...@@ -3082,7 +3082,7 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry, ...@@ -3082,7 +3082,7 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry,
} else { } else {
path->dentry = dentry; path->dentry = dentry;
path->mnt = nd->path.mnt; path->mnt = nd->path.mnt;
return 1; return 0;
} }
} }
} }
...@@ -3093,17 +3093,17 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry, ...@@ -3093,17 +3093,17 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry,
/* /*
* Look up and 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. * Must be called with parent locked (exclusive in O_CREAT case).
*
* 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 * Returns 0 on success, that is, if
* and creations will have been performed and the dentry returned in @path will * the file was successfully atomically created (if necessary) and opened, or
* be positive upon return if O_CREAT was specified. If O_CREAT wasn't * the file was not completely opened at this time, though lookups and
* specified then a negative dentry may be returned. * creations were performed.
* These case are distinguished by presence of FMODE_OPENED on file->f_mode.
* In the latter case dentry returned in @path might be negative if O_CREAT
* hadn't been specified.
* *
* An error code is returned otherwise. * An error code is returned on failure.
*/ */
static int lookup_open(struct nameidata *nd, struct path *path, static int lookup_open(struct nameidata *nd, struct path *path,
struct file *file, struct file *file,
...@@ -3225,7 +3225,7 @@ static int lookup_open(struct nameidata *nd, struct path *path, ...@@ -3225,7 +3225,7 @@ static int lookup_open(struct nameidata *nd, struct path *path,
out_no_open: out_no_open:
path->dentry = dentry; path->dentry = dentry;
path->mnt = nd->path.mnt; path->mnt = nd->path.mnt;
return 1; return 0;
out_dput: out_dput:
dput(dentry); dput(dentry);
...@@ -3308,10 +3308,10 @@ static int do_last(struct nameidata *nd, ...@@ -3308,10 +3308,10 @@ static int do_last(struct nameidata *nd,
else else
inode_unlock_shared(dir->d_inode); inode_unlock_shared(dir->d_inode);
if (error <= 0) { if (error)
if (error) goto out;
goto out;
if (file->f_mode & FMODE_OPENED) {
if ((file->f_mode & FMODE_CREATED) || if ((file->f_mode & FMODE_CREATED) ||
!S_ISREG(file_inode(file)->i_mode)) !S_ISREG(file_inode(file)->i_mode))
will_truncate = false; will_truncate = false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册