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
066cc813
Commit
066cc813
authored
Dec 01, 2017
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
do_mq_open(): move all work prior to dentry_open() into a helper
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
05c1b290
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
46 deletions
+31
-46
ipc/mqueue.c
ipc/mqueue.c
+31
-46
No files found.
ipc/mqueue.c
View file @
066cc813
...
...
@@ -713,34 +713,44 @@ static void remove_notification(struct mqueue_inode_info *info)
info
->
notify_user_ns
=
NULL
;
}
/*
* Invoked when creating a new queue via sys_mq_open
*/
static
int
do_create
(
struct
ipc_namespace
*
ipc_ns
,
struct
inode
*
dir
,
struct
path
*
path
,
int
oflag
,
umode_t
mode
,
static
int
prepare_open
(
struct
dentry
*
dentry
,
int
oflag
,
int
ro
,
umode_t
mode
,
struct
filename
*
name
,
struct
mq_attr
*
attr
)
{
return
vfs_mkobj
(
path
->
dentry
,
mode
&
~
current_umask
(),
mqueue_create_attr
,
attr
);
}
/* Opens existing queue */
static
int
do_open
(
struct
path
*
path
,
int
oflag
)
{
static
const
int
oflag2acc
[
O_ACCMODE
]
=
{
MAY_READ
,
MAY_WRITE
,
MAY_READ
|
MAY_WRITE
};
int
acc
;
if
(
oflag
&
O_CREAT
)
{
if
(
d_really_is_positive
(
dentry
))
{
/* entry already exists */
audit_inode
(
name
,
dentry
,
0
);
if
(
oflag
&
O_EXCL
)
return
-
EEXIST
;
}
else
{
if
(
ro
)
return
ro
;
audit_inode_parent_hidden
(
name
,
dentry
->
d_parent
);
return
vfs_mkobj
(
dentry
,
mode
&
~
current_umask
(),
mqueue_create_attr
,
attr
);
}
}
else
{
if
(
d_really_is_negative
(
dentry
))
{
return
-
ENOENT
;
}
else
{
audit_inode
(
name
,
dentry
,
0
);
}
}
if
((
oflag
&
O_ACCMODE
)
==
(
O_RDWR
|
O_WRONLY
))
return
-
EINVAL
;
acc
=
oflag2acc
[
oflag
&
O_ACCMODE
];
return
inode_permission
(
d_inode
(
path
->
dentry
),
acc
);
return
inode_permission
(
d_inode
(
dentry
),
acc
);
}
static
int
do_mq_open
(
const
char
__user
*
u_name
,
int
oflag
,
umode_t
mode
,
struct
mq_attr
*
attr
)
{
struct
path
path
;
struct
file
*
filp
;
struct
filename
*
name
;
int
fd
,
error
;
struct
ipc_namespace
*
ipc_ns
=
current
->
nsproxy
->
ipc_ns
;
...
...
@@ -767,39 +777,14 @@ static int do_mq_open(const char __user *u_name, int oflag, umode_t mode,
}
path
.
mnt
=
mntget
(
mnt
);
if
(
oflag
&
O_CREAT
)
{
if
(
d_really_is_positive
(
path
.
dentry
))
{
/* entry already exists */
audit_inode
(
name
,
path
.
dentry
,
0
);
if
(
oflag
&
O_EXCL
)
error
=
-
EEXIST
;
else
error
=
do_open
(
&
path
,
oflag
);
}
else
{
if
(
ro
)
{
error
=
ro
;
}
else
{
audit_inode_parent_hidden
(
name
,
root
);
error
=
do_create
(
ipc_ns
,
d_inode
(
root
),
&
path
,
oflag
,
mode
,
attr
);
}
}
}
else
{
if
(
d_really_is_negative
(
path
.
dentry
))
{
error
=
-
ENOENT
;
}
else
{
audit_inode
(
name
,
path
.
dentry
,
0
);
error
=
do_open
(
&
path
,
oflag
);
}
error
=
prepare_open
(
path
.
dentry
,
oflag
,
ro
,
mode
,
name
,
attr
);
if
(
!
error
)
{
struct
file
*
file
=
dentry_open
(
&
path
,
oflag
,
current_cred
());
if
(
!
IS_ERR
(
file
))
fd_install
(
fd
,
file
);
else
error
=
PTR_ERR
(
file
);
}
if
(
error
)
goto
out
;
filp
=
dentry_open
(
&
path
,
oflag
,
current_cred
());
if
(
!
IS_ERR
(
filp
))
fd_install
(
fd
,
filp
);
else
error
=
PTR_ERR
(
filp
);
out:
path_put
(
&
path
);
out_putfd:
if
(
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