From: Paolo 'Blaisorblade' Giarrusso From: Jeff Dike This is a large set of small fixes and other changes: 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 the log() facility to mem_user.c. Fixed a problem with recursive segfaults not being handled correctly. tty_log_fd and umid aren't added to the command line any more. Fixed some prints. Signed-off-by: Paolo 'Blaisorblade' Giarrusso Signed-off-by: Andrew Morton --- 25-akpm/arch/um/drivers/port_user.c | 8 +++++ 25-akpm/arch/um/kernel/mem_user.c | 33 ++++++++++++++++++++++++ 25-akpm/arch/um/kernel/sigio_kern.c | 2 - 25-akpm/arch/um/kernel/skas/include/mode-skas.h | 2 + 25-akpm/arch/um/kernel/tt/trap_user.c | 7 +++++ 25-akpm/arch/um/kernel/tty_log.c | 2 + 25-akpm/arch/um/kernel/umid.c | 1 25-akpm/arch/um/os-Linux/file.c | 3 +- 8 files changed, 55 insertions(+), 3 deletions(-) diff -puN arch/um/drivers/port_user.c~uml-lots-of-little-fixes-by-jeff-dike arch/um/drivers/port_user.c --- 25/arch/um/drivers/port_user.c~uml-lots-of-little-fixes-by-jeff-dike 2004-11-03 19:28:02.118347072 -0800 +++ 25-akpm/arch/um/drivers/port_user.c 2004-11-03 19:28:02.131345096 -0800 @@ -123,12 +123,18 @@ struct chan_ops port_ops = { 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); diff -puN arch/um/kernel/mem_user.c~uml-lots-of-little-fixes-by-jeff-dike arch/um/kernel/mem_user.c --- 25/arch/um/kernel/mem_user.c~uml-lots-of-little-fixes-by-jeff-dike 2004-11-03 19:28:02.119346920 -0800 +++ 25-akpm/arch/um/kernel/mem_user.c 2004-11-03 19:28:02.132344944 -0800 @@ -228,6 +228,39 @@ int protect_memory(unsigned long addr, u 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 diff -puN arch/um/kernel/sigio_kern.c~uml-lots-of-little-fixes-by-jeff-dike arch/um/kernel/sigio_kern.c --- 25/arch/um/kernel/sigio_kern.c~uml-lots-of-little-fixes-by-jeff-dike 2004-11-03 19:28:02.120346768 -0800 +++ 25-akpm/arch/um/kernel/sigio_kern.c 2004-11-03 19:28:02.132344944 -0800 @@ -28,7 +28,7 @@ int write_sigio_irq(int fd) int err; err = um_request_irq(SIGIO_WRITE_IRQ, fd, IRQ_READ, sigio_interrupt, - SA_INTERRUPT | SA_SAMPLE_RANDOM, "write sigio", + SA_INTERRUPT | SA_SAMPLE_RANDOM, "write sigio", NULL); if(err){ printk("write_sigio_irq : um_request_irq failed, err = %d\n", diff -puN arch/um/kernel/skas/include/mode-skas.h~uml-lots-of-little-fixes-by-jeff-dike arch/um/kernel/skas/include/mode-skas.h --- 25/arch/um/kernel/skas/include/mode-skas.h~uml-lots-of-little-fixes-by-jeff-dike 2004-11-03 19:28:02.122346464 -0800 +++ 25-akpm/arch/um/kernel/skas/include/mode-skas.h 2004-11-03 19:28:02.133344792 -0800 @@ -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[]; diff -puN arch/um/kernel/tt/trap_user.c~uml-lots-of-little-fixes-by-jeff-dike arch/um/kernel/tt/trap_user.c --- 25/arch/um/kernel/tt/trap_user.c~uml-lots-of-little-fixes-by-jeff-dike 2004-11-03 19:28:02.123346312 -0800 +++ 25-akpm/arch/um/kernel/tt/trap_user.c 2004-11-03 19:28:02.133344792 -0800 @@ -30,6 +30,13 @@ void sig_handler_common_tt(int sig, void if(sig == SIGSEGV) change_sig(SIGSEGV, 1); + /* 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)); diff -puN arch/um/kernel/tty_log.c~uml-lots-of-little-fixes-by-jeff-dike arch/um/kernel/tty_log.c --- 25/arch/um/kernel/tty_log.c~uml-lots-of-little-fixes-by-jeff-dike 2004-11-03 19:28:02.125346008 -0800 +++ 25-akpm/arch/um/kernel/tty_log.c 2004-11-03 19:28:02.133344792 -0800 @@ -205,6 +205,8 @@ static int __init set_tty_log_fd(char *n printf("set_tty_log_fd - strtoul failed on '%s'\n", name); tty_log_fd = -1; } + + *add = 0; return 0; } diff -puN arch/um/kernel/umid.c~uml-lots-of-little-fixes-by-jeff-dike arch/um/kernel/umid.c --- 25/arch/um/kernel/umid.c~uml-lots-of-little-fixes-by-jeff-dike 2004-11-03 19:28:02.126345856 -0800 +++ 25-akpm/arch/um/kernel/umid.c 2004-11-03 19:28:02.134344640 -0800 @@ -54,6 +54,7 @@ static int __init set_umid(char *name, i static int __init set_umid_arg(char *name, int *add) { + *add = 0; return(set_umid(name, 0, printf)); } diff -puN arch/um/os-Linux/file.c~uml-lots-of-little-fixes-by-jeff-dike arch/um/os-Linux/file.c --- 25/arch/um/os-Linux/file.c~uml-lots-of-little-fixes-by-jeff-dike 2004-11-03 19:28:02.128345552 -0800 +++ 25-akpm/arch/um/os-Linux/file.c 2004-11-03 19:28:02.135344488 -0800 @@ -308,7 +308,8 @@ int os_seek_file(int fd, __u64 offset) __u64 actual; actual = lseek64(fd, offset, SEEK_SET); - if(actual != offset) return(-errno); + if(actual != offset) + return(-errno); return(0); } _