Commit 76313c70 authored by Eric W. Biederman's avatar Eric W. Biederman

uml: Create a private mount of proc for mconsole

The mconsole code only ever accesses proc for the initial pid
namespace.  Instead of depending upon the proc_mnt which is
for proc_flush_task have uml create it's own mount of proc
instead.

This allows proc_flush_task to evolve and remove the
need for having a proc_mnt to do it's job.

Cc: Jeff Dike <jdike@addtoit.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
parent af1abab9
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#include "mconsole_kern.h" #include "mconsole_kern.h"
#include <os.h> #include <os.h>
static struct vfsmount *proc_mnt = NULL;
static int do_unlink_socket(struct notifier_block *notifier, static int do_unlink_socket(struct notifier_block *notifier,
unsigned long what, void *data) unsigned long what, void *data)
{ {
...@@ -123,7 +125,7 @@ void mconsole_log(struct mc_request *req) ...@@ -123,7 +125,7 @@ void mconsole_log(struct mc_request *req)
void mconsole_proc(struct mc_request *req) void mconsole_proc(struct mc_request *req)
{ {
struct vfsmount *mnt = init_pid_ns.proc_mnt; struct vfsmount *mnt = proc_mnt;
char *buf; char *buf;
int len; int len;
struct file *file; struct file *file;
...@@ -134,6 +136,10 @@ void mconsole_proc(struct mc_request *req) ...@@ -134,6 +136,10 @@ void mconsole_proc(struct mc_request *req)
ptr += strlen("proc"); ptr += strlen("proc");
ptr = skip_spaces(ptr); ptr = skip_spaces(ptr);
if (!mnt) {
mconsole_reply(req, "Proc not available", 1, 0);
goto out;
}
file = file_open_root(mnt->mnt_root, mnt, ptr, O_RDONLY, 0); file = file_open_root(mnt->mnt_root, mnt, ptr, O_RDONLY, 0);
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);
...@@ -683,6 +689,24 @@ void mconsole_stack(struct mc_request *req) ...@@ -683,6 +689,24 @@ void mconsole_stack(struct mc_request *req)
with_console(req, stack_proc, to); with_console(req, stack_proc, to);
} }
static int __init mount_proc(void)
{
struct file_system_type *proc_fs_type;
struct vfsmount *mnt;
proc_fs_type = get_fs_type("proc");
if (!proc_fs_type)
return -ENODEV;
mnt = kern_mount(proc_fs_type);
put_filesystem(proc_fs_type);
if (IS_ERR(mnt))
return PTR_ERR(mnt);
proc_mnt = mnt;
return 0;
}
/* /*
* Changed by mconsole_setup, which is __setup, and called before SMP is * Changed by mconsole_setup, which is __setup, and called before SMP is
* active. * active.
...@@ -696,6 +720,8 @@ static int __init mconsole_init(void) ...@@ -696,6 +720,8 @@ static int __init mconsole_init(void)
int err; int err;
char file[UNIX_PATH_MAX]; char file[UNIX_PATH_MAX];
mount_proc();
if (umid_file_name("mconsole", file, sizeof(file))) if (umid_file_name("mconsole", file, sizeof(file)))
return -1; return -1;
snprintf(mconsole_socket_name, sizeof(file), "%s", file); snprintf(mconsole_socket_name, sizeof(file), "%s", file);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment