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
384f26e2
Commit
384f26e2
authored
Apr 28, 2016
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
atomic_open(): reorder and clean up a bit
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
1643b43f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
34 deletions
+27
-34
fs/namei.c
fs/namei.c
+27
-34
No files found.
fs/namei.c
View file @
384f26e2
...
@@ -2827,14 +2827,11 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry,
...
@@ -2827,14 +2827,11 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry,
int
open_flag
,
umode_t
mode
,
int
open_flag
,
umode_t
mode
,
int
*
opened
)
int
*
opened
)
{
{
struct
dentry
*
const
DENTRY_NOT_SET
=
(
void
*
)
-
1UL
;
struct
inode
*
dir
=
nd
->
path
.
dentry
->
d_inode
;
struct
inode
*
dir
=
nd
->
path
.
dentry
->
d_inode
;
int
error
;
int
error
;
int
acc_mode
;
struct
dentry
*
const
DENTRY_NOT_SET
=
(
void
*
)
-
1UL
;
bool
excl
;
excl
=
(
open_flag
&
(
O_EXCL
|
O_CREAT
))
==
(
O_EXCL
|
O_CREAT
);
if
(
!
(
~
open_flag
&
(
O_EXCL
|
O_CREAT
)))
/* both O_EXCL and O_CREAT */
if
(
excl
)
open_flag
&=
~
O_TRUNC
;
open_flag
&=
~
O_TRUNC
;
if
(
nd
->
flags
&
LOOKUP_DIRECTORY
)
if
(
nd
->
flags
&
LOOKUP_DIRECTORY
)
...
@@ -2845,14 +2842,24 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry,
...
@@ -2845,14 +2842,24 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry,
error
=
dir
->
i_op
->
atomic_open
(
dir
,
dentry
,
file
,
error
=
dir
->
i_op
->
atomic_open
(
dir
,
dentry
,
file
,
open_to_namei_flags
(
open_flag
),
open_to_namei_flags
(
open_flag
),
mode
,
opened
);
mode
,
opened
);
if
(
error
<
0
)
if
(
!
error
)
{
goto
out
;
/*
* We didn't have the inode before the open, so check open
if
(
error
)
{
/* returned 1, that is */
* permission here.
*/
int
acc_mode
=
op
->
acc_mode
;
if
(
*
opened
&
FILE_CREATED
)
{
WARN_ON
(
!
(
open_flag
&
O_CREAT
));
fsnotify_create
(
dir
,
dentry
);
acc_mode
=
0
;
}
error
=
may_open
(
&
file
->
f_path
,
acc_mode
,
open_flag
);
if
(
WARN_ON
(
error
>
0
))
error
=
-
EINVAL
;
}
else
if
(
error
>
0
)
{
if
(
WARN_ON
(
file
->
f_path
.
dentry
==
DENTRY_NOT_SET
))
{
if
(
WARN_ON
(
file
->
f_path
.
dentry
==
DENTRY_NOT_SET
))
{
error
=
-
EIO
;
error
=
-
EIO
;
goto
out
;
}
else
{
}
if
(
file
->
f_path
.
dentry
)
{
if
(
file
->
f_path
.
dentry
)
{
dput
(
dentry
);
dput
(
dentry
);
dentry
=
file
->
f_path
.
dentry
;
dentry
=
file
->
f_path
.
dentry
;
...
@@ -2863,21 +2870,7 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry,
...
@@ -2863,21 +2870,7 @@ static int atomic_open(struct nameidata *nd, struct dentry *dentry,
path
->
mnt
=
nd
->
path
.
mnt
;
path
->
mnt
=
nd
->
path
.
mnt
;
return
1
;
return
1
;
}
}
/*
* We didn't have the inode before the open, so check open permission
* here.
*/
acc_mode
=
op
->
acc_mode
;
if
(
*
opened
&
FILE_CREATED
)
{
WARN_ON
(
!
(
open_flag
&
O_CREAT
));
fsnotify_create
(
dir
,
dentry
);
acc_mode
=
0
;
}
}
error
=
may_open
(
&
file
->
f_path
,
acc_mode
,
open_flag
);
if
(
WARN_ON
(
error
>
0
))
error
=
-
EINVAL
;
out:
dput
(
dentry
);
dput
(
dentry
);
return
error
;
return
error
;
}
}
...
...
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