Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
625b6d10
R
raspberrypi-kernel
项目概览
openeuler
/
raspberrypi-kernel
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
raspberrypi-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
625b6d10
编写于
5月 12, 2015
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
namei: pass the struct path to store the result down into path_lookupat()
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
18d8c860
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
34 addition
and
38 deletion
+34
-38
fs/namei.c
fs/namei.c
+34
-38
未找到文件。
fs/namei.c
浏览文件 @
625b6d10
...
...
@@ -2086,8 +2086,8 @@ static inline int lookup_last(struct nameidata *nd)
}
/* Returns 0 and nd will be valid on success; Retuns error, otherwise. */
static
int
path_lookupat
(
int
dfd
,
const
struct
filename
*
name
,
unsigned
int
flags
,
struct
nameidata
*
nd
)
static
int
path_lookupat
(
int
dfd
,
const
struct
filename
*
name
,
unsigned
flags
,
struct
nameidata
*
nd
,
struct
path
*
path
)
{
const
char
*
s
=
path_init
(
dfd
,
name
,
flags
,
nd
);
int
err
;
...
...
@@ -2108,27 +2108,31 @@ static int path_lookupat(int dfd, const struct filename *name,
if
(
!
err
&&
nd
->
flags
&
LOOKUP_DIRECTORY
)
if
(
!
d_can_lookup
(
nd
->
path
.
dentry
))
err
=
-
ENOTDIR
;
if
(
err
)
if
(
!
err
)
{
*
path
=
nd
->
path
;
nd
->
path
.
mnt
=
NULL
;
nd
->
path
.
dentry
=
NULL
;
}
terminate_walk
(
nd
);
path_cleanup
(
nd
);
return
err
;
}
static
int
filename_lookup
(
int
dfd
,
struct
filename
*
name
,
unsigned
int
flags
,
struct
nameidata
*
nd
)
static
int
filename_lookup
(
int
dfd
,
struct
filename
*
name
,
unsigned
flags
,
struct
nameidata
*
nd
,
struct
path
*
path
)
{
int
retval
;
struct
nameidata
*
saved_nd
=
set_nameidata
(
nd
);
retval
=
path_lookupat
(
dfd
,
name
,
flags
|
LOOKUP_RCU
,
nd
);
retval
=
path_lookupat
(
dfd
,
name
,
flags
|
LOOKUP_RCU
,
nd
,
path
);
if
(
unlikely
(
retval
==
-
ECHILD
))
retval
=
path_lookupat
(
dfd
,
name
,
flags
,
nd
);
retval
=
path_lookupat
(
dfd
,
name
,
flags
,
nd
,
path
);
if
(
unlikely
(
retval
==
-
ESTALE
))
retval
=
path_lookupat
(
dfd
,
name
,
flags
|
LOOKUP_REVAL
,
nd
);
retval
=
path_lookupat
(
dfd
,
name
,
flags
|
LOOKUP_REVAL
,
nd
,
path
);
if
(
likely
(
!
retval
))
audit_inode
(
name
,
nd
->
path
.
dentry
,
flags
&
LOOKUP_PARENT
);
audit_inode
(
name
,
path
->
dentry
,
flags
&
LOOKUP_PARENT
);
restore_nameidata
(
saved_nd
);
return
retval
;
}
...
...
@@ -2209,10 +2213,8 @@ int kern_path(const char *name, unsigned int flags, struct path *path)
int
res
=
PTR_ERR
(
filename
);
if
(
!
IS_ERR
(
filename
))
{
res
=
filename_lookup
(
AT_FDCWD
,
filename
,
flags
,
&
nd
);
res
=
filename_lookup
(
AT_FDCWD
,
filename
,
flags
,
&
nd
,
path
);
putname
(
filename
);
if
(
!
res
)
*
path
=
nd
.
path
;
}
return
res
;
}
...
...
@@ -2241,9 +2243,7 @@ int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
nd
.
root
.
dentry
=
dentry
;
nd
.
root
.
mnt
=
mnt
;
err
=
filename_lookup
(
AT_FDCWD
,
filename
,
flags
|
LOOKUP_ROOT
,
&
nd
);
if
(
!
err
)
*
path
=
nd
.
path
;
flags
|
LOOKUP_ROOT
,
&
nd
,
path
);
putname
(
filename
);
}
return
err
;
...
...
@@ -2311,10 +2311,8 @@ int user_path_at_empty(int dfd, const char __user *name, unsigned flags,
BUG_ON
(
flags
&
LOOKUP_PARENT
);
err
=
filename_lookup
(
dfd
,
tmp
,
flags
,
&
nd
);
err
=
filename_lookup
(
dfd
,
tmp
,
flags
,
&
nd
,
path
);
putname
(
tmp
);
if
(
!
err
)
*
path
=
nd
.
path
;
}
return
err
;
}
...
...
@@ -3261,44 +3259,42 @@ static int do_tmpfile(int dfd, struct filename *pathname,
struct
file
*
file
,
int
*
opened
)
{
static
const
struct
qstr
name
=
QSTR_INIT
(
"/"
,
1
);
struct
dentry
*
dentry
,
*
child
;
struct
dentry
*
child
;
struct
inode
*
dir
;
struct
path
path
;
int
error
=
path_lookupat
(
dfd
,
pathname
,
flags
|
LOOKUP_DIRECTORY
,
nd
);
flags
|
LOOKUP_DIRECTORY
,
nd
,
&
path
);
if
(
unlikely
(
error
))
return
error
;
error
=
mnt_want_write
(
nd
->
path
.
mnt
);
error
=
mnt_want_write
(
path
.
mnt
);
if
(
unlikely
(
error
))
goto
out
;
dir
=
path
.
dentry
->
d_inode
;
/* we want directory to be writable */
error
=
inode_permission
(
nd
->
inode
,
MAY_WRITE
|
MAY_EXEC
);
error
=
inode_permission
(
dir
,
MAY_WRITE
|
MAY_EXEC
);
if
(
error
)
goto
out2
;
dentry
=
nd
->
path
.
dentry
;
dir
=
dentry
->
d_inode
;
if
(
!
dir
->
i_op
->
tmpfile
)
{
error
=
-
EOPNOTSUPP
;
goto
out2
;
}
child
=
d_alloc
(
dentry
,
&
name
);
child
=
d_alloc
(
path
.
dentry
,
&
name
);
if
(
unlikely
(
!
child
))
{
error
=
-
ENOMEM
;
goto
out2
;
}
nd
->
flags
&=
~
LOOKUP_DIRECTORY
;
nd
->
flags
|=
op
->
intent
;
dput
(
nd
->
path
.
dentry
);
nd
->
path
.
dentry
=
child
;
error
=
dir
->
i_op
->
tmpfile
(
dir
,
nd
->
path
.
dentry
,
op
->
mode
);
dput
(
path
.
dentry
);
path
.
dentry
=
child
;
error
=
dir
->
i_op
->
tmpfile
(
dir
,
child
,
op
->
mode
);
if
(
error
)
goto
out2
;
audit_inode
(
pathname
,
nd
->
path
.
dentry
,
0
);
audit_inode
(
pathname
,
child
,
0
);
/* Don't check for other permissions, the inode was just created */
error
=
may_open
(
&
nd
->
path
,
MAY_OPEN
,
op
->
open_flag
);
error
=
may_open
(
&
path
,
MAY_OPEN
,
op
->
open_flag
);
if
(
error
)
goto
out2
;
file
->
f_path
.
mnt
=
nd
->
path
.
mnt
;
error
=
finish_open
(
file
,
nd
->
path
.
dentry
,
NULL
,
opened
);
file
->
f_path
.
mnt
=
path
.
mnt
;
error
=
finish_open
(
file
,
child
,
NULL
,
opened
);
if
(
error
)
goto
out2
;
error
=
open_check_o_direct
(
file
);
...
...
@@ -3311,9 +3307,9 @@ static int do_tmpfile(int dfd, struct filename *pathname,
spin_unlock
(
&
inode
->
i_lock
);
}
out2:
mnt_drop_write
(
nd
->
path
.
mnt
);
mnt_drop_write
(
path
.
mnt
);
out:
path_put
(
&
nd
->
path
);
path_put
(
&
path
);
return
error
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录