Commit facb7381 authored by Jeff Dike's avatar Jeff Dike

Cleaned up a bunch of things noticed while merging the SMP support.

The tempfile code is in its own file.
A bunch of unused stuff is now gone.
A bunch of code that could be called from the tracing thread was
made safe for that to happen.
parent e856ba4a
...@@ -343,8 +343,6 @@ void line_register_devfs(struct lines *set, struct line_driver *line_driver, ...@@ -343,8 +343,6 @@ void line_register_devfs(struct lines *set, struct line_driver *line_driver,
driver->write_room = line_write_room; driver->write_room = line_write_room;
driver->init_termios = tty_std_termios; driver->init_termios = tty_std_termios;
driver->refcount = &set->refcount;
if (tty_register_driver(driver)) if (tty_register_driver(driver))
panic("line_register_devfs : Couldn't register driver\n"); panic("line_register_devfs : Couldn't register driver\n");
...@@ -439,7 +437,6 @@ static void winch_cleanup(void) ...@@ -439,7 +437,6 @@ static void winch_cleanup(void)
list_for_each(ele, &winch_handlers){ list_for_each(ele, &winch_handlers){
winch = list_entry(ele, struct winch, list); winch = list_entry(ele, struct winch, list);
close(winch->fd); close(winch->fd);
free_irq_by_fd(winch->fd);
if(winch->pid != -1) os_kill_process(winch->pid); if(winch->pid != -1) os_kill_process(winch->pid);
} }
} }
......
...@@ -519,8 +519,6 @@ __uml_help(eth_setup, ...@@ -519,8 +519,6 @@ __uml_help(eth_setup,
" Configure a network device.\n\n" " Configure a network device.\n\n"
); );
int ndev = 0;
static int eth_init(void) static int eth_init(void)
{ {
struct list_head *ele, *next; struct list_head *ele, *next;
......
...@@ -184,7 +184,6 @@ static void free_port(void) ...@@ -184,7 +184,6 @@ static void free_port(void)
list_for_each(ele, &ports){ list_for_each(ele, &ports){
port = list_entry(ele, struct port_list, list); port = list_entry(ele, struct port_list, list);
free_irq(ACCEPT_IRQ, port);
os_close_file(port->fd); os_close_file(port->fd);
} }
} }
......
...@@ -24,10 +24,13 @@ ...@@ -24,10 +24,13 @@
static int ssl_version = 1; static int ssl_version = 1;
static struct tty_driver ssl_driver; /* Referenced only by tty_driver below - presumably it's locked correctly
* by the tty driver.
*/
static int ssl_refcount = 0; static int ssl_refcount = 0;
static struct tty_driver ssl_driver;
#define NR_PORTS 64 #define NR_PORTS 64
void ssl_announce(char *dev_name, int dev) void ssl_announce(char *dev_name, int dev)
...@@ -153,17 +156,7 @@ void ssl_hangup(struct tty_struct *tty) ...@@ -153,17 +156,7 @@ void ssl_hangup(struct tty_struct *tty)
{ {
} }
static int ssl_init_done = 0; static struct tty_driver ssl_driver = {
int ssl_init(void)
{
char *new_title;
printk(KERN_INFO "Initializing software serial port version %d\n",
ssl_version);
ssl_driver = ((struct tty_driver)
{
refcount : &ssl_refcount, refcount : &ssl_refcount,
open : ssl_open, open : ssl_open,
close : ssl_close, close : ssl_close,
...@@ -179,7 +172,19 @@ int ssl_init(void) ...@@ -179,7 +172,19 @@ int ssl_init(void)
stop : ssl_stop, stop : ssl_stop,
start : ssl_start, start : ssl_start,
hangup : ssl_hangup hangup : ssl_hangup
}); };
/* Changed by ssl_init and referenced by ssl_exit, which are both serialized
* by being an initcall and exitcall, respectively.
*/
static int ssl_init_done = 0;
int ssl_init(void)
{
char *new_title;
printk(KERN_INFO "Initializing software serial port version %d\n",
ssl_version);
line_register_devfs(&lines, &driver, &ssl_driver, serial_lines, line_register_devfs(&lines, &driver, &ssl_driver, serial_lines,
sizeof(serial_lines)/sizeof(serial_lines[0])); sizeof(serial_lines)/sizeof(serial_lines[0]));
......
...@@ -130,15 +130,6 @@ int stdio_init(void) ...@@ -130,15 +130,6 @@ int stdio_init(void)
printk(KERN_INFO "Initializing stdio console driver\n"); printk(KERN_INFO "Initializing stdio console driver\n");
console_driver = ((struct tty_driver)
{
open : con_open,
close : con_close,
write : con_write,
chars_in_buffer : chars_in_buffer,
set_termios : set_termios
});
line_register_devfs(&console_lines, &driver, &console_driver, vts, line_register_devfs(&console_lines, &driver, &console_driver, vts,
sizeof(vts)/sizeof(vts[0])); sizeof(vts)/sizeof(vts[0]));
...@@ -157,9 +148,20 @@ __initcall(stdio_init); ...@@ -157,9 +148,20 @@ __initcall(stdio_init);
static void console_write(struct console *console, const char *string, static void console_write(struct console *console, const char *string,
unsigned len) unsigned len)
{ {
if(con_init_done) down(&vts[console->index].sem);
console_write_chan(&vts[console->index].chan_list, string, len); console_write_chan(&vts[console->index].chan_list, string, len);
if(con_init_done) up(&vts[console->index].sem);
} }
static struct tty_driver console_driver = {
refcount : &console_refcount,
open : con_open,
close : con_close,
write : con_write,
chars_in_buffer : chars_in_buffer,
set_termios : set_termios
};
static kdev_t console_device(struct console *c) static kdev_t console_device(struct console *c)
{ {
return mk_kdev(TTY_MAJOR, c->index); return mk_kdev(TTY_MAJOR, c->index);
...@@ -193,7 +195,6 @@ __channel_help(console_chan_setup, "con"); ...@@ -193,7 +195,6 @@ __channel_help(console_chan_setup, "con");
static void console_exit(void) static void console_exit(void)
{ {
if(!con_init_done) return; if(!con_init_done) return;
line_close(vts, NULL);
close_lines(vts, sizeof(vts)/sizeof(vts[0])); close_lines(vts, sizeof(vts)/sizeof(vts[0]));
} }
......
...@@ -130,12 +130,7 @@ static int ubd0_init(void) ...@@ -130,12 +130,7 @@ static int ubd0_init(void)
__initcall(ubd0_init); __initcall(ubd0_init);
static struct hd_driveid ubd_id = { /* Only changed by fake_ide_setup which is a setup */
.cyls = 0,
.heads = 128,
.sectors = 32,
};
static int fake_ide = 0; static int fake_ide = 0;
static struct proc_dir_entry *proc_ide_root = NULL; static struct proc_dir_entry *proc_ide_root = NULL;
static struct proc_dir_entry *proc_ide = NULL; static struct proc_dir_entry *proc_ide = NULL;
...@@ -161,7 +156,6 @@ static int proc_ide_read_media(char *page, char **start, off_t off, int count, ...@@ -161,7 +156,6 @@ static int proc_ide_read_media(char *page, char **start, off_t off, int count,
else len = count; else len = count;
*start = page + off; *start = page + off;
return len; return len;
} }
static void make_ide_entries(char *dev_name) static void make_ide_entries(char *dev_name)
...@@ -380,8 +374,6 @@ void kill_io_thread(void) ...@@ -380,8 +374,6 @@ void kill_io_thread(void)
__uml_exitcall(kill_io_thread); __uml_exitcall(kill_io_thread);
int sync = 0;
static int ubd_file_size(struct ubd *dev, __u64 *size_out) static int ubd_file_size(struct ubd *dev, __u64 *size_out)
{ {
char *file; char *file;
...@@ -566,7 +558,7 @@ int ubd_driver_init(void){ ...@@ -566,7 +558,7 @@ int ubd_driver_init(void){
unsigned long stack; unsigned long stack;
int err; int err;
if(sync){ if(global_openflags.s){
printk(KERN_INFO "ubd : Synchronous mode\n"); printk(KERN_INFO "ubd : Synchronous mode\n");
return(0); return(0);
} }
...@@ -590,9 +582,9 @@ device_initcall(ubd_driver_init); ...@@ -590,9 +582,9 @@ device_initcall(ubd_driver_init);
static void ubd_close(struct ubd *dev) static void ubd_close(struct ubd *dev)
{ {
close_fd(dev->fd); os_close_file(dev->fd);
if(dev->cow.file != NULL) { if(dev->cow.file != NULL) {
close_fd(dev->cow.fd); os_close_file(dev->cow.fd);
vfree(dev->cow.bitmap); vfree(dev->cow.bitmap);
dev->cow.bitmap = NULL; dev->cow.bitmap = NULL;
} }
...@@ -695,9 +687,6 @@ static int ubd_release(struct inode * inode, struct file * file) ...@@ -695,9 +687,6 @@ static int ubd_release(struct inode * inode, struct file * file)
return(0); return(0);
} }
int cow_read = 0;
int cow_write = 0;
void cowify_req(struct io_thread_req *req, struct ubd *dev) void cowify_req(struct io_thread_req *req, struct ubd *dev)
{ {
int i, update_bitmap, sector = req->offset >> 9; int i, update_bitmap, sector = req->offset >> 9;
...@@ -710,14 +699,12 @@ void cowify_req(struct io_thread_req *req, struct ubd *dev) ...@@ -710,14 +699,12 @@ void cowify_req(struct io_thread_req *req, struct ubd *dev)
dev->cow.bitmap)){ dev->cow.bitmap)){
ubd_set_bit(i, (unsigned char *) ubd_set_bit(i, (unsigned char *)
&req->sector_mask); &req->sector_mask);
cow_read++;
} }
} }
} }
else { else {
update_bitmap = 0; update_bitmap = 0;
for(i = 0; i < req->length >> 9; i++){ for(i = 0; i < req->length >> 9; i++){
cow_write++;
ubd_set_bit(i, (unsigned char *) ubd_set_bit(i, (unsigned char *)
&req->sector_mask); &req->sector_mask);
if(!ubd_test_bit(sector + i, (unsigned char *) if(!ubd_test_bit(sector + i, (unsigned char *)
...@@ -819,6 +806,12 @@ static int ubd_ioctl(struct inode * inode, struct file * file, ...@@ -819,6 +806,12 @@ static int ubd_ioctl(struct inode * inode, struct file * file,
struct hd_geometry *loc = (struct hd_geometry *) arg; struct hd_geometry *loc = (struct hd_geometry *) arg;
struct ubd *dev; struct ubd *dev;
int n, min, err; int n, min, err;
struct hd_driveid ubd_id = {
.cyls = 0,
.heads = 128,
.sectors = 32,
};
if(!inode) return(-EINVAL); if(!inode) return(-EINVAL);
min = minor(inode->i_rdev); min = minor(inode->i_rdev);
......
...@@ -61,12 +61,9 @@ struct line { ...@@ -61,12 +61,9 @@ struct line {
struct lines { struct lines {
int num; int num;
int refcount;
}; };
#define LINES_INIT(n) \ #define LINES_INIT(n) { num : n }
{ num : n, \
refcount : 0 }
extern void line_interrupt(int irq, void *data, struct pt_regs *unused); extern void line_interrupt(int irq, void *data, struct pt_regs *unused);
extern void line_write_interrupt(int irq, void *data, struct pt_regs *unused); extern void line_write_interrupt(int irq, void *data, struct pt_regs *unused);
......
/*
* Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
* Licensed under the GPL
*/
#ifndef __TEMPFILE_H__
#define __TEMPFILE_H__
extern int make_tempfile(const char *template, char **tempname, int do_unlink);
#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
* adjust the settings for this buffer only. This must remain at the end
* of the file.
* ---------------------------------------------------------------------------
* Local variables:
* c-file-style: "linux"
* End:
*/
...@@ -48,32 +48,21 @@ extern unsigned long brk_start; ...@@ -48,32 +48,21 @@ extern unsigned long brk_start;
extern int pty_output_sigio; extern int pty_output_sigio;
extern int pty_close_sigio; extern int pty_close_sigio;
extern void *open_maps(void);
extern void close_maps(void *fd);
extern unsigned long get_brk(void);
extern void stop(void); extern void stop(void);
extern int proc_start_thread(unsigned long ip, unsigned long sp);
extern void stack_protections(unsigned long address); extern void stack_protections(unsigned long address);
extern void task_protections(unsigned long address); extern void task_protections(unsigned long address);
extern void abandon_proc_space(int (*proc)(void *), unsigned long sp);
extern int signals(int (*init_proc)(void *), void *sp); extern int signals(int (*init_proc)(void *), void *sp);
extern int __personality(int);
extern int wait_for_stop(int pid, int sig, int cont_type, void *relay); extern int wait_for_stop(int pid, int sig, int cont_type, void *relay);
extern void *add_signal_handler(int sig, void (*handler)(int)); extern void *add_signal_handler(int sig, void (*handler)(int));
extern void signal_init(void);
extern int start_fork_tramp(void *arg, unsigned long temp_stack, extern int start_fork_tramp(void *arg, unsigned long temp_stack,
int clone_flags, int (*tramp)(void *)); int clone_flags, int (*tramp)(void *));
extern void trace_myself(void); extern void trace_myself(void);
extern int clone_and_wait(int (*fn)(void *), void *arg, void *sp, int flags); extern int clone_and_wait(int (*fn)(void *), void *arg, void *sp, int flags);
extern int input_loop(void);
extern void continue_execing_proc(int pid);
extern int linux_main(int argc, char **argv); extern int linux_main(int argc, char **argv);
extern void remap_data(void *segment_start, void *segment_end, int w); extern void remap_data(void *segment_start, void *segment_end, int w);
extern void set_cmdline(char *cmd); extern void set_cmdline(char *cmd);
extern void input_cb(void (*proc)(void *), void *arg, int arg_len); extern void input_cb(void (*proc)(void *), void *arg, int arg_len);
extern void setup_input(void);
extern int get_pty(void); extern int get_pty(void);
extern void save_signal_state(int *sig_ptr);
extern void *um_kmalloc(int size); extern void *um_kmalloc(int size);
extern int raw(int fd, int complain); extern int raw(int fd, int complain);
extern int switcheroo(int fd, int prot, void *from, void *to, int size); extern int switcheroo(int fd, int prot, void *from, void *to, int size);
...@@ -82,15 +71,11 @@ extern void setup_hostinfo(void); ...@@ -82,15 +71,11 @@ extern void setup_hostinfo(void);
extern void add_arg(char *cmd_line, char *arg); extern void add_arg(char *cmd_line, char *arg);
extern void init_new_thread(void *sig_stack, void (*usr1_handler)(int)); extern void init_new_thread(void *sig_stack, void (*usr1_handler)(int));
extern void attach_process(int pid); extern void attach_process(int pid);
extern void calc_sigframe_size(void);
extern int fork_tramp(void *sig_stack); extern int fork_tramp(void *sig_stack);
extern void do_exec(int old_pid, int new_pid); extern void do_exec(int old_pid, int new_pid);
extern void tracer_panic(char *msg, ...); extern void tracer_panic(char *msg, ...);
extern void close_fd(int);
extern int make_tempfile(const char *template, char **tempname, int do_unlink);
extern char *get_umid(int only_if_set); extern char *get_umid(int only_if_set);
extern void do_longjmp(void *p); extern void do_longjmp(void *p);
extern void term_handler(int sig);
extern void suspend_new_thread(int fd); extern void suspend_new_thread(int fd);
extern int detach(int pid, int sig); extern int detach(int pid, int sig);
extern int attach(int pid); extern int attach(int pid);
...@@ -99,12 +84,9 @@ extern int cont(int pid); ...@@ -99,12 +84,9 @@ extern int cont(int pid);
extern void check_ptrace(void); extern void check_ptrace(void);
extern void check_sigio(void); extern void check_sigio(void);
extern int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr); extern int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr);
extern int user_read(int fd, char *buf, int len);
extern int user_write(int fd, char *buf, int len);
extern void write_sigio_workaround(void); extern void write_sigio_workaround(void);
extern void arch_check_bugs(void); extern void arch_check_bugs(void);
extern int arch_handle_signal(int sig, struct uml_pt_regs *regs); extern int arch_handle_signal(int sig, struct uml_pt_regs *regs);
extern unsigned long pid_pc(int pid);
extern int arch_fixup(unsigned long address, void *sc_ptr); extern int arch_fixup(unsigned long address, void *sc_ptr);
extern void forward_pending_sigio(int target); extern void forward_pending_sigio(int target);
......
...@@ -3,9 +3,9 @@ EXTRA_TARGETS := unmap_fin.o ...@@ -3,9 +3,9 @@ EXTRA_TARGETS := unmap_fin.o
obj-y = config.o exec_kern.o exec_user.o exitcode.o frame_kern.o frame.o \ obj-y = config.o exec_kern.o exec_user.o exitcode.o frame_kern.o frame.o \
helper.o init_task.o irq.o irq_user.o ksyms.o mem.o mem_user.o \ helper.o init_task.o irq.o irq_user.o ksyms.o mem.o mem_user.o \
process.o process_kern.o ptrace.o reboot.o resource.o setup.o \ process.o process_kern.o ptrace.o reboot.o resource.o sigio_user.o \
sigio_user.o sigio_kern.o signal_kern.o signal_user.o smp.o \ sigio_kern.o signal_kern.o signal_user.o smp.o syscall_kern.o \
syscall_kern.o syscall_user.o sysrq.o sys_call_table.o time.o \ syscall_user.o sysrq.o sys_call_table.o tempfile.o time.o \
time_kern.o tlb.o trap_kern.o trap_user.o uaccess_user.o um_arch.o \ time_kern.o tlb.o trap_kern.o trap_user.o uaccess_user.o um_arch.o \
umid.o user_util.o umid.o user_util.o
...@@ -14,8 +14,8 @@ obj-$(CONFIG_BLK_DEV_INITRD) += initrd_kern.o initrd_user.o ...@@ -14,8 +14,8 @@ obj-$(CONFIG_BLK_DEV_INITRD) += initrd_kern.o initrd_user.o
# user_syms.o not included here because Rules.make has its own ideas about # user_syms.o not included here because Rules.make has its own ideas about
# building anything in export-objs # building anything in export-objs
USER_OBJS := $(filter %_user.o,$(obj-y)) config.o frame.o helper.o process.o \ USER_OBJS := $(filter %_user.o,$(obj-y)) config.o helper.o process.o \
time.o tty_log.o umid.o user_util.o user_syms.o tempfile.o time.o tty_log.o umid.o user_util.o user_syms.o
USER_OBJS := $(foreach file,$(USER_OBJS),arch/um/kernel/$(file)) USER_OBJS := $(foreach file,$(USER_OBJS),arch/um/kernel/$(file))
export-objs := ksyms.o process_kern.o signal_kern.o gprof_syms.o gmon_syms.o export-objs := ksyms.o process_kern.o signal_kern.o gprof_syms.o gmon_syms.o
...@@ -51,6 +51,9 @@ arch/um/kernel/unmap.o: arch/um/kernel/unmap.c ...@@ -51,6 +51,9 @@ arch/um/kernel/unmap.o: arch/um/kernel/unmap.c
arch/um/kernel/unmap_fin.o : arch/um/kernel/unmap.o arch/um/kernel/unmap_fin.o : arch/um/kernel/unmap.o
ld -r -o $@ $< -lc -L/usr/lib ld -r -o $@ $< -lc -L/usr/lib
arch/um/kernel/frame.o: arch/um/kernel/frame.c
$(CC) $(CFLAGS_$@) -c -o $@ $<
QUOTE = 'my $$config=`cat $(TOPDIR)/.config`; $$config =~ s/"/\\"/g ; while(<STDIN>) { $$_ =~ s/CONFIG/$$config/; print $$_ }' QUOTE = 'my $$config=`cat $(TOPDIR)/.config`; $$config =~ s/"/\\"/g ; while(<STDIN>) { $$_ =~ s/CONFIG/$$config/; print $$_ }'
arch/um/kernel/config.c : arch/um/kernel/config.c.in $(TOPDIR)/.config arch/um/kernel/config.c : arch/um/kernel/config.c.in $(TOPDIR)/.config
......
...@@ -20,6 +20,7 @@ EXPORT_SYMBOL(__const_udelay); ...@@ -20,6 +20,7 @@ EXPORT_SYMBOL(__const_udelay);
EXPORT_SYMBOL(sys_waitpid); EXPORT_SYMBOL(sys_waitpid);
EXPORT_SYMBOL(task_size); EXPORT_SYMBOL(task_size);
EXPORT_SYMBOL(__do_copy_from_user); EXPORT_SYMBOL(__do_copy_from_user);
EXPORT_SYMBOL(__do_copy_to_user);
EXPORT_SYMBOL(__do_strncpy_from_user); EXPORT_SYMBOL(__do_strncpy_from_user);
EXPORT_SYMBOL(__do_strnlen_user); EXPORT_SYMBOL(__do_strnlen_user);
EXPORT_SYMBOL(flush_tlb_range); EXPORT_SYMBOL(flush_tlb_range);
......
...@@ -229,7 +229,7 @@ void *switch_to(void *prev, void *next, void *last) ...@@ -229,7 +229,7 @@ void *switch_to(void *prev, void *next, void *last)
set_current(to); set_current(to);
reading = 0; reading = 0;
err = user_write(to->thread.switch_pipe[1], &c, sizeof(c)); err = os_write_file(to->thread.switch_pipe[1], &c, sizeof(c));
if(err != sizeof(c)) if(err != sizeof(c))
panic("write of switch_pipe failed, errno = %d", -err); panic("write of switch_pipe failed, errno = %d", -err);
...@@ -237,7 +237,7 @@ void *switch_to(void *prev, void *next, void *last) ...@@ -237,7 +237,7 @@ void *switch_to(void *prev, void *next, void *last)
if((from->state == TASK_ZOMBIE) || (from->state == TASK_DEAD)) if((from->state == TASK_ZOMBIE) || (from->state == TASK_DEAD))
os_kill_process(os_getpid()); os_kill_process(os_getpid());
err = user_read(from->thread.switch_pipe[0], &c, sizeof(c)); err = os_read_file(from->thread.switch_pipe[0], &c, sizeof(c));
if(err != sizeof(c)) if(err != sizeof(c))
panic("read of switch_pipe failed, errno = %d", -err); panic("read of switch_pipe failed, errno = %d", -err);
......
...@@ -57,7 +57,7 @@ int change_sig(int signal, int on) ...@@ -57,7 +57,7 @@ int change_sig(int signal, int on)
sigemptyset(&sigset); sigemptyset(&sigset);
sigaddset(&sigset, signal); sigaddset(&sigset, signal);
sigprocmask(on ? SIG_UNBLOCK : SIG_BLOCK, &sigset, &old); sigprocmask(on ? SIG_UNBLOCK : SIG_BLOCK, &sigset, &old);
return(sigismember(&old, signal)); return(!sigismember(&old, signal));
} }
static void change_signals(int type) static void change_signals(int type)
......
...@@ -86,6 +86,7 @@ long um_stime(int * tptr) ...@@ -86,6 +86,7 @@ long um_stime(int * tptr)
return 0; return 0;
} }
/* XXX Needs to be moved under sys-i386 */
void __delay(um_udelay_t time) void __delay(um_udelay_t time)
{ {
/* Stolen from the i386 __loop_delay */ /* Stolen from the i386 __loop_delay */
......
...@@ -99,6 +99,7 @@ static int signal_tramp(void *arg) ...@@ -99,6 +99,7 @@ static int signal_tramp(void *arg)
static void last_ditch_exit(int sig) static void last_ditch_exit(int sig)
{ {
kmalloc_ok = 0;
signal(SIGINT, SIG_DFL); signal(SIGINT, SIG_DFL);
signal(SIGTERM, SIG_DFL); signal(SIGTERM, SIG_DFL);
signal(SIGHUP, SIG_DFL); signal(SIGHUP, SIG_DFL);
...@@ -188,7 +189,7 @@ int signals(int (*init_proc)(void *), void *sp) ...@@ -188,7 +189,7 @@ int signals(int (*init_proc)(void *), void *sp)
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
setup_tracer_winch(); setup_tracer_winch();
tracing_pid = os_getpid(); tracing_pid = os_getpid();
printk("tracing thread pid = %d\n", tracing_pid); printf("tracing thread pid = %d\n", tracing_pid);
pid = clone(signal_tramp, sp, CLONE_FILES | SIGCHLD, init_proc); pid = clone(signal_tramp, sp, CLONE_FILES | SIGCHLD, init_proc);
n = waitpid(pid, &status, WUNTRACED); n = waitpid(pid, &status, WUNTRACED);
...@@ -207,7 +208,7 @@ int signals(int (*init_proc)(void *), void *sp) ...@@ -207,7 +208,7 @@ int signals(int (*init_proc)(void *), void *sp)
set_handler(SIGTERM, last_ditch_exit, SA_ONESHOT | SA_NODEFER, -1); set_handler(SIGTERM, last_ditch_exit, SA_ONESHOT | SA_NODEFER, -1);
set_handler(SIGHUP, last_ditch_exit, SA_ONESHOT | SA_NODEFER, -1); set_handler(SIGHUP, last_ditch_exit, SA_ONESHOT | SA_NODEFER, -1);
if(debug_trace){ if(debug_trace){
printk("Tracing thread pausing to be attached\n"); printf("Tracing thread pausing to be attached\n");
stop(); stop();
} }
if(debug){ if(debug){
...@@ -219,14 +220,14 @@ int signals(int (*init_proc)(void *), void *sp) ...@@ -219,14 +220,14 @@ int signals(int (*init_proc)(void *), void *sp)
init_parent_proxy(debugger_parent); init_parent_proxy(debugger_parent);
err = attach(debugger_parent); err = attach(debugger_parent);
if(err){ if(err){
printk("Failed to attach debugger parent %d, " printf("Failed to attach debugger parent %d, "
"errno = %d\n", debugger_parent, err); "errno = %d\n", debugger_parent, err);
debugger_parent = -1; debugger_parent = -1;
} }
else { else {
if(ptrace(PTRACE_SYSCALL, debugger_parent, if(ptrace(PTRACE_SYSCALL, debugger_parent,
0, 0) < 0){ 0, 0) < 0){
printk("Failed to continue debugger " printf("Failed to continue debugger "
"parent, errno = %d\n", errno); "parent, errno = %d\n", errno);
debugger_parent = -1; debugger_parent = -1;
} }
...@@ -237,7 +238,7 @@ int signals(int (*init_proc)(void *), void *sp) ...@@ -237,7 +238,7 @@ int signals(int (*init_proc)(void *), void *sp)
while(1){ while(1){
if((pid = waitpid(-1, &status, WUNTRACED)) <= 0){ if((pid = waitpid(-1, &status, WUNTRACED)) <= 0){
if(errno != ECHILD){ if(errno != ECHILD){
printk("wait failed - errno = %d\n", errno); printf("wait failed - errno = %d\n", errno);
} }
continue; continue;
} }
...@@ -314,7 +315,7 @@ int signals(int (*init_proc)(void *), void *sp) ...@@ -314,7 +315,7 @@ int signals(int (*init_proc)(void *), void *sp)
ptrace(PTRACE_KILL, pid, 0, 0); ptrace(PTRACE_KILL, pid, 0, 0);
return(op == OP_REBOOT); return(op == OP_REBOOT);
case OP_NONE: case OP_NONE:
printk("Detaching pid %d\n", pid); printf("Detaching pid %d\n", pid);
detach(pid, SIGSTOP); detach(pid, SIGSTOP);
continue; continue;
default: default:
......
...@@ -104,7 +104,7 @@ static int __init set_tty_log_fd(char *name, int *add) ...@@ -104,7 +104,7 @@ static int __init set_tty_log_fd(char *name, int *add)
tty_log_fd = strtoul(name, &end, 0); tty_log_fd = strtoul(name, &end, 0);
if(*end != '\0'){ if(*end != '\0'){
printk("set_tty_log_dir - strtoul failed on '%s'\n", name); printk("set_tty_log_fd - strtoul failed on '%s'\n", name);
tty_log_fd = -1; tty_log_fd = -1;
} }
return 0; return 0;
......
...@@ -316,11 +316,12 @@ int linux_main(int argc, char **argv) ...@@ -316,11 +316,12 @@ int linux_main(int argc, char **argv)
end_vm = start_vm + virtmem_size; end_vm = start_vm + virtmem_size;
if(virtmem_size < physmem_size) if(virtmem_size < physmem_size)
printk(KERN_INFO "Kernel virtual memory size shrunk to %ld " printf("Kernel virtual memory size shrunk to %ld bytes\n",
"bytes\n", virtmem_size); virtmem_size);
err = reserve_vm(high_physmem, end_vm, &kernel_vm_reserved); err = reserve_vm(high_physmem, end_vm, &kernel_vm_reserved);
if(err) panic("Failed to reserve VM area for kernel VM\n"); if(err)
tracer_panic("Failed to reserve VM area for kernel VM\n");
uml_postsetup(); uml_postsetup();
......
/* /*
* Copyright (C) 2000, 2001 Jeff Dike (jdike@karaya.com) * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
* Licensed under the GPL * Licensed under the GPL
*/ */
...@@ -184,85 +184,6 @@ void setup_hostinfo(void) ...@@ -184,85 +184,6 @@ void setup_hostinfo(void)
host.release, host.version, host.machine); host.release, host.version, host.machine);
} }
void close_fd(int fd)
{
close(fd);
}
char *tempdir = NULL;
static void __init find_tempdir(void)
{
char *dirs[] = { "TMP", "TEMP", "TMPDIR", NULL };
int i;
char *dir = NULL;
if(tempdir != NULL) return; /* We've already been called */
for(i = 0; dirs[i]; i++){
dir = getenv(dirs[i]);
if(dir != NULL) break;
}
if(dir == NULL) dir = "/tmp";
else if(*dir == '\0') dir = NULL;
if(dir != NULL) {
tempdir = malloc(strlen(dir) + 2);
if(tempdir == NULL){
fprintf(stderr, "Failed to malloc tempdir, "
"errno = %d\n", errno);
return;
}
strcpy(tempdir, dir);
strcat(tempdir, "/");
}
}
int make_tempfile(const char *template, char **out_tempname, int do_unlink)
{
char tempname[MAXPATHLEN];
int fd;
find_tempdir();
if (*template != '/')
strcpy(tempname, tempdir);
else
*tempname = 0;
strcat(tempname, template);
if((fd = mkstemp(tempname)) < 0){
fprintf(stderr, "open - cannot create %s: %s\n", tempname,
strerror(errno));
return -1;
}
if(do_unlink && (unlink(tempname) < 0)){
perror("unlink");
return -1;
}
if(out_tempname){
if((*out_tempname = strdup(tempname)) == NULL){
perror("strdup");
return -1;
}
}
return(fd);
}
int user_read(int fd, char *buf, int len)
{
int err;
err = read(fd, buf, len);
if(err < 0) return(-errno);
else return(err);
}
int user_write(int fd, char *buf, int len)
{
int err;
err = write(fd, buf, len);
if(err < 0) return(-errno);
else return(err);
}
/* /*
* 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
......
...@@ -30,6 +30,7 @@ Jeff Dike (jdike@karaya.com) : Modified for integration into uml ...@@ -30,6 +30,7 @@ Jeff Dike (jdike@karaya.com) : Modified for integration into uml
#include "user_util.h" #include "user_util.h"
#include "user.h" #include "user.h"
#include "os.h" #include "os.h"
#include "tempfile.h"
static int debugger_wait(debugger_state *debugger, int *status, int options, static int debugger_wait(debugger_state *debugger, int *status, int options,
int (*syscall)(debugger_state *debugger, pid_t child), int (*syscall)(debugger_state *debugger, pid_t child),
......
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