Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

uml: tidy kern_util.h

Tidy kern_util.h. It turns out that most of the function declarations
aren't used, so they can go away. os.h no longer includes
kern_util.h, so files which got it through os.h now need to include it
directly. A number of other files never needed it, so these includes
are deleted.

The structure which was used to pass signal handlers from the kernel
side to the userspace side is gone. Instead, the handlers are
declared here, and used directly from libc code. This allows
arch/um/os-Linux/trap.c to be deleted, with its remnants being moved
to arch/um/os-Linux/skas/trap.c.

arch/um/os-Linux/tty.c had its inclusions changed, and it needed some
style attention, so it got tidied.

Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Jeff Dike and committed by
Linus Torvalds
edea1385 0ba7fe03

+91 -175
+1
arch/um/drivers/line.c
··· 8 8 #include "chan_kern.h" 9 9 #include "irq_kern.h" 10 10 #include "irq_user.h" 11 + #include "kern_util.h" 11 12 #include "os.h" 12 13 13 14 #define LINE_BUFSIZE 4096
-1
arch/um/drivers/ssl.c
··· 15 15 #include "line.h" 16 16 #include "ssl.h" 17 17 #include "chan_kern.h" 18 - #include "kern_util.h" 19 18 #include "kern.h" 20 19 #include "init.h" 21 20 #include "irq_user.h"
-1
arch/um/drivers/stdio_console.c
··· 22 22 #include "stdio_console.h" 23 23 #include "line.h" 24 24 #include "chan_kern.h" 25 - #include "kern_util.h" 26 25 #include "irq_user.h" 27 26 #include "mconsole_kern.h" 28 27 #include "init.h"
+1
arch/um/drivers/ubd_kern.c
··· 49 49 #include "irq_user.h" 50 50 #include "irq_kern.h" 51 51 #include "ubd_user.h" 52 + #include "kern_util.h" 52 53 #include "os.h" 53 54 #include "mem.h" 54 55 #include "mem_kern.h"
-1
arch/um/drivers/ubd_user.c
··· 16 16 #include <sys/mman.h> 17 17 #include <sys/param.h> 18 18 #include "asm/types.h" 19 - #include "kern_util.h" 20 19 #include "user.h" 21 20 #include "ubd_user.h" 22 21 #include "os.h"
+37 -85
arch/um/include/kern_util.h
··· 9 9 #include "sysdep/ptrace.h" 10 10 #include "sysdep/faultinfo.h" 11 11 12 - typedef void (*kern_hndl)(int, struct uml_pt_regs *); 13 - 14 - struct kern_handlers { 15 - kern_hndl relay_signal; 16 - kern_hndl winch; 17 - kern_hndl bus_handler; 18 - kern_hndl page_fault; 19 - kern_hndl sigio_handler; 20 - kern_hndl timer_handler; 21 - }; 22 - 23 - extern const struct kern_handlers handlinfo_kern; 24 - 25 12 extern int ncpus; 26 - extern char *gdb_init; 27 13 extern int kmalloc_ok; 28 - extern int jail; 29 14 extern int nsyscalls; 30 15 31 - #define UML_ROUND_DOWN(addr) ((void *)(((unsigned long) addr) & PAGE_MASK)) 32 16 #define UML_ROUND_UP(addr) \ 33 - UML_ROUND_DOWN(((unsigned long) addr) + PAGE_SIZE - 1) 17 + ((((unsigned long) addr) + PAGE_SIZE - 1) & PAGE_MASK) 34 18 35 - extern int kernel_fork(unsigned long flags, int (*fn)(void *), void * arg); 36 - extern int kernel_thread_proc(void *data); 37 - extern void syscall_segv(int sig); 38 - extern int current_pid(void); 39 19 extern unsigned long alloc_stack(int order, int atomic); 20 + extern void free_stack(unsigned long stack, int order); 21 + 40 22 extern int do_signal(void); 41 - extern int is_stack_fault(unsigned long sp); 23 + extern void copy_sc(struct uml_pt_regs *regs, void *from); 24 + extern void interrupt_end(void); 25 + extern void relay_signal(int sig, struct uml_pt_regs *regs); 26 + 42 27 extern unsigned long segv(struct faultinfo fi, unsigned long ip, 43 28 int is_user, struct uml_pt_regs *regs); 44 29 extern int handle_page_fault(unsigned long address, unsigned long ip, 45 30 int is_write, int is_user, int *code_out); 46 - extern void syscall_ready(void); 47 - extern void set_tracing(void *t, int tracing); 48 - extern int is_tracing(void *task); 49 - extern int segv_syscall(void); 50 - extern void kern_finish_exec(void *task, int new_pid, unsigned long stack); 51 - extern unsigned long page_mask(void); 52 - extern int need_finish_fork(void); 53 - extern void free_stack(unsigned long stack, int order); 54 - extern void add_input_request(int op, void (*proc)(int), void *arg); 55 - extern char *current_cmd(void); 56 - extern void timer_handler(int sig, struct uml_pt_regs *regs); 57 - extern int set_signals(int enable); 58 - extern int pid_to_processor_id(int pid); 59 - extern void deliver_signals(void *t); 60 - extern int next_trap_index(int max); 61 - extern void default_idle(void); 62 - extern void finish_fork(void); 63 - extern void paging_init(void); 64 - extern void init_flush_vm(void); 65 - extern void *syscall_sp(void *t); 66 - extern void syscall_trace(struct uml_pt_regs *regs, int entryexit); 31 + 67 32 extern unsigned int do_IRQ(int irq, struct uml_pt_regs *regs); 68 - extern void interrupt_end(void); 69 - extern void initial_thread_cb(void (*proc)(void *), void *arg); 70 - extern int debugger_signal(int status, int pid); 71 - extern void debugger_parent_signal(int status, int pid); 72 - extern void child_signal(int pid, int status); 73 - extern int init_ptrace_proxy(int idle_pid, int startup, int stop); 74 - extern int init_parent_proxy(int pid); 75 - extern int singlestepping(void *t); 76 - extern void check_stack_overflow(void *ptr); 77 - extern void relay_signal(int sig, struct uml_pt_regs *regs); 78 - extern int user_context(unsigned long sp); 79 - extern void timer_irq(struct uml_pt_regs *regs); 80 - extern void do_uml_exitcalls(void); 81 - extern int attach_debugger(int idle_pid, int pid, int stop); 82 - extern int config_gdb(char *str); 83 - extern int remove_gdb(void); 84 - extern char *uml_strdup(const char *string); 85 - extern void unprotect_kernel_mem(void); 86 - extern void protect_kernel_mem(void); 87 - extern void uml_cleanup(void); 88 - extern void lock_signalled_task(void *t); 89 - extern void IPI_handler(int cpu); 90 - extern int jail_setup(char *line, int *add); 91 - extern void *get_init_task(void); 92 - extern int clear_user_proc(void *buf, int size); 93 - extern int copy_to_user_proc(void *to, void *from, int size); 94 - extern int copy_from_user_proc(void *to, void *from, int size); 95 - extern int strlen_user_proc(char *str); 96 - extern long execute_syscall(void *r); 97 33 extern int smp_sigio_handler(void); 98 - extern void *get_current(void); 99 - extern struct task_struct *get_task(int pid, int require); 100 - extern void machine_halt(void); 34 + extern void initial_thread_cb(void (*proc)(void *), void *arg); 101 35 extern int is_syscall(unsigned long addr); 36 + extern void timer_handler(int sig, struct uml_pt_regs *regs); 102 37 103 - extern void free_irq(unsigned int, void *); 104 - extern int cpu(void); 38 + extern void timer_handler(int sig, struct uml_pt_regs *regs); 105 39 106 - extern void time_init_kern(void); 107 - 108 - /* Are we disallowed to sleep? Used to choose between GFP_KERNEL and GFP_ATOMIC. */ 109 - extern int __cant_sleep(void); 110 - extern void sigio_handler(int sig, struct uml_pt_regs *regs); 111 - extern void copy_sc(struct uml_pt_regs *regs, void *from); 112 - extern unsigned long to_irq_stack(unsigned long *mask_out); 113 - unsigned long from_irq_stack(int nested); 114 40 extern int start_uml(void); 41 + extern void paging_init(void); 42 + 43 + extern void uml_cleanup(void); 44 + extern void do_uml_exitcalls(void); 45 + 46 + /* 47 + * Are we disallowed to sleep? Used to choose between GFP_KERNEL and 48 + * GFP_ATOMIC. 49 + */ 50 + extern int __cant_sleep(void); 51 + extern void *get_current(void); 52 + extern int copy_from_user_proc(void *to, void *from, int size); 53 + extern int cpu(void); 54 + extern char *uml_strdup(const char *string); 55 + 56 + extern unsigned long to_irq_stack(unsigned long *mask_out); 57 + extern unsigned long from_irq_stack(int nested); 58 + 59 + extern void syscall_trace(struct uml_pt_regs *regs, int entryexit); 60 + extern int singlestepping(void *t); 61 + 62 + extern void segv_handler(int sig, struct uml_pt_regs *regs); 63 + extern void bus_handler(int sig, struct uml_pt_regs *regs); 64 + extern void winch(int sig, struct uml_pt_regs *regs); 65 + 66 + 115 67 #endif
-4
arch/um/include/os.h
··· 8 8 9 9 #include <stdarg.h> 10 10 #include "irq_user.h" 11 - #include "kern_util.h" 12 11 #include "longjmp.h" 13 12 #include "mm_id.h" 14 13 #include "sysdep/tls.h" ··· 235 236 extern void unblock_signals(void); 236 237 extern int get_signals(void); 237 238 extern int set_signals(int enable); 238 - 239 - /* trap.c */ 240 - extern void os_fill_handlinfo(struct kern_handlers h); 241 239 242 240 /* util.c */ 243 241 extern void stack_protections(unsigned long address);
-1
arch/um/kernel/initrd.c
··· 7 7 #include "linux/bootmem.h" 8 8 #include "linux/initrd.h" 9 9 #include "asm/types.h" 10 - #include "kern_util.h" 11 10 #include "initrd.h" 12 11 #include "init.h" 13 12 #include "os.h"
+1
arch/um/kernel/reboot.c
··· 4 4 */ 5 5 6 6 #include "linux/sched.h" 7 + #include "kern_util.h" 7 8 #include "os.h" 8 9 #include "skas.h" 9 10
-1
arch/um/kernel/smp.c
··· 21 21 #include "asm/smp.h" 22 22 #include "asm/processor.h" 23 23 #include "asm/spinlock.h" 24 - #include "kern_util.h" 25 24 #include "kern.h" 26 25 #include "irq_user.h" 27 26 #include "os.h"
+3 -12
arch/um/kernel/trap.c
··· 128 128 force_sig_info(SIGSEGV, &si, current); 129 129 } 130 130 131 - static void segv_handler(int sig, struct uml_pt_regs *regs) 131 + void segv_handler(int sig, struct uml_pt_regs *regs) 132 132 { 133 133 struct faultinfo * fi = UPT_FAULTINFO(regs); 134 134 ··· 229 229 force_sig(sig, current); 230 230 } 231 231 232 - static void bus_handler(int sig, struct uml_pt_regs *regs) 232 + void bus_handler(int sig, struct uml_pt_regs *regs) 233 233 { 234 234 if (current->thread.fault_catcher != NULL) 235 235 UML_LONGJMP(current->thread.fault_catcher, 1); 236 236 else relay_signal(sig, regs); 237 237 } 238 238 239 - static void winch(int sig, struct uml_pt_regs *regs) 239 + void winch(int sig, struct uml_pt_regs *regs) 240 240 { 241 241 do_IRQ(WINCH_IRQ, regs); 242 242 } 243 - 244 - const struct kern_handlers handlinfo_kern = { 245 - .relay_signal = relay_signal, 246 - .winch = winch, 247 - .bus_handler = bus_handler, 248 - .page_fault = segv_handler, 249 - .sigio_handler = sigio_handler, 250 - .timer_handler = timer_handler 251 - }; 252 243 253 244 void trap_init(void) 254 245 {
+1 -5
arch/um/kernel/um_arch.c
··· 16 16 #include "as-layout.h" 17 17 #include "init.h" 18 18 #include "kern.h" 19 + #include "kern_util.h" 19 20 #include "mem_user.h" 20 21 #include "os.h" 21 22 #include "skas.h" ··· 280 279 printf("UML running in %s mode\n", mode); 281 280 282 281 host_task_size = set_task_sizes_skas(&task_size); 283 - 284 - /* 285 - * Setting up handlers to 'sig_info' struct 286 - */ 287 - os_fill_handlinfo(handlinfo_kern); 288 282 289 283 brk_start = (unsigned long) sbrk(0); 290 284
+2 -2
arch/um/os-Linux/Makefile
··· 4 4 # 5 5 6 6 obj-y = aio.o elf_aux.o execvp.o file.o helper.o irq.o main.o mem.o process.o \ 7 - registers.o sigio.o signal.o start_up.o time.o trap.o tty.o uaccess.o \ 7 + registers.o sigio.o signal.o start_up.o time.o tty.o uaccess.o \ 8 8 umid.o tls.o user_syms.o util.o drivers/ sys-$(SUBARCH)/ skas/ 9 9 10 10 obj-$(CONFIG_TTY_LOG) += tty_log.o ··· 12 12 13 13 USER_OBJS := $(user-objs-y) aio.o elf_aux.o execvp.o file.o helper.o irq.o \ 14 14 main.o mem.o process.o registers.o sigio.o signal.o start_up.o time.o \ 15 - trap.o tty.o tls.o uaccess.o umid.o util.o 15 + tty.o tls.o uaccess.o umid.o util.o 16 16 17 17 CFLAGS_user_syms.o += -DSUBARCH_$(SUBARCH) 18 18
+1
arch/um/os-Linux/aio.c
··· 12 12 #include "aio.h" 13 13 #include "init.h" 14 14 #include "kern_constants.h" 15 + #include "kern_util.h" 15 16 #include "os.h" 16 17 #include "user.h" 17 18
+1
arch/um/os-Linux/drivers/tuntap_user.c
··· 14 14 #include <sys/wait.h> 15 15 #include <sys/uio.h> 16 16 #include "kern_constants.h" 17 + #include "kern_util.h" 17 18 #include "os.h" 18 19 #include "tuntap.h" 19 20 #include "user.h"
-1
arch/um/os-Linux/file.c
··· 17 17 #include <sys/uio.h> 18 18 #include "os.h" 19 19 #include "user.h" 20 - #include "kern_util.h" 21 20 22 21 static void copy_stat(struct uml_stat *dst, const struct stat64 *src) 23 22 {
-1
arch/um/os-Linux/irq.c
··· 11 11 #include <sys/poll.h> 12 12 #include <sys/types.h> 13 13 #include <sys/time.h> 14 - #include "kern_util.h" 15 14 #include "user.h" 16 15 #include "process.h" 17 16 #include "sigio.h"
-1
arch/um/os-Linux/mem.c
··· 9 9 #include <sys/types.h> 10 10 #include <sys/mman.h> 11 11 #include <sys/statfs.h> 12 - #include "kern_util.h" 13 12 #include "user.h" 14 13 #include "mem_user.h" 15 14 #include "init.h"
+1
arch/um/os-Linux/signal.c
··· 9 9 #include <errno.h> 10 10 #include <signal.h> 11 11 #include <strings.h> 12 + #include "kern_util.h" 12 13 #include "os.h" 13 14 #include "sysdep/barrier.h" 14 15 #include "sysdep/sigcontext.h"
+1
arch/um/os-Linux/skas/process.c
··· 15 15 #include "as-layout.h" 16 16 #include "chan_user.h" 17 17 #include "kern_constants.h" 18 + #include "kern_util.h" 18 19 #include "mem.h" 19 20 #include "os.h" 20 21 #include "process.h"
+11 -7
arch/um/os-Linux/skas/trap.c
··· 3 3 * Licensed under the GPL 4 4 */ 5 5 6 - #if 0 7 - #include "kern_util.h" 8 - #include "skas.h" 9 - #include "ptrace_user.h" 10 - #include "sysdep/ptrace_user.h" 11 - #endif 12 - 13 6 #include <errno.h> 14 7 #include <signal.h> 15 8 #include "sysdep/ptrace.h" 16 9 #include "kern_constants.h" 17 10 #include "as-layout.h" 11 + #include "kern_util.h" 18 12 #include "os.h" 19 13 #include "sigcontext.h" 20 14 #include "task.h" 15 + 16 + void (*sig_info[NSIG])(int, struct uml_pt_regs *) = { 17 + [SIGTRAP] = relay_signal, 18 + [SIGFPE] = relay_signal, 19 + [SIGILL] = relay_signal, 20 + [SIGWINCH] = winch, 21 + [SIGBUS] = bus_handler, 22 + [SIGSEGV] = segv_handler, 23 + [SIGIO] = sigio_handler, 24 + [SIGVTALRM] = timer_handler }; 21 25 22 26 static struct uml_pt_regs ksig_regs[UM_NR_CPUS]; 23 27
-23
arch/um/os-Linux/trap.c
··· 1 - /* 2 - * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) 3 - * Licensed under the GPL 4 - */ 5 - 6 - #include <signal.h> 7 - #include "os.h" 8 - #include "sysdep/ptrace.h" 9 - 10 - /* Initialized from linux_main() */ 11 - void (*sig_info[NSIG])(int, struct uml_pt_regs *); 12 - 13 - void os_fill_handlinfo(struct kern_handlers h) 14 - { 15 - sig_info[SIGTRAP] = h.relay_signal; 16 - sig_info[SIGFPE] = h.relay_signal; 17 - sig_info[SIGILL] = h.relay_signal; 18 - sig_info[SIGWINCH] = h.winch; 19 - sig_info[SIGBUS] = h.bus_handler; 20 - sig_info[SIGSEGV] = h.page_fault; 21 - sig_info[SIGIO] = h.sigio_handler; 22 - sig_info[SIGVTALRM] = h.timer_handler; 23 - }
+29 -28
arch/um/os-Linux/tty.c
··· 1 - /* 2 - * Copyright (C) 2002 Jeff Dike (jdike@karaya.com) 1 + /* 2 + * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) 3 3 * Licensed under the GPL 4 4 */ 5 5 6 6 #include <stdlib.h> 7 + #include <unistd.h> 7 8 #include <errno.h> 9 + #include <fcntl.h> 10 + #include "kern_constants.h" 11 + #include "kern_util.h" 8 12 #include "os.h" 9 13 #include "user.h" 10 - #include "kern_util.h" 11 14 12 15 struct grantpt_info { 13 16 int fd; ··· 29 26 int get_pty(void) 30 27 { 31 28 struct grantpt_info info; 32 - int fd; 29 + int fd, err; 33 30 34 - fd = os_open_file("/dev/ptmx", of_rdwr(OPENFLAGS()), 0); 35 - if(fd < 0){ 36 - printk("get_pty : Couldn't open /dev/ptmx - err = %d\n", -fd); 37 - return(fd); 31 + fd = open("/dev/ptmx", O_RDWR); 32 + if (fd < 0) { 33 + err = -errno; 34 + printk(UM_KERN_ERR "get_pty : Couldn't open /dev/ptmx - " 35 + "err = %d\n", errno); 36 + return err; 38 37 } 39 38 40 39 info.fd = fd; 41 40 initial_thread_cb(grantpt_cb, &info); 42 41 43 - if(info.res < 0){ 44 - printk("get_pty : Couldn't grant pty - errno = %d\n", 45 - -info.err); 46 - return(-1); 42 + if (info.res < 0) { 43 + err = -info.err; 44 + printk(UM_KERN_ERR "get_pty : Couldn't grant pty - " 45 + "errno = %d\n", -info.err); 46 + goto out; 47 47 } 48 - if(unlockpt(fd) < 0){ 49 - printk("get_pty : Couldn't unlock pty - errno = %d\n", errno); 50 - return(-1); 51 - } 52 - return(fd); 53 - } 54 48 55 - /* 56 - * Overrides for Emacs so that we follow Linus's tabbing style. 57 - * Emacs will notice this stuff at the end of the file and automatically 58 - * adjust the settings for this buffer only. This must remain at the end 59 - * of the file. 60 - * --------------------------------------------------------------------------- 61 - * Local variables: 62 - * c-file-style: "linux" 63 - * End: 64 - */ 49 + if (unlockpt(fd) < 0) { 50 + err = -errno; 51 + printk(UM_KERN_ERR "get_pty : Couldn't unlock pty - " 52 + "errno = %d\n", errno); 53 + goto out; 54 + } 55 + return fd; 56 + out: 57 + close(fd); 58 + return err; 59 + }
-1
arch/um/os-Linux/tty_log.c
··· 12 12 #include <sys/time.h> 13 13 #include "init.h" 14 14 #include "user.h" 15 - #include "kern_util.h" 16 15 #include "os.h" 17 16 18 17 #define TTY_LOG_DIR "./"
+1
arch/um/sys-i386/bugs.c
··· 5 5 6 6 #include <signal.h> 7 7 #include "kern_constants.h" 8 + #include "kern_util.h" 8 9 #include "longjmp.h" 9 10 #include "task.h" 10 11 #include "user.h"