# This is a large set of small fixes and other changes: # unsigned long -> __u32 conversions in the cow header to protect against # 64-bit problems # Cleanup and simplification of the mconsole interrupt handler. # Fixing of a bug with mconsole log. # Moving the sysrq reply to before the actual sysrq so that a reboot request # will be replied to. # Added ethtool support to the network drivers. # Fixed a file descriptor leak in the network driver when changing an IP # address. # The port channel now sets SO_REUSEADDR. # Added some initcall and exitcall definitions to arch/um/include/init.h # so that they can be used from userspace code. # Fixed the error handling in run_helper. # Added some symbols to ksyms.c. # Added the log() facility to mem_user.c. # Fixed a problem with recursive segfaults not being handled correctly. # Added a bunch of missing jmpbuf -> sigjmp_buf changes. # Added a reminder to fix a kernel stack size assumption. # Made sigio_interrupt static. # Added some EINTR protection to the sigio initialization code. # tty_log_fd and umid aren't added to the command line any more. # Bumped the physical memory of exec-shield users so they don't lose the # hole in their address space. # A panic now produces a stack trace and sets the exit status to 1. # Fixed some prints. # The timer is now enabled after it is initialized. # sig_handler_common_skas saves and restores is_user properly. # The process status printing code was cleaned up. # Bumped HZ to 100. # Removed the __cmpxchg implementation. # Removed a bogus declaration from asm/bug.h. Index: um/arch/um/drivers/cow_user.c =================================================================== --- um.orig/arch/um/drivers/cow_user.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/drivers/cow_user.c 2004-08-05 22:55:06.000000000 -0400 @@ -27,8 +27,8 @@ #define PATH_LEN_V2 MAXPATHLEN struct cow_header_v2 { - unsigned long magic; - unsigned long version; + __u32 magic; + __u32 version; char backing_file[PATH_LEN_V2]; time_t mtime; __u64 size; Index: um/arch/um/drivers/mconsole_kern.c =================================================================== --- um.orig/arch/um/drivers/mconsole_kern.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/drivers/mconsole_kern.c 2004-08-06 15:01:12.000000000 -0400 @@ -55,18 +55,16 @@ { struct mconsole_entry *req; unsigned long flags; - int done; - do { + while(!list_empty(&mc_requests)){ local_save_flags(flags); req = list_entry(mc_requests.next, struct mconsole_entry, list); list_del(&req->list); - done = list_empty(&mc_requests); local_irq_restore(flags); req->request.cmd->handler(&req->request); kfree(req); - } while(!done); + } } DECLARE_WORK(mconsole_work, mc_work_proc, NULL); @@ -91,7 +89,8 @@ } } } - if(!list_empty(&mc_requests)) schedule_work(&mconsole_work); + if(!list_empty(&mc_requests)) + schedule_work(&mconsole_work); reactivate_fd(fd, MCONSOLE_IRQ); return(IRQ_HANDLED); } @@ -374,8 +373,8 @@ ptr += strlen("sysrq"); while(isspace(*ptr)) ptr++; - handle_sysrq(*ptr, ¤t->thread.regs, NULL); mconsole_reply(req, "", 0, 0); + handle_sysrq(*ptr, ¤t->thread.regs, NULL); } #else void mconsole_sysrq(struct mc_request *req) Index: um/arch/um/drivers/net_kern.c =================================================================== --- um.orig/arch/um/drivers/net_kern.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/drivers/net_kern.c 2004-08-05 22:55:06.000000000 -0400 @@ -19,6 +19,8 @@ #include "linux/inetdevice.h" #include "linux/ctype.h" #include "linux/bootmem.h" +#include "linux/ethtool.h" +#include "asm/uaccess.h" #include "user_util.h" #include "kern_util.h" #include "net_kern.h" @@ -240,7 +242,30 @@ static int uml_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) { - return(-EINVAL); + static const struct ethtool_drvinfo info = { + .cmd = ETHTOOL_GDRVINFO, + .driver = "uml virtual ethernet", + .version = "42", + }; + void *useraddr; + u32 ethcmd; + + switch (cmd) { + case SIOCETHTOOL: + useraddr = ifr->ifr_data; + if (copy_from_user(ðcmd, useraddr, sizeof(ethcmd))) + return -EFAULT; + switch (ethcmd) { + case ETHTOOL_GDRVINFO: + if (copy_to_user(useraddr, &info, sizeof(info))) + return -EFAULT; + return 0; + default: + return -EOPNOTSUPP; + } + default: + return -EINVAL; + } } void uml_net_user_timer_expire(unsigned long _conn) Index: um/arch/um/drivers/net_user.c =================================================================== --- um.orig/arch/um/drivers/net_user.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/drivers/net_user.c 2004-08-05 22:55:06.000000000 -0400 @@ -173,8 +173,9 @@ pe_data.stdout = fds[1]; pid = run_helper(change_pre_exec, &pe_data, argv, NULL); - os_close_file(fds[1]); read_output(fds[0], output, output_len); + os_close_file(fds[0]); + os_close_file(fds[1]); waitpid(pid, NULL, 0); return(pid); } Index: um/arch/um/drivers/port_user.c =================================================================== --- um.orig/arch/um/drivers/port_user.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/drivers/port_user.c 2004-08-05 22:55:06.000000000 -0400 @@ -118,12 +118,18 @@ int port_listen_fd(int port) { struct sockaddr_in addr; - int fd, err; + int fd, err, arg; fd = socket(PF_INET, SOCK_STREAM, 0); if(fd == -1) return(-errno); + arg = 1; + if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &arg, sizeof(arg)) < 0){ + err = -errno; + goto out; + } + addr.sin_family = AF_INET; addr.sin_port = htons(port); addr.sin_addr.s_addr = htonl(INADDR_ANY); Index: um/arch/um/include/init.h =================================================================== --- um.orig/arch/um/include/init.h 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/include/init.h 2004-08-05 22:55:06.000000000 -0400 @@ -100,6 +100,16 @@ #define __uml_postsetup_call __attribute__ ((unused,__section__ (".uml.postsetup.init"))) #define __uml_exit_call __attribute__ ((unused,__section__ (".uml.exitcall.exit"))) +#ifndef __KERNEL__ + +#define __initcall(fn) static initcall_t __initcall_##fn __init_call = fn +#define __exitcall(fn) static exitcall_t __exitcall_##fn __exit_call = fn + +#define __init_call __attribute__ ((unused,__section__ (".initcall.init"))) +#define __exit_call __attribute__ ((unused,__section__ (".exitcall.exit"))) + +#endif + #endif /* _LINUX_UML_INIT_H */ /* Index: um/arch/um/kernel/helper.c =================================================================== --- um.orig/arch/um/kernel/helper.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/kernel/helper.c 2004-08-05 22:55:06.000000000 -0400 @@ -93,24 +93,20 @@ if(n < 0){ printk("run_helper : read on pipe failed, err = %d\n", -n); err = n; - goto out_kill; + os_kill_process(pid, 1); } else if(n != 0){ waitpid(pid, NULL, 0); pid = -errno; } + err = pid; - if(stack_out == NULL) free_stack(stack, 0); - else *stack_out = stack; - return(pid); - - out_kill: - os_kill_process(pid, 1); out_close: os_close_file(fds[0]); - os_close_file(fds[1]); out_free: - free_stack(stack, 0); + if(stack_out == NULL) + free_stack(stack, 0); + else *stack_out = stack; return(err); } Index: um/arch/um/kernel/ksyms.c =================================================================== --- um.orig/arch/um/kernel/ksyms.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/kernel/ksyms.c 2004-08-05 22:55:06.000000000 -0400 @@ -50,11 +50,13 @@ EXPORT_SYMBOL(find_iomem); #ifdef CONFIG_MODE_TT +EXPORT_SYMBOL(strncpy_from_user_tt); EXPORT_SYMBOL(copy_from_user_tt); EXPORT_SYMBOL(copy_to_user_tt); #endif #ifdef CONFIG_MODE_SKAS +EXPORT_SYMBOL(strncpy_from_user_skas); EXPORT_SYMBOL(copy_to_user_skas); EXPORT_SYMBOL(copy_from_user_skas); #endif @@ -85,6 +87,7 @@ EXPORT_SYMBOL(os_create_unix_socket); EXPORT_SYMBOL(os_connect_socket); EXPORT_SYMBOL(os_accept_connection); +EXPORT_SYMBOL(os_ioctl_generic); EXPORT_SYMBOL(os_rcv_fd); EXPORT_SYMBOL(run_helper); EXPORT_SYMBOL(start_thread); Index: um/arch/um/kernel/mem_user.c =================================================================== --- um.orig/arch/um/kernel/mem_user.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/kernel/mem_user.c 2004-08-06 15:01:12.000000000 -0400 @@ -206,6 +206,39 @@ return(0); } +#if 0 +/* Debugging facility for dumping stuff out to the host, avoiding the timing + * problems that come with printf and breakpoints. + * Enable in case of emergency. + */ + +int logging = 1; +int logging_fd = -1; + +int logging_line = 0; +char logging_buf[512]; + +void log(char *fmt, ...) +{ + va_list ap; + struct timeval tv; + struct openflags flags; + + if(logging == 0) return; + if(logging_fd < 0){ + flags = of_create(of_trunc(of_rdwr(OPENFLAGS()))); + logging_fd = os_open_file("log", flags, 0644); + } + gettimeofday(&tv, NULL); + sprintf(logging_buf, "%d\t %u.%u ", logging_line++, tv.tv_sec, + tv.tv_usec); + va_start(ap, fmt); + vsprintf(&logging_buf[strlen(logging_buf)], fmt, ap); + va_end(ap); + write(logging_fd, logging_buf, strlen(logging_buf)); +} +#endif + /* * Overrides for Emacs so that we follow Linus's tabbing style. * Emacs will notice this stuff at the end of the file and automatically Index: um/arch/um/kernel/process.c =================================================================== --- um.orig/arch/um/kernel/process.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/kernel/process.c 2004-08-05 22:55:06.000000000 -0400 @@ -56,11 +56,7 @@ { int flags = altstack ? SA_ONSTACK : 0; - /* NODEFER is set here because SEGV isn't turned back on when the - * handler is ready to receive signals. This causes any segfault - * during a copy_user to kill the process because the fault is blocked. - */ - set_handler(SIGSEGV, (__sighandler_t) sig_handler, flags | SA_NODEFER, + set_handler(SIGSEGV, (__sighandler_t) sig_handler, flags, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); set_handler(SIGTRAP, (__sighandler_t) sig_handler, flags, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); @@ -73,7 +69,7 @@ set_handler(SIGWINCH, (__sighandler_t) sig_handler, flags, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); set_handler(SIGUSR2, (__sighandler_t) sig_handler, - SA_NOMASK | flags, -1); + flags, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); signal(SIGHUP, SIG_IGN); init_irq_signals(altstack); @@ -221,7 +217,7 @@ int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr) { - jmp_buf buf; + sigjmp_buf buf; int n; *jmp_ptr = &buf; Index: um/arch/um/kernel/process_kern.c =================================================================== --- um.orig/arch/um/kernel/process_kern.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/kernel/process_kern.c 2004-08-05 22:55:06.000000000 -0400 @@ -165,6 +165,7 @@ struct pt_regs *regs) { p->thread = (struct thread_struct) INIT_THREAD; + /* XXX Kernel stack size assumption */ p->thread.kernel_stack = (unsigned long) p->thread_info + 2 * PAGE_SIZE; return(CHOOSE_MODE_PROC(copy_thread_tt, copy_thread_skas, nr, Index: um/arch/um/kernel/sigio_kern.c =================================================================== --- um.orig/arch/um/kernel/sigio_kern.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/kernel/sigio_kern.c 2004-08-05 22:55:06.000000000 -0400 @@ -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 @@ int write_sigio_irq(int fd) { - if(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"); + int err; + + err = um_request_irq(SIGIO_WRITE_IRQ, fd, IRQ_READ, sigio_interrupt, + SA_INTERRUPT | SA_SAMPLE_RANDOM, "write sigio", + NULL); + if(err){ + printk("write_sigio_irq : um_request_irq failed, err = %d\n", + err); return(-1); } sigio_irq_fd = fd; Index: um/arch/um/kernel/sigio_user.c =================================================================== --- um.orig/arch/um/kernel/sigio_user.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/kernel/sigio_user.c 2004-08-05 22:55:06.000000000 -0400 @@ -68,12 +68,15 @@ return; } - /* XXX These can fail with EINTR */ - if(tcgetattr(master, &tt) < 0) + do { + err = tcgetattr(master, &tt); + cfmakeraw(&tt); + if(!err) + err = tcsetattr(master, TCSADRAIN, &tt); + } while((err < 0) && (errno == EINTR)); + + if(err < 0) panic("check_sigio : tcgetattr failed, errno = %d\n", errno); - cfmakeraw(&tt); - if(tcsetattr(master, TCSADRAIN, &tt) < 0) - panic("check_sigio : tcsetattr failed, errno = %d\n", errno); err = os_sigio_async(master, slave); if(err < 0) Index: um/arch/um/kernel/skas/include/mode.h =================================================================== --- um.orig/arch/um/kernel/skas/include/mode.h 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/kernel/skas/include/mode.h 2004-08-05 22:55:06.000000000 -0400 @@ -6,6 +6,8 @@ #ifndef __MODE_SKAS_H__ #define __MODE_SKAS_H__ +#include + extern unsigned long exec_regs[]; extern unsigned long exec_fp_regs[]; extern unsigned long exec_fpx_regs[]; Index: um/arch/um/kernel/skas/process.c =================================================================== --- um.orig/arch/um/kernel/skas/process.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/kernel/skas/process.c 2004-08-05 22:55:06.000000000 -0400 @@ -190,7 +190,7 @@ void (*handler)(int)) { unsigned long flags; - jmp_buf switch_buf, fork_buf; + sigjmp_buf switch_buf, fork_buf; *switch_buf_ptr = &switch_buf; *fork_buf_ptr = &fork_buf; @@ -214,7 +214,7 @@ void thread_wait(void *sw, void *fb) { - jmp_buf buf, **switch_buf = sw, *fork_buf; + sigjmp_buf buf, **switch_buf = sw, *fork_buf; *switch_buf = &buf; fork_buf = fb; @@ -276,23 +276,23 @@ void switch_threads(void *me, void *next) { - jmp_buf my_buf, **me_ptr = me, *next_buf = next; + sigjmp_buf my_buf, **me_ptr = me, *next_buf = next; *me_ptr = &my_buf; if(sigsetjmp(my_buf, 1) == 0) siglongjmp(*next_buf, 1); } -static jmp_buf initial_jmpbuf; +static sigjmp_buf initial_jmpbuf; /* XXX Make these percpu */ static void (*cb_proc)(void *arg); static void *cb_arg; -static jmp_buf *cb_back; +static sigjmp_buf *cb_back; int start_idle_thread(void *stack, void *switch_buf_ptr, void **fork_buf_ptr) { - jmp_buf **switch_buf = switch_buf_ptr; + sigjmp_buf **switch_buf = switch_buf_ptr; int n; *fork_buf_ptr = &initial_jmpbuf; @@ -328,7 +328,7 @@ void initial_thread_cb_skas(void (*proc)(void *), void *arg) { - jmp_buf here; + sigjmp_buf here; cb_proc = proc; cb_arg = arg; Index: um/arch/um/kernel/skas/process_kern.c =================================================================== --- um.orig/arch/um/kernel/skas/process_kern.c 2004-08-05 22:54:40.000000000 -0400 +++ um/arch/um/kernel/skas/process_kern.c 2004-08-05 22:55:06.000000000 -0400 @@ -188,9 +188,9 @@ { start_userspace(0); capture_signal_stack(); - uml_idle_timer(); init_new_thread_signals(1); + uml_idle_timer(); init_task.thread.request.u.thread.proc = start_kernel_proc; init_task.thread.request.u.thread.arg = NULL; Index: um/arch/um/kernel/skas/trap_user.c =================================================================== --- um.orig/arch/um/kernel/skas/trap_user.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/kernel/skas/trap_user.c 2004-08-05 22:55:06.000000000 -0400 @@ -19,8 +19,10 @@ struct skas_regs *r; struct signal_info *info; int save_errno = errno; + int save_user; r = &TASK_REGS(get_current())->skas; + save_user = r->is_user; r->is_user = 0; r->fault_addr = SC_FAULT_ADDR(sc); r->fault_type = SC_FAULT_TYPE(sc); @@ -33,6 +35,7 @@ (*info->handler)(sig, (union uml_pt_regs *) r); errno = save_errno; + r->is_user = save_user; } void user_signal(int sig, union uml_pt_regs *regs) Index: um/arch/um/kernel/skas/uaccess.c =================================================================== --- um.orig/arch/um/kernel/skas/uaccess.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/kernel/skas/uaccess.c 2004-08-06 15:01:13.000000000 -0400 @@ -25,7 +25,7 @@ int dummy_code; if(IS_ERR(phys) || (is_write && !pte_write(pte))){ - err = handle_page_fault(virt, 0, is_write, 0, &dummy_code); + err = handle_page_fault(virt, 0, is_write, 1, &dummy_code); if(err) return(0); phys = um_virt_to_phys(current, virt, NULL); Index: um/arch/um/kernel/trap_user.c =================================================================== --- um.orig/arch/um/kernel/trap_user.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/kernel/trap_user.c 2004-08-05 22:55:06.000000000 -0400 @@ -120,7 +120,7 @@ void do_longjmp(void *b, int val) { - jmp_buf *buf = b; + sigjmp_buf *buf = b; siglongjmp(*buf, val); } Index: um/arch/um/kernel/tt/trap_user.c =================================================================== --- um.orig/arch/um/kernel/tt/trap_user.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/kernel/tt/trap_user.c 2004-08-06 15:01:13.000000000 -0400 @@ -23,6 +23,13 @@ unprotect_kernel_mem(); + /* This is done because to allow SIGSEGV to be delivered inside a SEGV + * handler. This can happen in copy_user, and if SEGV is disabled, + * the process will die. + */ + if(sig == SIGSEGV) + change_sig(SIGSEGV, 1); + r = &TASK_REGS(get_current())->tt; save_regs = *r; is_user = user_context(SC_SP(sc)); Index: um/arch/um/kernel/tt/uaccess_user.c =================================================================== --- um.orig/arch/um/kernel/tt/uaccess_user.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/kernel/tt/uaccess_user.c 2004-08-05 22:55:06.000000000 -0400 @@ -72,7 +72,7 @@ struct tt_regs save = TASK_REGS(get_current())->tt; int ret; unsigned long *faddrp = (unsigned long *)fault_addr; - jmp_buf jbuf; + sigjmp_buf jbuf; *fault_catcher = &jbuf; if(sigsetjmp(jbuf, 1) == 0) Index: um/arch/um/kernel/tty_log.c =================================================================== --- um.orig/arch/um/kernel/tty_log.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/kernel/tty_log.c 2004-08-05 22:55:06.000000000 -0400 @@ -205,6 +205,8 @@ printf("set_tty_log_fd - strtoul failed on '%s'\n", name); tty_log_fd = -1; } + + *add = 0; return 0; } Index: um/arch/um/kernel/uaccess_user.c =================================================================== --- um.orig/arch/um/kernel/uaccess_user.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/kernel/uaccess_user.c 2004-08-05 22:55:06.000000000 -0400 @@ -18,7 +18,7 @@ { unsigned long *faddrp = (unsigned long *) fault_addr, ret; - jmp_buf jbuf; + sigjmp_buf jbuf; *fault_catcher = &jbuf; if(sigsetjmp(jbuf, 1) == 0){ (*op)(to, from, n); Index: um/arch/um/kernel/um_arch.c =================================================================== --- um.orig/arch/um/kernel/um_arch.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/kernel/um_arch.c 2004-08-05 22:55:06.000000000 -0400 @@ -305,7 +305,7 @@ int linux_main(int argc, char **argv) { - unsigned long avail; + unsigned long avail, diff; unsigned long virtmem_size, max_physmem; unsigned int i, add; @@ -323,6 +323,16 @@ brk_start = (unsigned long) sbrk(0); CHOOSE_MODE_PROC(before_mem_tt, before_mem_skas, brk_start); + /* Increase physical memory size for exec-shield users + so they actually get what they asked for. This should + add zero for non-exec shield users */ + + diff = UML_ROUND_UP(brk_start) - UML_ROUND_UP(&_end); + if(diff > 1024 * 1024){ + printf("Adding %ld bytes to physical memory to account for " + "exec-shield gap\n", diff); + physmem_size += UML_ROUND_UP(brk_start) - UML_ROUND_UP(&_end); + } uml_physmem = uml_start; Index: um/arch/um/kernel/umid.c =================================================================== --- um.orig/arch/um/kernel/umid.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/kernel/umid.c 2004-08-06 15:01:12.000000000 -0400 @@ -43,7 +43,7 @@ } 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)); @@ -54,6 +54,7 @@ static int __init set_umid_arg(char *name, int *add) { + *add = 0; return(set_umid(name, 0, printf)); } @@ -204,12 +205,15 @@ 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: um/arch/um/kernel/user_util.c =================================================================== --- um.orig/arch/um/kernel/user_util.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/kernel/user_util.c 2004-08-06 15:01:13.000000000 -0400 @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -90,11 +91,11 @@ 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) || @@ -110,8 +111,8 @@ 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: um/arch/um/os-Linux/file.c =================================================================== --- um.orig/arch/um/os-Linux/file.c 2004-08-06 15:01:13.000000000 -0400 +++ um/arch/um/os-Linux/file.c 2004-08-06 15:02:38.000000000 -0400 @@ -187,7 +187,8 @@ 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); } @@ -326,7 +327,8 @@ __u64 actual; actual = lseek64(fd, offset, SEEK_SET); - if(actual != offset) return(-errno); + if(actual != offset) + return(-errno); return(0); } Index: um/arch/um/os-Linux/process.c =================================================================== --- um.orig/arch/um/os-Linux/process.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/os-Linux/process.c 2004-08-05 22:55:06.000000000 -0400 @@ -16,9 +16,12 @@ #define ARBITRARY_ADDR -1 #define FAILURE_PID -1 +#define STAT_PATH_LEN sizeof("/proc/#######/stat\0") +#define COMM_SCANF "%*[^)])" + unsigned long os_process_pc(int pid) { - char proc_stat[sizeof("/proc/#####/stat\0")], buf[256]; + char proc_stat[STAT_PATH_LEN], buf[256]; unsigned long pc; int fd, err; @@ -38,9 +41,9 @@ } os_close_file(fd); pc = ARBITRARY_ADDR; - if(sscanf(buf, "%*d %*s %*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 %ld", &pc) != 1){ + "%*d %*d %*d %*d %*d %lu", &pc) != 1){ printk("os_process_pc - couldn't find pc in '%s'\n", buf); } return(pc); @@ -48,7 +51,7 @@ int os_process_parent(int pid) { - char stat[sizeof("/proc/nnnnn/stat\0")]; + char stat[STAT_PATH_LEN]; char data[256]; int parent, n, fd; @@ -70,8 +73,7 @@ } parent = FAILURE_PID; - /* XXX This will break if there is a space in the command */ - n = sscanf(data, "%*d %*s %*c %d", &parent); + n = sscanf(data, "%*d " COMM_SCANF " %*c %d", &parent); if(n != 1) printk("Failed to scan '%s'\n", data); Index: um/arch/um/sys-i386/ptrace_user.c =================================================================== --- um.orig/arch/um/sys-i386/ptrace_user.c 2004-08-05 22:54:30.000000000 -0400 +++ um/arch/um/sys-i386/ptrace_user.c 2004-08-05 22:55:06.000000000 -0400 @@ -42,7 +42,8 @@ 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); } } Index: um/include/asm-um/bug.h =================================================================== --- um.orig/include/asm-um/bug.h 2004-08-05 22:54:30.000000000 -0400 +++ um/include/asm-um/bug.h 2004-08-05 22:55:06.000000000 -0400 @@ -23,8 +23,6 @@ } \ } while (0) -extern int foo; - #endif #endif