* [PATCH] UML: kraxel's mconsole_proc rewrite
@ 2004-10-20 2:35 Chris Wedgwood
2004-10-25 12:26 ` Gerd Knorr
0 siblings, 1 reply; 2+ messages in thread
From: Chris Wedgwood @ 2004-10-20 2:35 UTC (permalink / raw)
To: LKML; +Cc: Jeff Dike, Gerd Knorr
This is an update/resync of kraxel's mconsole_proc rewrite from about
two months ago and IMO it should be merged as-is.
I didn't originally write this, so no Signed-off-by... I'd love to
see his re-post with that though.
diff -Nru a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
--- a/arch/um/drivers/mconsole_kern.c 2004-10-19 17:48:18 -07:00
+++ b/arch/um/drivers/mconsole_kern.c 2004-10-19 17:48:18 -07:00
@@ -19,6 +19,7 @@
#include "linux/fs.h"
#include "linux/namei.h"
#include "linux/proc_fs.h"
+#include "linux/syscalls.h"
#include "asm/irq.h"
#include "asm/uaccess.h"
#include "user_util.h"
@@ -120,77 +121,50 @@
void mconsole_proc(struct mc_request *req)
{
- struct nameidata nd;
- struct file_system_type *proc;
- struct super_block *super;
- struct file *file;
- int n, err;
- char *ptr = req->request.data, *buf;
+ char path[64];
+ char *buf;
+ int len;
+ int fd;
+ char *ptr = req->request.data;
ptr += strlen("proc");
while(isspace(*ptr)) ptr++;
+ snprintf(path, sizeof(path), "/proc/%s", ptr);
- proc = get_fs_type("proc");
- if(proc == NULL){
- mconsole_reply(req, "procfs not registered", 1, 0);
- goto out;
- }
-
- super = (*proc->get_sb)(proc, 0, NULL, NULL);
- put_filesystem(proc);
- if(super == NULL){
- mconsole_reply(req, "Failed to get procfs superblock", 1, 0);
- goto out;
- }
- up_write(&super->s_umount);
-
- nd.dentry = super->s_root;
- nd.mnt = NULL;
- nd.flags = O_RDONLY + 1;
- nd.last_type = LAST_ROOT;
-
- err = link_path_walk(ptr, &nd);
- if(err){
- mconsole_reply(req, "Failed to look up file", 1, 0);
- goto out_kill;
- }
-
- file = dentry_open(nd.dentry, nd.mnt, O_RDONLY);
- if(IS_ERR(file)){
+ fd = sys_open(path, 0, 0);
+ if (fd < 0) {
mconsole_reply(req, "Failed to open file", 1, 0);
- goto out_kill;
+ printk("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_fput;
+ goto out_close;
}
- if((file->f_op != NULL) && (file->f_op->read != NULL)){
- do {
- n = (*file->f_op->read)(file, buf, PAGE_SIZE - 1,
- &file->f_pos);
- 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);
+ for (;;) {
+ len = sys_read(fd, buf, PAGE_SIZE-1);
+ if (len < 0) {
+ mconsole_reply(req, "Read of file failed", 1, 0);
+ goto out_free;
+ } else 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;
+ }
}
- else mconsole_reply(req, "", 0, 0);
out_free:
kfree(buf);
- out_fput:
- fput(file);
- out_kill:
- deactivate_super(super);
- out: ;
+ out_close:
+ sys_close(fd);
+ out:
+ /* nothing */;
}
#define UML_MCONSOLE_HELPTEXT \
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] UML: kraxel's mconsole_proc rewrite
2004-10-20 2:35 [PATCH] UML: kraxel's mconsole_proc rewrite Chris Wedgwood
@ 2004-10-25 12:26 ` Gerd Knorr
0 siblings, 0 replies; 2+ messages in thread
From: Gerd Knorr @ 2004-10-25 12:26 UTC (permalink / raw)
To: Chris Wedgwood; +Cc: LKML, Jeff Dike
On Tue, Oct 19, 2004 at 07:35:58PM -0700, Chris Wedgwood wrote:
> This is an update/resync of kraxel's mconsole_proc rewrite from about
> two months ago and IMO it should be merged as-is.
Jeff didn't like it because the original version also worked without
/proc being mounted. Well, tree times, then it crashed. I don't have
that in-deep knowledge of vfs stuff, but I somehow feel that the attempt
to access /proc without mounting it is the reason for the crash. I
don't feel like bypassing the vfs layer so I didn't attempt to make it
wotk like the original version.
> I didn't originally write this, so no Signed-off-by... I'd love to
> see his re-post with that though.
http://www.suse.de/~kraxel/uml/patches/2.6.9/ has my current patchset
with some (short) comments what the patches do. The mconsole fix is
there as well, and will be there until either someone comes up with some
better fix (or it gets merged ;)
Gerd
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2004-10-25 12:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-20 2:35 [PATCH] UML: kraxel's mconsole_proc rewrite Chris Wedgwood
2004-10-25 12:26 ` Gerd Knorr
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).