]> git.hungrycats.org Git - linux/commitdiff
[PATCH] uml: cleaning up
authorJeff Dike <jdike@addtoit.com>
Fri, 17 Sep 2004 05:11:41 +0000 (22:11 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Fri, 17 Sep 2004 05:11:41 +0000 (22:11 -0700)
This patch is a whole lot of "obviously won't break anything" changes,
including
renaming the UML console functions more consistently
notes to myself
code movement
making some functions static
error path cleanup
printk fixes

Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
13 files changed:
arch/um/drivers/stdio_console.c
arch/um/drivers/xterm.c
arch/um/kernel/process.c
arch/um/kernel/sigio_kern.c
arch/um/kernel/skas/process.c
arch/um/kernel/skas/process_kern.c
arch/um/kernel/tt/process_kern.c
arch/um/kernel/tt/tracer.c
arch/um/kernel/umid.c
arch/um/kernel/user_util.c
arch/um/os-Linux/file.c
arch/um/os-Linux/process.c
arch/um/sys-i386/ptrace_user.c

index d5df64e7b2113639c0889703c4cf00b2d8e82ab7..54e6a57c897381375b1cc4feda4240d4730b0a14 100644 (file)
@@ -191,7 +191,7 @@ int stdio_init(void)
 
 late_initcall(stdio_init);
 
-static void console_write(struct console *console, const char *string, 
+static void uml_console_write(struct console *console, const char *string,
                          unsigned len)
 {
        struct line *line = &vts[console->index];
@@ -203,22 +203,22 @@ static void console_write(struct console *console, const char *string,
                up(&line->sem);
 }
 
-static struct tty_driver *um_console_device(struct console *c, int *index)
+static struct tty_driver *uml_console_device(struct console *c, int *index)
 {
        *index = c->index;
        return console_driver;
 }
 
-static int console_setup(struct console *co, char *options)
+static int uml_console_setup(struct console *co, char *options)
 {
        return(0);
 }
 
 static struct console stdiocons = {
        name:           "tty",
-       write:          console_write,
-       device:         um_console_device,
-       setup:          console_setup,
+       write:          uml_console_write,
+       device:         uml_console_device,
+       setup:          uml_console_setup,
        flags:          CON_PRINTBUFFER,
        index:          -1,
 };
index dccdf3e90f9bd457c6336c0f586d2614863f3621..f429a35dbba6d12900a69d87ed84309d3b638cd9 100644 (file)
@@ -83,6 +83,7 @@ __uml_setup("xterm=", xterm_setup,
 "    are 'xterm=gnome-terminal,-t,-x'.\n\n"
 );
 
+/* XXX This badly needs some cleaning up in the error paths */
 int xterm_open(int input, int output, int primary, void *d, char **dev_out)
 {
        struct xterm_chan *data = d;
index da12446f930abf4ba9dd794344f195cd89b1d396..4db4d89b85d6c8515f0c028cbb0b3b8c740fb90a 100644 (file)
@@ -139,16 +139,6 @@ int start_fork_tramp(void *thread_arg, unsigned long temp_stack,
        return(arg.pid);
 }
 
-void suspend_new_thread(int fd)
-{
-       char c;
-
-       os_stop_process(os_getpid());
-
-       if(os_read_file(fd, &c, sizeof(c)) != sizeof(c))
-               panic("read failed in suspend_new_thread");
-}
-
 static int ptrace_child(void *arg)
 {
        int pid = os_getpid();
index 92658eaa4e4ddbf44c04d25ed9df98b0872dca94..fbffae41545990eac625beedc13022f17f52b539 100644 (file)
@@ -16,7 +16,7 @@
 /* Protected by sigio_lock() called from write_sigio_workaround */
 static int sigio_irq_fd = -1;
 
-irqreturn_t sigio_interrupt(int irq, void *data, struct pt_regs *unused)
+static irqreturn_t sigio_interrupt(int irq, void *data, struct pt_regs *unused)
 {
        read_sigio_fd(sigio_irq_fd);
        reactivate_fd(sigio_irq_fd, SIGIO_WRITE_IRQ);
@@ -25,10 +25,14 @@ irqreturn_t sigio_interrupt(int irq, void *data, struct pt_regs *unused)
 
 int write_sigio_irq(int fd)
 {
-       if(um_request_irq(SIGIO_WRITE_IRQ, fd, IRQ_READ, sigio_interrupt,
+       int err;
+
+       err = um_request_irq(SIGIO_WRITE_IRQ, fd, IRQ_READ, sigio_interrupt,
                          SA_INTERRUPT | SA_SAMPLE_RANDOM, "write sigio", 
-                         NULL)){
-               printk("write_sigio_irq : um_request_irq failed\n");
+                            NULL);
+       if(err){
+               printk("write_sigio_irq : um_request_irq failed, err = %d\n",
+                      err);
                return(-1);
        }
        sigio_irq_fd = fd;
index ff5912552272be1208a39581ccdb3e14538f0379..cb748f85daceb9338ee367bcbc6363d34676c25a 100644 (file)
@@ -375,28 +375,6 @@ void reboot_skas(void)
        siglongjmp(initial_jmpbuf, 4);
 }
 
-int new_mm(int from)
-{
-       struct proc_mm_op copy;
-       int n, fd = os_open_file("/proc/mm",
-                                of_cloexec(of_write(OPENFLAGS())), 0);
-
-       if(fd < 0)
-               return(fd);
-
-       if(from != -1){
-               copy = ((struct proc_mm_op) { .op       = MM_COPY_SEGMENTS,
-                                             .u        = 
-                                             { .copy_segments  = from } } );
-               n = os_write_file(fd, &copy, sizeof(copy));
-               if(n != sizeof(copy)) 
-                       printk("new_mm : /proc/mm copy_segments failed, "
-                              "err = %d\n", -n);
-       }
-
-       return(fd);
-}
-
 void switch_mm_skas(int mm_fd)
 {
        int err;
index a5aecf38be026277cb581d48f30987f8e73d4e99..5418f08628893ba3557e316091170e5d9e5a074a 100644 (file)
@@ -22,6 +22,7 @@
 #include "frame.h"
 #include "kern.h"
 #include "mode.h"
+#include "proc_mm.h"
 
 static atomic_t using_sysemu;
 int sysemu_supported;
@@ -196,6 +197,28 @@ int copy_thread_skas(int nr, unsigned long clone_flags, unsigned long sp,
        return(0);
 }
 
+int new_mm(int from)
+{
+       struct proc_mm_op copy;
+       int n, fd;
+
+       fd = os_open_file("/proc/mm", of_cloexec(of_write(OPENFLAGS())), 0);
+       if(fd < 0)
+               return(fd);
+
+       if(from != -1){
+               copy = ((struct proc_mm_op) { .op       = MM_COPY_SEGMENTS,
+                                             .u        =
+                                             { .copy_segments  = from } } );
+               n = os_write_file(fd, &copy, sizeof(copy));
+               if(n != sizeof(copy))
+                       printk("new_mm : /proc/mm copy_segments failed, "
+                              "err = %d\n", -n);
+       }
+
+       return(fd);
+}
+
 void init_idle_skas(void)
 {
        cpu_tasks[current_thread->cpu].pid = os_getpid();
index 129dcd4d2245813704e656d89602d70fd8bfd644..e4e8cbf2a9e94041e2c1b5b12d8038ff2a348d16 100644 (file)
@@ -128,6 +128,17 @@ void exit_thread_tt(void)
        os_close_file(current->thread.mode.tt.switch_pipe[1]);
 }
 
+void suspend_new_thread(int fd)
+{
+       int err;
+       char c;
+
+       os_stop_process(os_getpid());
+       err = os_read_file(fd, &c, sizeof(c));
+       if(err != sizeof(c))
+               panic("read failed in suspend_new_thread, err = %d", -err);
+}
+
 void schedule_tail(task_t *prev);
 
 static void new_thread_handler(int sig)
@@ -162,6 +173,12 @@ static void new_thread_handler(int sig)
        local_irq_enable();
        if(!run_kernel_thread(fn, arg, &current->thread.exec_buf))
                do_exit(0);
+
+       /* XXX No set_user_mode here because a newly execed process will
+        * immediately segfault on its non-existent IP, coming straight back
+        * to the signal handler, which will call set_user_mode on its way
+        * out.  This should probably change since it's confusing.
+        */
 }
 
 static int new_thread_proc(void *stack)
index 1b547741244a0ce4f1debda9fffc8cd35d540086..deef43bb558d4ab5f9af1c2b3abf4c9acc96e9af 100644 (file)
@@ -330,7 +330,8 @@ int tracer(int (*init_proc)(void *), void *sp)
                                        continue;
                                }
                                tracing = 0;
-                               if(do_syscall(task, pid)) sig = SIGUSR2;
+                               if(do_syscall(task, pid))
+                                       sig = SIGUSR2;
                                else clear_singlestep(task);
                                break;
                        case SIGPROF:
index a03eb1561f195b44d54c17f1045848ea79716334..78c8dc45c61eaf62a0ebef5bd74d9d5bf27b076a 100644 (file)
@@ -43,7 +43,7 @@ static int __init set_umid(char *name, int is_random,
        }
 
        if(strlen(name) > UMID_LEN - 1)
-               (*printer)("Unique machine name is being truncated to %s "
+               (*printer)("Unique machine name is being truncated to %d "
                           "characters\n", UMID_LEN);
        strlcpy(umid, name, sizeof(umid));
 
@@ -199,17 +199,20 @@ int not_dead_yet(char *dir)
 static int __init set_uml_dir(char *name, int *add)
 {
        if((strlen(name) > 0) && (name[strlen(name) - 1] != '/')){
-               uml_dir = malloc(strlen(name) + 1);
+               uml_dir = malloc(strlen(name) + 2);
                if(uml_dir == NULL){
                        printf("Failed to malloc uml_dir - error = %d\n",
                               errno);
                        uml_dir = name;
+                       /* Return 0 here because do_initcalls doesn't look at
+                        * the return value.
+                        */
                        return(0);
                }
                sprintf(uml_dir, "%s/", name);
        }
        else uml_dir = name;
-       return 0;
+       return(0);
 }
 
 static int __init make_uml_dir(void)
index 544ae54ce77d9cdd21c40eb4b861fc43553950d8..a3b17b05d536bff980639cc62e0f87970771d3df 100644 (file)
@@ -88,11 +88,11 @@ int wait_for_stop(int pid, int sig, int cont_type, void *relay)
                                       errno);
                        }
                        else if(WIFEXITED(status)) 
-                               printk("process exited with status %d\n", 
-                                      WEXITSTATUS(status));
+                               printk("process %d exited with status %d\n",
+                                      pid, WEXITSTATUS(status));
                        else if(WIFSIGNALED(status))
-                               printk("process exited with signal %d\n", 
-                                      WTERMSIG(status));
+                               printk("process %d exited with signal %d\n",
+                                      pid, WTERMSIG(status));
                        else if((WSTOPSIG(status) == SIGVTALRM) ||
                                (WSTOPSIG(status) == SIGALRM) ||
                                (WSTOPSIG(status) == SIGIO) ||
@@ -108,8 +108,8 @@ int wait_for_stop(int pid, int sig, int cont_type, void *relay)
                                ptrace(cont_type, pid, 0, WSTOPSIG(status));
                                continue;
                        }
-                       else printk("process stopped with signal %d\n", 
-                                   WSTOPSIG(status));
+                       else printk("process %d stopped with signal %d\n",
+                                   pid, WSTOPSIG(status));
                        panic("wait_for_stop failed to wait for %d to stop "
                              "with %d\n", pid, sig);
                }
index 8d5710cd42ed010a7b9eda2d97076f48607cd872..514ab984cfb3067ce6f4323db33a988381db27c2 100644 (file)
@@ -187,7 +187,8 @@ int os_sigio_async(int master, int slave)
 
        if((fcntl(master, F_SETFL, flags | O_NONBLOCK | O_ASYNC) < 0) ||
           (fcntl(master, F_SETOWN, os_getpid()) < 0)){
-               printk("fcntl F_SETFL or F_SETOWN failed, errno = %d\n", errno);
+               printk("fcntl F_SETFL or F_SETOWN failed, errno = %d\n",
+                      errno);
                return(-errno);
        }
 
index 2cbe598b9df2864250427ec691b542903e1d735d..57deb70ac26edf5e1a9dbc5b44f03b2c0079a279 100644 (file)
@@ -42,9 +42,9 @@ unsigned long os_process_pc(int pid)
        }
        os_close_file(fd);
        pc = ARBITRARY_ADDR;
-       if(sscanf(buf, "%*d " COMM_SCANF " %*c %*d %*d %*d %*d %*d %*d %*d %*d "
+       if(sscanf(buf, "%*d " COMM_SCANF " %*c %*d %*d %*d %*d %*d %*d %*d "
                  "%*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d "
-                 "%*d %*d %*d %*d %lu", &pc) != 1){
+                 "%*d %*d %*d %*d %*d %lu", &pc) != 1){
                printk("os_process_pc - couldn't find pc in '%s'\n", buf);
        }
        return(pc);
index c6f8d50af5955bfed6a16268a7eb32915942816b..b1021e82bce4a652465b5e755323d1771dd3dead 100644 (file)
@@ -42,7 +42,8 @@ static void write_debugregs(int pid, unsigned long *regs)
                if(ptrace(PTRACE_POKEUSER, pid, &dummy->u_debugreg[i],
                          regs[i]) < 0)
                        printk("write_debugregs - ptrace failed on "
-                              "register %d, errno = %d\n", errno);
+                              "register %d, value = 0x%x, errno = %d\n", i,
+                              regs[i], errno);
        }
 }