Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
5d826c84
K
Kernel
项目概览
openeuler
/
Kernel
大约 1 年 前同步成功
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5d826c84
编写于
3月 14, 2014
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
new helper: readlink_copy()
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
4efcc9ff
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
12 addition
and
47 deletion
+12
-47
fs/namei.c
fs/namei.c
+5
-8
fs/proc/namespaces.c
fs/proc/namespaces.c
+4
-10
fs/proc/self.c
fs/proc/self.c
+1
-1
fs/xfs/xfs_ioctl.c
fs/xfs/xfs_ioctl.c
+1
-27
include/linux/fs.h
include/linux/fs.h
+1
-1
未找到文件。
fs/namei.c
浏览文件 @
5d826c84
...
@@ -4297,11 +4297,9 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
...
@@ -4297,11 +4297,9 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
return
sys_renameat
(
AT_FDCWD
,
oldname
,
AT_FDCWD
,
newname
);
return
sys_renameat
(
AT_FDCWD
,
oldname
,
AT_FDCWD
,
newname
);
}
}
int
vfs_readlink
(
struct
dentry
*
dentry
,
char
__user
*
buffer
,
int
buflen
,
const
char
*
link
)
int
readlink_copy
(
char
__user
*
buffer
,
int
buflen
,
const
char
*
link
)
{
{
int
len
;
int
len
=
PTR_ERR
(
link
);
len
=
PTR_ERR
(
link
);
if
(
IS_ERR
(
link
))
if
(
IS_ERR
(
link
))
goto
out
;
goto
out
;
...
@@ -4313,7 +4311,7 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
...
@@ -4313,7 +4311,7 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
out:
out:
return
len
;
return
len
;
}
}
EXPORT_SYMBOL
(
vfs_readlink
);
EXPORT_SYMBOL
(
readlink_copy
);
/*
/*
* A helper for ->readlink(). This should be used *ONLY* for symlinks that
* A helper for ->readlink(). This should be used *ONLY* for symlinks that
...
@@ -4331,7 +4329,7 @@ int generic_readlink(struct dentry *dentry, char __user *buffer, int buflen)
...
@@ -4331,7 +4329,7 @@ int generic_readlink(struct dentry *dentry, char __user *buffer, int buflen)
if
(
IS_ERR
(
cookie
))
if
(
IS_ERR
(
cookie
))
return
PTR_ERR
(
cookie
);
return
PTR_ERR
(
cookie
);
res
=
vfs_readlink
(
dentry
,
buffer
,
buflen
,
nd_get_link
(
&
nd
));
res
=
readlink_copy
(
buffer
,
buflen
,
nd_get_link
(
&
nd
));
if
(
dentry
->
d_inode
->
i_op
->
put_link
)
if
(
dentry
->
d_inode
->
i_op
->
put_link
)
dentry
->
d_inode
->
i_op
->
put_link
(
dentry
,
&
nd
,
cookie
);
dentry
->
d_inode
->
i_op
->
put_link
(
dentry
,
&
nd
,
cookie
);
return
res
;
return
res
;
...
@@ -4356,8 +4354,7 @@ static char *page_getlink(struct dentry * dentry, struct page **ppage)
...
@@ -4356,8 +4354,7 @@ static char *page_getlink(struct dentry * dentry, struct page **ppage)
int
page_readlink
(
struct
dentry
*
dentry
,
char
__user
*
buffer
,
int
buflen
)
int
page_readlink
(
struct
dentry
*
dentry
,
char
__user
*
buffer
,
int
buflen
)
{
{
struct
page
*
page
=
NULL
;
struct
page
*
page
=
NULL
;
char
*
s
=
page_getlink
(
dentry
,
&
page
);
int
res
=
readlink_copy
(
buffer
,
buflen
,
page_getlink
(
dentry
,
&
page
));
int
res
=
vfs_readlink
(
dentry
,
buffer
,
buflen
,
s
);
if
(
page
)
{
if
(
page
)
{
kunmap
(
page
);
kunmap
(
page
);
page_cache_release
(
page
);
page_cache_release
(
page
);
...
...
fs/proc/namespaces.c
浏览文件 @
5d826c84
...
@@ -146,7 +146,7 @@ static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int bufl
...
@@ -146,7 +146,7 @@ static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int bufl
struct
task_struct
*
task
;
struct
task_struct
*
task
;
void
*
ns
;
void
*
ns
;
char
name
[
50
];
char
name
[
50
];
int
len
=
-
EACCES
;
int
res
=
-
EACCES
;
task
=
get_proc_task
(
inode
);
task
=
get_proc_task
(
inode
);
if
(
!
task
)
if
(
!
task
)
...
@@ -155,24 +155,18 @@ static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int bufl
...
@@ -155,24 +155,18 @@ static int proc_ns_readlink(struct dentry *dentry, char __user *buffer, int bufl
if
(
!
ptrace_may_access
(
task
,
PTRACE_MODE_READ
))
if
(
!
ptrace_may_access
(
task
,
PTRACE_MODE_READ
))
goto
out_put_task
;
goto
out_put_task
;
len
=
-
ENOENT
;
res
=
-
ENOENT
;
ns
=
ns_ops
->
get
(
task
);
ns
=
ns_ops
->
get
(
task
);
if
(
!
ns
)
if
(
!
ns
)
goto
out_put_task
;
goto
out_put_task
;
snprintf
(
name
,
sizeof
(
name
),
"%s:[%u]"
,
ns_ops
->
name
,
ns_ops
->
inum
(
ns
));
snprintf
(
name
,
sizeof
(
name
),
"%s:[%u]"
,
ns_ops
->
name
,
ns_ops
->
inum
(
ns
));
len
=
strlen
(
name
);
res
=
readlink_copy
(
buffer
,
buflen
,
name
);
if
(
len
>
buflen
)
len
=
buflen
;
if
(
copy_to_user
(
buffer
,
name
,
len
))
len
=
-
EFAULT
;
ns_ops
->
put
(
ns
);
ns_ops
->
put
(
ns
);
out_put_task:
out_put_task:
put_task_struct
(
task
);
put_task_struct
(
task
);
out:
out:
return
len
;
return
res
;
}
}
static
const
struct
inode_operations
proc_ns_link_inode_operations
=
{
static
const
struct
inode_operations
proc_ns_link_inode_operations
=
{
...
...
fs/proc/self.c
浏览文件 @
5d826c84
...
@@ -16,7 +16,7 @@ static int proc_self_readlink(struct dentry *dentry, char __user *buffer,
...
@@ -16,7 +16,7 @@ static int proc_self_readlink(struct dentry *dentry, char __user *buffer,
if
(
!
tgid
)
if
(
!
tgid
)
return
-
ENOENT
;
return
-
ENOENT
;
sprintf
(
tmp
,
"%d"
,
tgid
);
sprintf
(
tmp
,
"%d"
,
tgid
);
return
vfs_readlink
(
dentry
,
buffer
,
buflen
,
tmp
);
return
readlink_copy
(
buffer
,
buflen
,
tmp
);
}
}
static
void
*
proc_self_follow_link
(
struct
dentry
*
dentry
,
struct
nameidata
*
nd
)
static
void
*
proc_self_follow_link
(
struct
dentry
*
dentry
,
struct
nameidata
*
nd
)
...
...
fs/xfs/xfs_ioctl.c
浏览文件 @
5d826c84
...
@@ -271,32 +271,6 @@ xfs_open_by_handle(
...
@@ -271,32 +271,6 @@ xfs_open_by_handle(
return
error
;
return
error
;
}
}
/*
* This is a copy from fs/namei.c:vfs_readlink(), except for removing it's
* unused first argument.
*/
STATIC
int
do_readlink
(
char
__user
*
buffer
,
int
buflen
,
const
char
*
link
)
{
int
len
;
len
=
PTR_ERR
(
link
);
if
(
IS_ERR
(
link
))
goto
out
;
len
=
strlen
(
link
);
if
(
len
>
(
unsigned
)
buflen
)
len
=
buflen
;
if
(
copy_to_user
(
buffer
,
link
,
len
))
len
=
-
EFAULT
;
out:
return
len
;
}
int
int
xfs_readlink_by_handle
(
xfs_readlink_by_handle
(
struct
file
*
parfilp
,
struct
file
*
parfilp
,
...
@@ -334,7 +308,7 @@ xfs_readlink_by_handle(
...
@@ -334,7 +308,7 @@ xfs_readlink_by_handle(
error
=
-
xfs_readlink
(
XFS_I
(
dentry
->
d_inode
),
link
);
error
=
-
xfs_readlink
(
XFS_I
(
dentry
->
d_inode
),
link
);
if
(
error
)
if
(
error
)
goto
out_kfree
;
goto
out_kfree
;
error
=
do_readlink
(
hreq
->
ohandle
,
olen
,
link
);
error
=
readlink_copy
(
hreq
->
ohandle
,
olen
,
link
);
if
(
error
)
if
(
error
)
goto
out_kfree
;
goto
out_kfree
;
...
...
include/linux/fs.h
浏览文件 @
5d826c84
...
@@ -2517,7 +2517,7 @@ extern const struct file_operations generic_ro_fops;
...
@@ -2517,7 +2517,7 @@ extern const struct file_operations generic_ro_fops;
#define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
#define special_file(m) (S_ISCHR(m)||S_ISBLK(m)||S_ISFIFO(m)||S_ISSOCK(m))
extern
int
vfs_readlink
(
struct
dentry
*
,
char
__user
*
,
int
,
const
char
*
);
extern
int
readlink_copy
(
char
__user
*
,
int
,
const
char
*
);
extern
int
page_readlink
(
struct
dentry
*
,
char
__user
*
,
int
);
extern
int
page_readlink
(
struct
dentry
*
,
char
__user
*
,
int
);
extern
void
*
page_follow_link_light
(
struct
dentry
*
,
struct
nameidata
*
);
extern
void
*
page_follow_link_light
(
struct
dentry
*
,
struct
nameidata
*
);
extern
void
page_put_link
(
struct
dentry
*
,
struct
nameidata
*
,
void
*
);
extern
void
page_put_link
(
struct
dentry
*
,
struct
nameidata
*
,
void
*
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录