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
723a1d77
Commit
723a1d77
authored
Aug 19, 2012
by
Al Viro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
um: resurrect the right variant of mconsole_proc()
Signed-off-by:
Al Viro
<
viro@zeniv.linux.org.uk
>
parent
483ce1d4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
78 deletions
+21
-78
arch/um/drivers/mconsole_kern.c
arch/um/drivers/mconsole_kern.c
+21
-78
No files found.
arch/um/drivers/mconsole_kern.c
View file @
723a1d77
...
@@ -21,6 +21,9 @@
...
@@ -21,6 +21,9 @@
#include <linux/un.h>
#include <linux/un.h>
#include <linux/workqueue.h>
#include <linux/workqueue.h>
#include <linux/mutex.h>
#include <linux/mutex.h>
#include <linux/fs.h>
#include <linux/mount.h>
#include <linux/file.h>
#include <asm/uaccess.h>
#include <asm/uaccess.h>
#include <asm/switch_to.h>
#include <asm/switch_to.h>
...
@@ -118,18 +121,14 @@ void mconsole_log(struct mc_request *req)
...
@@ -118,18 +121,14 @@ void mconsole_log(struct mc_request *req)
mconsole_reply
(
req
,
""
,
0
,
0
);
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
)
void
mconsole_proc
(
struct
mc_request
*
req
)
{
{
struct
vfsmount
*
mnt
=
current
->
nsproxy
->
pid_ns
->
proc_mnt
;
struct
vfsmount
*
mnt
=
current
->
nsproxy
->
pid_ns
->
proc_mnt
;
char
*
buf
;
int
len
;
struct
file
*
file
;
struct
file
*
file
;
int n;
int
first_chunk
=
1
;
char *ptr = req->request.data, *buf;
char
*
ptr
=
req
->
request
.
data
;
mm_segment_t old_fs = get_fs();
ptr
+=
strlen
(
"proc"
);
ptr
+=
strlen
(
"proc"
);
ptr
=
skip_spaces
(
ptr
);
ptr
=
skip_spaces
(
ptr
);
...
@@ -137,6 +136,7 @@ void mconsole_proc(struct mc_request *req)
...
@@ -137,6 +136,7 @@ void mconsole_proc(struct mc_request *req)
file
=
file_open_root
(
mnt
->
mnt_root
,
mnt
,
ptr
,
O_RDONLY
);
file
=
file_open_root
(
mnt
->
mnt_root
,
mnt
,
ptr
,
O_RDONLY
);
if
(
IS_ERR
(
file
))
{
if
(
IS_ERR
(
file
))
{
mconsole_reply
(
req
,
"Failed to open file"
,
1
,
0
);
mconsole_reply
(
req
,
"Failed to open file"
,
1
,
0
);
printk
(
KERN_ERR
"open /proc/%s: %ld
\n
"
,
ptr
,
PTR_ERR
(
file
));
goto
out
;
goto
out
;
}
}
...
@@ -146,62 +146,13 @@ void mconsole_proc(struct mc_request *req)
...
@@ -146,62 +146,13 @@ void mconsole_proc(struct mc_request *req)
goto
out_fput
;
goto
out_fput
;
}
}
if (file->f_op->read) {
do
{
do
{
loff_t
pos
;
loff_t
pos
;
mm_segment_t
old_fs
=
get_fs
();
set_fs
(
KERNEL_DS
);
set_fs
(
KERNEL_DS
);
n = vfs_read(file, buf, PAGE_SIZE - 1, &pos);
len
=
vfs_read
(
file
,
buf
,
PAGE_SIZE
-
1
,
&
pos
);
file_pos_write(file, pos);
set_fs
(
old_fs
);
set_fs
(
old_fs
);
if (n >= 0) {
file
->
f_pos
=
pos
;
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
;
int
first_chunk
=
1
;
char
*
ptr
=
req
->
request
.
data
;
ptr
+=
strlen
(
"proc"
);
ptr
=
skip_spaces
(
ptr
);
snprintf
(
path
,
sizeof
(
path
),
"/proc/%s"
,
ptr
);
fd
=
sys_open
(
path
,
0
,
0
);
if
(
fd
<
0
)
{
mconsole_reply
(
req
,
"Failed to open file"
,
1
,
0
);
printk
(
KERN_ERR
"open %s: %d
\n
"
,
path
,
fd
);
goto
out
;
}
buf
=
kmalloc
(
PAGE_SIZE
,
GFP_KERNEL
);
if
(
buf
==
NULL
)
{
mconsole_reply
(
req
,
"Failed to allocate buffer"
,
1
,
0
);
goto
out_close
;
}
for
(;;)
{
len
=
sys_read
(
fd
,
buf
,
PAGE_SIZE
-
1
);
if
(
len
<
0
)
{
if
(
len
<
0
)
{
mconsole_reply
(
req
,
"Read of file failed"
,
1
,
0
);
mconsole_reply
(
req
,
"Read of file failed"
,
1
,
0
);
goto
out_free
;
goto
out_free
;
...
@@ -211,22 +162,14 @@ void mconsole_proc(struct mc_request *req)
...
@@ -211,22 +162,14 @@ void mconsole_proc(struct mc_request *req)
mconsole_reply
(
req
,
"
\n
"
,
0
,
1
);
mconsole_reply
(
req
,
"
\n
"
,
0
,
1
);
first_chunk
=
0
;
first_chunk
=
0
;
}
}
if
(
len
==
PAGE_SIZE
-
1
)
{
buf
[
len
]
=
'\0'
;
mconsole_reply
(
req
,
buf
,
0
,
1
);
}
else
{
buf
[
len
]
=
'\0'
;
buf
[
len
]
=
'\0'
;
mconsole_reply
(
req
,
buf
,
0
,
0
);
mconsole_reply
(
req
,
buf
,
0
,
(
len
>
0
));
break
;
}
while
(
len
>
0
);
}
}
out_free:
out_free:
kfree
(
buf
);
kfree
(
buf
);
out_close:
out_fput:
sys_close
(
fd
);
fput
(
file
);
out:
out:
;
/* nothing */
;
}
}
#define UML_MCONSOLE_HELPTEXT \
#define UML_MCONSOLE_HELPTEXT \
...
...
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