Commit 629efb70 authored by Jeff Dike's avatar Jeff Dike

Merged in the C99 initializer changes.

parents 55014c58 e46b25f0
...@@ -35,7 +35,7 @@ void line_timer_cb(void *arg) ...@@ -35,7 +35,7 @@ void line_timer_cb(void *arg)
line_interrupt(dev->driver->read_irq, dev, NULL); line_interrupt(dev->driver->read_irq, dev, NULL);
} }
void buffer_data(struct line *line, const char *buf, int len) static void buffer_data(struct line *line, const char *buf, int len)
{ {
int end; int end;
......
...@@ -31,7 +31,6 @@ struct port_list { ...@@ -31,7 +31,6 @@ struct port_list {
struct port_dev { struct port_dev {
struct port_list *port; struct port_list *port;
int fd;
int helper_pid; int helper_pid;
int telnetd_pid; int telnetd_pid;
}; };
...@@ -55,7 +54,8 @@ static void pipe_interrupt(int irq, void *data, struct pt_regs *regs) ...@@ -55,7 +54,8 @@ static void pipe_interrupt(int irq, void *data, struct pt_regs *regs)
if(fd == -EAGAIN) if(fd == -EAGAIN)
return; return;
printk("os_rcv_fd returned %d\n", -fd); printk(KERN_ERR "pipe_interrupt : os_rcv_fd returned %d\n",
-fd);
os_close_file(conn->fd); os_close_file(conn->fd);
} }
...@@ -75,13 +75,15 @@ static int port_accept(struct port_list *port) ...@@ -75,13 +75,15 @@ static int port_accept(struct port_list *port)
fd = port_connection(port->fd, socket, &pid); fd = port_connection(port->fd, socket, &pid);
if(fd < 0){ if(fd < 0){
if(fd != -EAGAIN) if(fd != -EAGAIN)
printk("port_connection returned %d\n", -fd); printk(KERN_ERR "port_accept : port_connection "
"returned %d\n", -fd);
goto out; goto out;
} }
conn = kmalloc(sizeof(*conn), GFP_ATOMIC); conn = kmalloc(sizeof(*conn), GFP_ATOMIC);
if(conn == NULL){ if(conn == NULL){
printk("port_interrupt : failed to allocate connection\n"); printk(KERN_ERR "port_accept : failed to allocate "
"connection\n");
goto out_close; goto out_close;
} }
*conn = ((struct connection) *conn = ((struct connection)
...@@ -94,7 +96,8 @@ static int port_accept(struct port_list *port) ...@@ -94,7 +96,8 @@ static int port_accept(struct port_list *port)
if(um_request_irq(TELNETD_IRQ, socket[0], IRQ_READ, pipe_interrupt, if(um_request_irq(TELNETD_IRQ, socket[0], IRQ_READ, pipe_interrupt,
SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM, SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM,
"telnetd", conn)){ "telnetd", conn)){
printk(KERN_ERR "Failed to get IRQ for telnetd\n"); printk(KERN_ERR "port_accept : failed to get IRQ for "
"telnetd\n");
goto out_free; goto out_free;
} }
...@@ -106,7 +109,8 @@ static int port_accept(struct port_list *port) ...@@ -106,7 +109,8 @@ static int port_accept(struct port_list *port)
kfree(conn); kfree(conn);
out_close: out_close:
os_close_file(fd); os_close_file(fd);
if(pid != -1) os_kill_process(pid, 0); if(pid != -1)
os_kill_process(pid, 0);
out: out:
return(ret); return(ret);
} }
...@@ -206,38 +210,16 @@ void *port_data(int port_num) ...@@ -206,38 +210,16 @@ void *port_data(int port_num)
return(dev); return(dev);
} }
void port_remove_dev(void *d)
{
struct port_dev *dev = d;
if(dev->helper_pid != -1)
os_kill_process(dev->helper_pid, 0);
if(dev->telnetd_pid != -1)
os_kill_process(dev->telnetd_pid, 0);
dev->helper_pid = -1;
}
static void free_port(void)
{
struct list_head *ele;
struct port_list *port;
list_for_each(ele, &ports){
port = list_entry(ele, struct port_list, list);
os_close_file(port->fd);
}
}
__uml_exitcall(free_port);
int port_wait(void *data) int port_wait(void *data)
{ {
struct port_dev *dev = data; struct port_dev *dev = data;
struct connection *conn; struct connection *conn;
struct port_list *port = dev->port; struct port_list *port = dev->port;
int fd;
while(1){ while(1){
if(down_interruptible(&port->sem)) return(-ERESTARTSYS); if(down_interruptible(&port->sem))
return(-ERESTARTSYS);
spin_lock(&port->lock); spin_lock(&port->lock);
...@@ -264,23 +246,48 @@ int port_wait(void *data) ...@@ -264,23 +246,48 @@ int port_wait(void *data)
kfree(conn); kfree(conn);
} }
dev->fd = conn->fd; fd = conn->fd;
dev->helper_pid = conn->helper_pid; dev->helper_pid = conn->helper_pid;
dev->telnetd_pid = conn->telnetd_pid; dev->telnetd_pid = conn->telnetd_pid;
kfree(conn); kfree(conn);
return(dev->fd); return(fd);
}
void port_remove_dev(void *d)
{
struct port_dev *dev = d;
if(dev->helper_pid != -1)
os_kill_process(dev->helper_pid, 0);
if(dev->telnetd_pid != -1)
os_kill_process(dev->telnetd_pid, 0);
dev->helper_pid = -1;
dev->telnetd_pid = -1;
} }
void port_kern_free(void *d) void port_kern_free(void *d)
{ {
struct port_dev *dev = d; struct port_dev *dev = d;
if(dev->helper_pid != -1) os_kill_process(dev->telnetd_pid, 0); port_remove_dev(dev);
if(dev->telnetd_pid != -1) os_kill_process(dev->telnetd_pid, 0);
kfree(dev); kfree(dev);
} }
static void free_port(void)
{
struct list_head *ele;
struct port_list *port;
list_for_each(ele, &ports){
port = list_entry(ele, struct port_list, list);
free_irq_by_fd(port->fd);
os_close_file(port->fd);
}
}
__uml_exitcall(free_port);
/* /*
* 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
......
...@@ -47,14 +47,28 @@ void *port_init(char *str, int device, struct chan_opts *opts) ...@@ -47,14 +47,28 @@ void *port_init(char *str, int device, struct chan_opts *opts)
return(NULL); return(NULL);
} }
if((kern_data = port_data(port)) == NULL) return(NULL); if((kern_data = port_data(port)) == NULL)
return(NULL);
if((data = um_kmalloc(sizeof(*data))) == NULL)
goto err;
if((data = um_kmalloc(sizeof(*data))) == NULL) return(NULL); *data = ((struct port_chan) { .raw = opts->raw,
*data = ((struct port_chan) { raw : opts->raw, .kernel_data = kern_data });
kernel_data : kern_data });
sprintf(data->dev, "%d", port); sprintf(data->dev, "%d", port);
return(data); return(data);
err:
port_kern_free(kern_data);
return(NULL);
}
void port_free(void *d)
{
struct port_chan *data = d;
port_kern_free(data->kernel_data);
kfree(data);
} }
int port_open(int input, int output, int primary, void *d, char **dev_out) int port_open(int input, int output, int primary, void *d, char **dev_out)
...@@ -86,25 +100,17 @@ int port_console_write(int fd, const char *buf, int n, void *d) ...@@ -86,25 +100,17 @@ int port_console_write(int fd, const char *buf, int n, void *d)
return(generic_console_write(fd, buf, n, &data->tt)); return(generic_console_write(fd, buf, n, &data->tt));
} }
void port_free(void *d)
{
struct port_chan *data = d;
port_kern_free(data->kernel_data);
kfree(data);
}
struct chan_ops port_ops = { struct chan_ops port_ops = {
type: "port", .type = "port",
init: port_init, .init = port_init,
open: port_open, .open = port_open,
close: port_close, .close = port_close,
read: generic_read, .read = generic_read,
write: generic_write, .write = generic_write,
console_write: port_console_write, .console_write = port_console_write,
window_size: generic_window_size, .window_size = generic_window_size,
free: port_free, .free = port_free,
winch: 1, .winch = 1,
}; };
int port_listen_fd(int port) int port_listen_fd(int port)
...@@ -113,7 +119,8 @@ int port_listen_fd(int port) ...@@ -113,7 +119,8 @@ int port_listen_fd(int port)
int fd, err; int fd, err;
fd = socket(PF_INET, SOCK_STREAM, 0); fd = socket(PF_INET, SOCK_STREAM, 0);
if(fd == -1) return(-errno); if(fd == -1)
return(-errno);
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_port = htons(port); addr.sin_port = htons(port);
...@@ -163,14 +170,16 @@ int port_connection(int fd, int *socket, int *pid_out) ...@@ -163,14 +170,16 @@ int port_connection(int fd, int *socket, int *pid_out)
return(-errno); return(-errno);
err = os_pipe(socket, 0, 0); err = os_pipe(socket, 0, 0);
if(err) goto out_close; if(err)
goto out_close;
data = ((struct port_pre_exec_data) data = ((struct port_pre_exec_data)
{ sock_fd : new, { .sock_fd = new,
pipe_fd : socket[1] }); .pipe_fd = socket[1] });
err = run_helper(port_pre_exec, &data, argv, NULL); err = run_helper(port_pre_exec, &data, argv, NULL);
if(err < 0) goto out_shutdown; if(err < 0)
goto out_shutdown;
*pid_out = err; *pid_out = err;
return(new); return(new);
......
/* /*
* Copyright (C) 2001 Jeff Dike (jdike@karaya.com) * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
* Licensed under the GPL * Licensed under the GPL
*/ */
...@@ -86,34 +86,15 @@ int getmaster(char *line) ...@@ -86,34 +86,15 @@ int getmaster(char *line)
return(-1); return(-1);
} }
struct grantpt_info {
int fd;
int res;
int err;
};
static void grantpt_cb(void *arg)
{
struct grantpt_info *info = arg;
info->res = grantpt(info->fd);
info->err = errno;
}
int pty_open(int input, int output, int primary, void *d, char **dev_out) int pty_open(int input, int output, int primary, void *d, char **dev_out)
{ {
struct pty_chan *data = d; struct pty_chan *data = d;
int fd; int fd;
char dev[sizeof("/dev/ptyxx\0")] = "/dev/ptyxx"; char dev[sizeof("/dev/ptyxx\0")] = "/dev/ptyxx";
struct grantpt_info info;
fd = getmaster(dev); fd = getmaster(dev);
if(fd < 0) return(-errno); if(fd < 0) return(-errno);
info.fd = fd;
initial_thread_cb(grantpt_cb, &info);
unlockpt(fd);
if(data->raw) raw(fd, 0); if(data->raw) raw(fd, 0);
if(data->announce) (*data->announce)(dev, data->dev); if(data->announce) (*data->announce)(dev, data->dev);
......
/* /*
* Copyright (C) 2001 Jeff Dike (jdike@karaya.com) * Copyright (C) 2001, 2002 Jeff Dike (jdike@karaya.com)
* Licensed under the GPL * Licensed under the GPL
*/ */
#ifndef __SIGNAL_KERN_H__ #ifndef __SIGNAL_KERN_H__
#define __SIGNAL_KERN_H__ #define __SIGNAL_KERN_H__
#include "sysdep/ptrace.h"
extern void signal_deliverer(int sig);
extern int probe_stack(unsigned long sp, int delta);
extern int have_signals(void *t); extern int have_signals(void *t);
#endif #endif
......
...@@ -3,8 +3,13 @@ ...@@ -3,8 +3,13 @@
* Licensed under the GPL * Licensed under the GPL
*/ */
#ifndef __UMID_H__
#define __UMID_H__
extern int umid_file_name(char *name, char *buf, int len); extern int umid_file_name(char *name, char *buf, int len);
#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
......
...@@ -78,7 +78,8 @@ static int capture_stack(int (*child)(void *arg), void *arg, void *sp, ...@@ -78,7 +78,8 @@ static int capture_stack(int (*child)(void *arg), void *arg, void *sp,
/* It has outlived its usefulness, so continue it so it can exit */ /* It has outlived its usefulness, so continue it so it can exit */
if(ptrace(PTRACE_CONT, pid, 0, 0) < 0){ if(ptrace(PTRACE_CONT, pid, 0, 0) < 0){
printf("capture_stack : mmap failed - errno = %d\n", errno); printf("capture_stack : PTRACE_CONT failed - errno = %d\n",
errno);
exit(1); exit(1);
} }
if(waitpid(pid, &status, 0) < 0){ if(waitpid(pid, &status, 0) < 0){
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "asm/processor.h" #include "asm/processor.h"
#include "asm/unistd.h" #include "asm/unistd.h"
#include "asm/pgalloc.h" #include "asm/pgalloc.h"
#include "asm/pgtable.h"
#include "asm/page.h" #include "asm/page.h"
#include "asm/tlbflush.h" #include "asm/tlbflush.h"
#include "kern_util.h" #include "kern_util.h"
...@@ -42,7 +43,11 @@ EXPORT_SYMBOL(page_to_phys); ...@@ -42,7 +43,11 @@ EXPORT_SYMBOL(page_to_phys);
EXPORT_SYMBOL(phys_to_page); EXPORT_SYMBOL(phys_to_page);
EXPORT_SYMBOL(high_physmem); EXPORT_SYMBOL(high_physmem);
EXPORT_SYMBOL(empty_zero_page); EXPORT_SYMBOL(empty_zero_page);
EXPORT_SYMBOL(um_virt_to_phys);
EXPORT_SYMBOL(mode_tt);
EXPORT_SYMBOL(handle_page_fault);
EXPORT_SYMBOL(os_getpid);
EXPORT_SYMBOL(os_open_file); EXPORT_SYMBOL(os_open_file);
EXPORT_SYMBOL(os_read_file); EXPORT_SYMBOL(os_read_file);
EXPORT_SYMBOL(os_write_file); EXPORT_SYMBOL(os_write_file);
......
...@@ -420,7 +420,8 @@ int read_sigio_fd(int fd) ...@@ -420,7 +420,8 @@ int read_sigio_fd(int fd)
static void sigio_cleanup(void) static void sigio_cleanup(void)
{ {
if(write_sigio_pid != -1) kill(write_sigio_pid, SIGKILL); if(write_sigio_pid != -1)
kill(write_sigio_pid, SIGKILL);
} }
__uml_exitcall(sigio_cleanup); __uml_exitcall(sigio_cleanup);
......
...@@ -29,18 +29,6 @@ ...@@ -29,18 +29,6 @@
EXPORT_SYMBOL(block_signals); EXPORT_SYMBOL(block_signals);
EXPORT_SYMBOL(unblock_signals); EXPORT_SYMBOL(unblock_signals);
int probe_stack(unsigned long sp, int delta)
{
int n;
if((get_user(n, (int *) sp) != 0) ||
(put_user(n, (int *) sp) != 0) ||
(get_user(n, (int *) (sp - delta)) != 0) ||
(put_user(n, (int *) (sp - delta)) != 0))
return(-EFAULT);
return(0);
}
static void force_segv(int sig) static void force_segv(int sig)
{ {
if(sig == SIGSEGV){ if(sig == SIGSEGV){
......
...@@ -27,9 +27,6 @@ static inline int verify_area_skas(int type, const void * addr, ...@@ -27,9 +27,6 @@ static inline int verify_area_skas(int type, const void * addr,
return(access_ok_skas(type, addr, size) ? 0 : -EFAULT); return(access_ok_skas(type, addr, size) ? 0 : -EFAULT);
} }
extern void *um_virt_to_phys(struct task_struct *task, unsigned long virt,
pte_t *pte_out);
static inline unsigned long maybe_map(unsigned long virt, int is_write) static inline unsigned long maybe_map(unsigned long virt, int is_write)
{ {
pte_t pte; pte_t pte;
......
...@@ -99,7 +99,6 @@ static void flush_kernel_vm_range(unsigned long start, unsigned long end) ...@@ -99,7 +99,6 @@ static void flush_kernel_vm_range(unsigned long start, unsigned long end)
protect_memory(addr, PAGE_SIZE, 1, 1, 1, 1); protect_memory(addr, PAGE_SIZE, 1, 1, 1, 1);
} }
addr += PAGE_SIZE; addr += PAGE_SIZE;
} }
else { else {
if(pmd_newpage(*pmd)){ if(pmd_newpage(*pmd)){
......
...@@ -108,7 +108,7 @@ void idle_sleep(int secs) ...@@ -108,7 +108,7 @@ void idle_sleep(int secs)
ts.tv_sec = secs; ts.tv_sec = secs;
ts.tv_nsec = 0; ts.tv_nsec = 0;
nanosleep(&ts, &ts); nanosleep(&ts, NULL);
} }
/* /*
......
...@@ -109,7 +109,8 @@ unsigned long segv(unsigned long address, unsigned long ip, int is_write, ...@@ -109,7 +109,8 @@ unsigned long segv(unsigned long address, unsigned long ip, int is_write,
flush_tlb_kernel_vm(); flush_tlb_kernel_vm();
return(0); return(0);
} }
if(current->mm == NULL) panic("Segfault with no mm"); if(current->mm == NULL)
panic("Segfault with no mm");
err = handle_page_fault(address, ip, is_write, is_user, &si.si_code); err = handle_page_fault(address, ip, is_write, is_user, &si.si_code);
catcher = current->thread.fault_catcher; catcher = current->thread.fault_catcher;
......
...@@ -13,9 +13,9 @@ extern int gdb_config(char *str); ...@@ -13,9 +13,9 @@ extern int gdb_config(char *str);
extern int gdb_remove(char *unused); extern int gdb_remove(char *unused);
static struct mc_device gdb_mc = { static struct mc_device gdb_mc = {
name: "gdb", .name = "gdb",
config: gdb_config, .config = gdb_config,
remove: gdb_remove, .remove = gdb_remove,
}; };
int gdb_mc_init(void) int gdb_mc_init(void)
......
...@@ -317,6 +317,11 @@ int linux_main(int argc, char **argv) ...@@ -317,6 +317,11 @@ int linux_main(int argc, char **argv)
if(physmem_size > max_physmem){ if(physmem_size > max_physmem){
highmem = physmem_size - max_physmem; highmem = physmem_size - max_physmem;
physmem_size -= highmem; physmem_size -= highmem;
#ifndef CONFIG_HIGHMEM
highmem = 0;
printf("CONFIG_HIGHMEM not enabled - physical memory shrunk "
"to %ld bytes\n", physmem_size);
#endif
} }
high_physmem = uml_physmem + physmem_size; high_physmem = uml_physmem + physmem_size;
......
...@@ -186,7 +186,6 @@ int not_dead_yet(char *dir) ...@@ -186,7 +186,6 @@ int not_dead_yet(char *dir)
} }
if(!dead) return(1); if(!dead) return(1);
return(actually_do_remove(dir)); return(actually_do_remove(dir));
return(0);
} }
static int __init set_uml_dir(char *name, int *add) static int __init set_uml_dir(char *name, int *add)
......
...@@ -9,6 +9,7 @@ USER_OBJS := bugs.o ptrace_user.o sigcontext.o fault.o ...@@ -9,6 +9,7 @@ USER_OBJS := bugs.o ptrace_user.o sigcontext.o fault.o
USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file)) USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
SYMLINKS = semaphore.c extable.c highmem.c module.c SYMLINKS = semaphore.c extable.c highmem.c module.c
SYMLINKS := $(foreach f,$(SYMLINKS),$(src)/$f)
semaphore.c-dir = kernel semaphore.c-dir = kernel
extable.c-dir = mm extable.c-dir = mm
...@@ -23,7 +24,7 @@ endef ...@@ -23,7 +24,7 @@ endef
$(USER_OBJS) : %.o: %.c $(USER_OBJS) : %.o: %.c
$(CC) $(CFLAGS_$(notdir $@)) $(USER_CFLAGS) -c -o $@ $< $(CC) $(CFLAGS_$(notdir $@)) $(USER_CFLAGS) -c -o $@ $<
$(foreach f,$(SYMLINKS),$(src)/$f): $(SYMLINKS):
$(call make_link,$@) $(call make_link,$@)
clean: clean:
......
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
extern pgd_t swapper_pg_dir[1024]; extern pgd_t swapper_pg_dir[1024];
extern void *um_virt_to_phys(struct task_struct *task, unsigned long virt,
pte_t *pte_out);
/* zero page used for uninitialized stuff */ /* zero page used for uninitialized stuff */
extern unsigned long *empty_zero_page; extern unsigned long *empty_zero_page;
......
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