Commit 67e19597 authored by Paolo \'Blaisorblade\' Giarrusso's avatar Paolo \'Blaisorblade\' Giarrusso Committed by Linus Torvalds

[PATCH] uml: Lots of little fixes by Jeff Dike.

From: Jeff Dike <jdike@addtoit.com>

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: default avatarPaolo 'Blaisorblade' Giarrusso <blaisorblade_spam@yahoo.it>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent fc8a8533
...@@ -123,12 +123,18 @@ struct chan_ops port_ops = { ...@@ -123,12 +123,18 @@ struct chan_ops port_ops = {
int port_listen_fd(int port) int port_listen_fd(int port)
{ {
struct sockaddr_in addr; struct sockaddr_in addr;
int fd, err; int fd, err, arg;
fd = socket(PF_INET, SOCK_STREAM, 0); fd = socket(PF_INET, SOCK_STREAM, 0);
if(fd == -1) if(fd == -1)
return(-errno); 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_family = AF_INET;
addr.sin_port = htons(port); addr.sin_port = htons(port);
addr.sin_addr.s_addr = htonl(INADDR_ANY); addr.sin_addr.s_addr = htonl(INADDR_ANY);
......
...@@ -228,6 +228,39 @@ int protect_memory(unsigned long addr, unsigned long len, int r, int w, int x, ...@@ -228,6 +228,39 @@ int protect_memory(unsigned long addr, unsigned long len, int r, int w, int x,
return(0); 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. * Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically * Emacs will notice this stuff at the end of the file and automatically
......
...@@ -28,7 +28,7 @@ int write_sigio_irq(int fd) ...@@ -28,7 +28,7 @@ int write_sigio_irq(int fd)
int err; int err;
err = um_request_irq(SIGIO_WRITE_IRQ, fd, IRQ_READ, sigio_interrupt, 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); NULL);
if(err){ if(err){
printk("write_sigio_irq : um_request_irq failed, err = %d\n", printk("write_sigio_irq : um_request_irq failed, err = %d\n",
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#ifndef __MODE_SKAS_H__ #ifndef __MODE_SKAS_H__
#define __MODE_SKAS_H__ #define __MODE_SKAS_H__
#include <sysdep/ptrace.h>
extern unsigned long exec_regs[]; extern unsigned long exec_regs[];
extern unsigned long exec_fp_regs[]; extern unsigned long exec_fp_regs[];
extern unsigned long exec_fpx_regs[]; extern unsigned long exec_fpx_regs[];
......
...@@ -23,6 +23,13 @@ void sig_handler_common_tt(int sig, void *sc_ptr) ...@@ -23,6 +23,13 @@ void sig_handler_common_tt(int sig, void *sc_ptr)
unprotect_kernel_mem(); 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);
/* This is done because to allow SIGSEGV to be delivered inside a SEGV /* 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, * handler. This can happen in copy_user, and if SEGV is disabled,
* the process will die. * the process will die.
......
...@@ -205,6 +205,8 @@ static int __init set_tty_log_fd(char *name, int *add) ...@@ -205,6 +205,8 @@ static int __init set_tty_log_fd(char *name, int *add)
printf("set_tty_log_fd - strtoul failed on '%s'\n", name); printf("set_tty_log_fd - strtoul failed on '%s'\n", name);
tty_log_fd = -1; tty_log_fd = -1;
} }
*add = 0;
return 0; return 0;
} }
......
...@@ -54,6 +54,7 @@ static int __init set_umid(char *name, int is_random, ...@@ -54,6 +54,7 @@ static int __init set_umid(char *name, int is_random,
static int __init set_umid_arg(char *name, int *add) static int __init set_umid_arg(char *name, int *add)
{ {
*add = 0;
return(set_umid(name, 0, printf)); return(set_umid(name, 0, printf));
} }
......
...@@ -308,7 +308,8 @@ int os_seek_file(int fd, __u64 offset) ...@@ -308,7 +308,8 @@ int os_seek_file(int fd, __u64 offset)
__u64 actual; __u64 actual;
actual = lseek64(fd, offset, SEEK_SET); actual = lseek64(fd, offset, SEEK_SET);
if(actual != offset) return(-errno); if(actual != offset)
return(-errno);
return(0); return(0);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment