Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Linux-御风守护者
linux
提交
723a1d77
L
linux
项目概览
Linux-御风守护者
/
linux
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
723a1d77
编写于
8月 19, 2012
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
um: resurrect the right variant of mconsole_proc()
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
483ce1d4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
21 addition
and
78 deletion
+21
-78
arch/um/drivers/mconsole_kern.c
arch/um/drivers/mconsole_kern.c
+21
-78
未找到文件。
arch/um/drivers/mconsole_kern.c
浏览文件 @
723a1d77
...
...
@@ -21,6 +21,9 @@
#include <linux/un.h>
#include <linux/workqueue.h>
#include <linux/mutex.h>
#include <linux/fs.h>
#include <linux/mount.h>
#include <linux/file.h>
#include <asm/uaccess.h>
#include <asm/switch_to.h>
...
...
@@ -118,90 +121,38 @@ void mconsole_log(struct mc_request *req)
mconsole_reply
(
req
,
""
,
0
,
0
);
}
/* This is a more convoluted version of mconsole_proc, which has some stability
* problems; however, we need it fixed, because it is expected that UML users
* mount HPPFS instead of procfs on /proc. And we want mconsole_proc to still
* show the real procfs content, not the ones from hppfs.*/
#if 0
void
mconsole_proc
(
struct
mc_request
*
req
)
{
struct
vfsmount
*
mnt
=
current
->
nsproxy
->
pid_ns
->
proc_mnt
;
struct file *file;
int n;
char *ptr = req->request.data, *buf;
mm_segment_t old_fs = get_fs();
ptr += strlen("proc");
ptr = skip_spaces(ptr);
file = file_open_root(mnt->mnt_root, mnt, ptr, O_RDONLY);
if (IS_ERR(file)) {
mconsole_reply(req, "Failed to open file", 1, 0);
goto out;
}
buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (buf == NULL) {
mconsole_reply(req, "Failed to allocate buffer", 1, 0);
goto out_fput;
}
if (file->f_op->read) {
do {
loff_t pos;
set_fs(KERNEL_DS);
n = vfs_read(file, buf, PAGE_SIZE - 1, &pos);
file_pos_write(file, pos);
set_fs(old_fs);
if (n >= 0) {
buf[n] = '\0';
mconsole_reply(req, buf, 0, (n > 0));
}
else {
mconsole_reply(req, "Read of file failed",
1, 0);
goto out_free;
}
} while (n > 0);
}
else mconsole_reply(req, "", 0, 0);
out_free:
kfree(buf);
out_fput:
fput(file);
out: ;
}
#endif
void
mconsole_proc
(
struct
mc_request
*
req
)
{
char
path
[
64
];
char
*
buf
;
int
len
;
int
fd
;
struct
file
*
file
;
int
first_chunk
=
1
;
char
*
ptr
=
req
->
request
.
data
;
ptr
+=
strlen
(
"proc"
);
ptr
=
skip_spaces
(
ptr
);
snprintf
(
path
,
sizeof
(
path
),
"/proc/%s"
,
ptr
);
f
d
=
sys_open
(
path
,
0
,
0
);
if
(
fd
<
0
)
{
f
ile
=
file_open_root
(
mnt
->
mnt_root
,
mnt
,
ptr
,
O_RDONLY
);
if
(
IS_ERR
(
file
)
)
{
mconsole_reply
(
req
,
"Failed to open file"
,
1
,
0
);
printk
(
KERN_ERR
"open
%s: %d
\n
"
,
path
,
fd
);
printk
(
KERN_ERR
"open
/proc/%s: %ld
\n
"
,
ptr
,
PTR_ERR
(
file
)
);
goto
out
;
}
buf
=
kmalloc
(
PAGE_SIZE
,
GFP_KERNEL
);
if
(
buf
==
NULL
)
{
mconsole_reply
(
req
,
"Failed to allocate buffer"
,
1
,
0
);
goto
out_
close
;
goto
out_
fput
;
}
for
(;;)
{
len
=
sys_read
(
fd
,
buf
,
PAGE_SIZE
-
1
);
do
{
loff_t
pos
;
mm_segment_t
old_fs
=
get_fs
();
set_fs
(
KERNEL_DS
);
len
=
vfs_read
(
file
,
buf
,
PAGE_SIZE
-
1
,
&
pos
);
set_fs
(
old_fs
);
file
->
f_pos
=
pos
;
if
(
len
<
0
)
{
mconsole_reply
(
req
,
"Read of file failed"
,
1
,
0
);
goto
out_free
;
...
...
@@ -211,22 +162,14 @@ void mconsole_proc(struct mc_request *req)
mconsole_reply
(
req
,
"
\n
"
,
0
,
1
);
first_chunk
=
0
;
}
if
(
len
==
PAGE_SIZE
-
1
)
{
buf
[
len
]
=
'\0'
;
mconsole_reply
(
req
,
buf
,
0
,
1
);
}
else
{
buf
[
len
]
=
'\0'
;
mconsole_reply
(
req
,
buf
,
0
,
0
);
break
;
}
}
buf
[
len
]
=
'\0'
;
mconsole_reply
(
req
,
buf
,
0
,
(
len
>
0
));
}
while
(
len
>
0
);
out_free:
kfree
(
buf
);
out_close:
sys_close
(
fd
);
out:
/* nothing */
;
out_fput:
fput
(
file
);
out:
;
}
#define UML_MCONSOLE_HELPTEXT \
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录