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
nexedi
linux
Commits
0f9d1a10
Commit
0f9d1a10
authored
Mar 09, 2011
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
expand finish_open() in its only caller
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
5a202bcd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
52 deletions
+38
-52
fs/namei.c
fs/namei.c
+38
-52
No files found.
fs/namei.c
View file @
0f9d1a10
...
@@ -2111,57 +2111,6 @@ static int open_will_truncate(int flag, struct inode *inode)
...
@@ -2111,57 +2111,6 @@ static int open_will_truncate(int flag, struct inode *inode)
return
(
flag
&
O_TRUNC
);
return
(
flag
&
O_TRUNC
);
}
}
static
struct
file
*
finish_open
(
struct
nameidata
*
nd
,
int
open_flag
,
int
acc_mode
)
{
struct
file
*
filp
;
int
will_truncate
;
int
error
;
will_truncate
=
open_will_truncate
(
open_flag
,
nd
->
path
.
dentry
->
d_inode
);
if
(
will_truncate
)
{
error
=
mnt_want_write
(
nd
->
path
.
mnt
);
if
(
error
)
goto
exit
;
}
error
=
may_open
(
&
nd
->
path
,
acc_mode
,
open_flag
);
if
(
error
)
{
if
(
will_truncate
)
mnt_drop_write
(
nd
->
path
.
mnt
);
goto
exit
;
}
filp
=
nameidata_to_filp
(
nd
);
if
(
!
IS_ERR
(
filp
))
{
error
=
ima_file_check
(
filp
,
acc_mode
);
if
(
error
)
{
fput
(
filp
);
filp
=
ERR_PTR
(
error
);
}
}
if
(
!
IS_ERR
(
filp
))
{
if
(
will_truncate
)
{
error
=
handle_truncate
(
filp
);
if
(
error
)
{
fput
(
filp
);
filp
=
ERR_PTR
(
error
);
}
}
}
/*
* It is now safe to drop the mnt write
* because the filp has had a write taken
* on its behalf.
*/
if
(
will_truncate
)
mnt_drop_write
(
nd
->
path
.
mnt
);
path_put
(
&
nd
->
path
);
return
filp
;
exit:
path_put
(
&
nd
->
path
);
return
ERR_PTR
(
error
);
}
/*
/*
* Handle the last step of open()
* Handle the last step of open()
*/
*/
...
@@ -2169,6 +2118,7 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
...
@@ -2169,6 +2118,7 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
const
struct
open_flags
*
op
,
const
char
*
pathname
)
const
struct
open_flags
*
op
,
const
char
*
pathname
)
{
{
struct
dentry
*
dir
=
nd
->
path
.
dentry
;
struct
dentry
*
dir
=
nd
->
path
.
dentry
;
int
will_truncate
;
struct
file
*
filp
;
struct
file
*
filp
;
struct
inode
*
inode
;
struct
inode
*
inode
;
int
error
;
int
error
;
...
@@ -2329,7 +2279,43 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
...
@@ -2329,7 +2279,43 @@ static struct file *do_last(struct nameidata *nd, struct path *path,
if
(
S_ISDIR
(
nd
->
inode
->
i_mode
))
if
(
S_ISDIR
(
nd
->
inode
->
i_mode
))
goto
exit
;
goto
exit
;
ok:
ok:
filp
=
finish_open
(
nd
,
op
->
open_flag
,
op
->
acc_mode
);
will_truncate
=
open_will_truncate
(
op
->
open_flag
,
nd
->
path
.
dentry
->
d_inode
);
if
(
will_truncate
)
{
error
=
mnt_want_write
(
nd
->
path
.
mnt
);
if
(
error
)
goto
exit
;
}
error
=
may_open
(
&
nd
->
path
,
op
->
acc_mode
,
op
->
open_flag
);
if
(
error
)
{
if
(
will_truncate
)
mnt_drop_write
(
nd
->
path
.
mnt
);
goto
exit
;
}
filp
=
nameidata_to_filp
(
nd
);
if
(
!
IS_ERR
(
filp
))
{
error
=
ima_file_check
(
filp
,
op
->
acc_mode
);
if
(
error
)
{
fput
(
filp
);
filp
=
ERR_PTR
(
error
);
}
}
if
(
!
IS_ERR
(
filp
))
{
if
(
will_truncate
)
{
error
=
handle_truncate
(
filp
);
if
(
error
)
{
fput
(
filp
);
filp
=
ERR_PTR
(
error
);
}
}
}
/*
* It is now safe to drop the mnt write
* because the filp has had a write taken
* on its behalf.
*/
if
(
will_truncate
)
mnt_drop_write
(
nd
->
path
.
mnt
);
path_put
(
&
nd
->
path
);
return
filp
;
return
filp
;
exit_mutex_unlock:
exit_mutex_unlock:
...
...
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