Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
55db2fd9
Commit
55db2fd9
authored
Apr 27, 2016
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
atomic_open(): massage the create_error logics a bit
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
9d0728e1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
23 deletions
+20
-23
fs/namei.c
fs/namei.c
+20
-23
No files found.
fs/namei.c
View file @
55db2fd9
...
...
@@ -2855,33 +2855,30 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry,
* Another problem is returing the "right" error value (e.g. for an
* O_EXCL open we want to return EEXIST not EROFS).
*/
if
(((
open_flag
&
(
O_CREAT
|
O_TRUNC
))
||
(
open_flag
&
O_ACCMODE
)
!=
O_RDONLY
)
&&
unlikely
(
!
got_write
))
{
if
(
!
(
open_flag
&
O_CREAT
))
{
/*
* No O_CREATE -> atomicity not a requirement -> fall
* back to lookup + open
*/
goto
no_open
;
}
else
if
(
open_flag
&
(
O_EXCL
|
O_TRUNC
))
{
/* Fall back and fail with the right error */
create_error
=
-
EROFS
;
goto
no_open
;
}
else
{
/* No side effects, safe to clear O_CREAT */
create_error
=
-
EROFS
;
open_flag
&=
~
O_CREAT
;
}
}
if
(
open_flag
&
O_CREAT
)
{
error
=
may_o_create
(
&
nd
->
path
,
dentry
,
mode
);
if
(
error
)
{
create_error
=
error
;
if
(
open_flag
&
O_EXCL
)
if
(
unlikely
(
!
got_write
))
{
create_error
=
-
EROFS
;
if
(
open_flag
&
(
O_EXCL
|
O_TRUNC
))
{
/* Fall back and fail with the right error */
goto
no_open
;
}
/* No side effects, safe to clear O_CREAT */
open_flag
&=
~
O_CREAT
;
}
else
{
create_error
=
may_o_create
(
&
nd
->
path
,
dentry
,
mode
);
if
(
create_error
)
{
if
(
open_flag
&
O_EXCL
)
goto
no_open
;
open_flag
&=
~
O_CREAT
;
}
}
}
else
if
((
open_flag
&
(
O_TRUNC
|
O_WRONLY
|
O_RDWR
))
&&
unlikely
(
!
got_write
))
{
/*
* No O_CREATE -> atomicity not a requirement -> fall
* back to lookup + open
*/
goto
no_open
;
}
if
(
nd
->
flags
&
LOOKUP_DIRECTORY
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment