fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / arch / um / drivers / mconsole_kern.c
index b414522..96f0189 100644 (file)
@@ -56,7 +56,7 @@ static struct notifier_block reboot_notifier = {
 
 static LIST_HEAD(mc_requests);
 
-static void mc_work_proc(void *unused)
+static void mc_work_proc(struct work_struct *unused)
 {
        struct mconsole_entry *req;
        unsigned long flags;
@@ -72,15 +72,14 @@ static void mc_work_proc(void *unused)
        }
 }
 
-static DECLARE_WORK(mconsole_work, mc_work_proc, NULL);
+static DECLARE_WORK(mconsole_work, mc_work_proc);
 
-static irqreturn_t mconsole_interrupt(int irq, void *dev_id,
-                                     struct pt_regs *regs)
+static irqreturn_t mconsole_interrupt(int irq, void *dev_id)
 {
        /* long to avoid size mismatch warnings from gcc */
        long fd;
        struct mconsole_entry *new;
-       struct mc_request req;
+       static struct mc_request req;   /* that's OK */
 
        fd = (long) dev_id;
        while (mconsole_get_request(fd, &req)){
@@ -92,6 +91,7 @@ static irqreturn_t mconsole_interrupt(int irq, void *dev_id,
                                mconsole_reply(&req, "Out of memory", 1, 0);
                        else {
                                new->request = req;
+                               new->request.regs = get_irq_regs()->regs;
                                list_add(&new->list, &mc_requests);
                        }
                }
@@ -106,9 +106,9 @@ void mconsole_version(struct mc_request *req)
 {
        char version[256];
 
-       sprintf(version, "%s %s %s %s %s", system_utsname.sysname,
-               system_utsname.nodename, system_utsname.release,
-               system_utsname.version, system_utsname.machine);
+       sprintf(version, "%s %s %s %s %s", utsname()->sysname,
+               utsname()->nodename, utsname()->release,
+               utsname()->version, utsname()->machine);
        mconsole_reply(req, version, 0, 0);
 }
 
@@ -315,9 +315,21 @@ void mconsole_stop(struct mc_request *req)
 {
        deactivate_fd(req->originating_fd, MCONSOLE_IRQ);
        os_set_fd_block(req->originating_fd, 1);
-       mconsole_reply(req, "", 0, 0);
-       while(mconsole_get_request(req->originating_fd, req)){
-               if(req->cmd->handler == mconsole_go) break;
+       mconsole_reply(req, "stopped", 0, 0);
+       while (mconsole_get_request(req->originating_fd, req)) {
+               if (req->cmd->handler == mconsole_go)
+                       break;
+               if (req->cmd->handler == mconsole_stop) {
+                       mconsole_reply(req, "Already stopped", 1, 0);
+                       continue;
+               }
+               if (req->cmd->handler == mconsole_sysrq) {
+                       struct pt_regs *old_regs;
+                       old_regs = set_irq_regs((struct pt_regs *)&req->regs);
+                       mconsole_sysrq(req);
+                       set_irq_regs(old_regs);
+                       continue;
+               }
                (*req->cmd->handler)(req);
        }
        os_set_fd_block(req->originating_fd, 0);
@@ -497,7 +509,7 @@ static void mconsole_get_config(int (*get_config)(char *, char *, int,
        }
 
        error = NULL;
-       size = sizeof(default_buf)/sizeof(default_buf[0]);
+       size = ARRAY_SIZE(default_buf);
        buf = default_buf;
 
        while(1){
@@ -598,6 +610,11 @@ out:
        mconsole_reply(req, err_msg, err, 0);
 }
 
+struct mconsole_output {
+       struct list_head list;
+       struct mc_request *req;
+};
+
 static DEFINE_SPINLOCK(console_lock);
 static LIST_HEAD(clients);
 static char console_buf[MCONSOLE_MAX_DATA];
@@ -622,10 +639,10 @@ static void console_write(struct console *console, const char *string,
                        return;
 
                list_for_each(ele, &clients){
-                       struct mconsole_entry *entry;
+                       struct mconsole_output *entry;
 
-                       entry = list_entry(ele, struct mconsole_entry, list);
-                       mconsole_reply_len(&entry->request, console_buf,
+                       entry = list_entry(ele, struct mconsole_output, list);
+                       mconsole_reply_len(entry->req, console_buf,
                                           console_index, 0, 1);
                }
 
@@ -649,10 +666,10 @@ late_initcall(mc_add_console);
 static void with_console(struct mc_request *req, void (*proc)(void *),
                         void *arg)
 {
-       struct mconsole_entry entry;
+       struct mconsole_output entry;
        unsigned long flags;
 
-       entry.request = *req;
+       entry.req = req;
        list_add(&entry.list, &clients);
        spin_lock_irqsave(&console_lock, flags);
 
@@ -669,8 +686,7 @@ static void with_console(struct mc_request *req, void (*proc)(void *),
 static void sysrq_proc(void *arg)
 {
        char *op = arg;
-
-       handle_sysrq(*op, &current->thread.regs, NULL);
+       handle_sysrq(*op, NULL);
 }
 
 void mconsole_sysrq(struct mc_request *req)