diff options
| author | Gennady Sharapov <Gennady.V.Sharapov@intel.com> | 2006-01-18 20:42:41 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-18 22:20:19 -0500 |
| commit | 4fef0c10fa174b57a10854b8b4b2b90d155706e0 (patch) | |
| tree | 02cfcc989114da9a6d46484753937cc0e3a60b52 /arch/um/kernel | |
| parent | 12919aa6e015dd85170fc3b1a3e10a5dfd116c72 (diff) | |
[PATCH] uml: move libc-dependent utility procedures
The serial UML OS-abstraction layer patch (um/kernel dir).
This moves all systemcalls from user_util.c file under os-Linux dir
Signed-off-by: Gennady Sharapov <Gennady.V.Sharapov@intel.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/kernel')
| -rw-r--r-- | arch/um/kernel/Makefile | 5 | ||||
| -rw-r--r-- | arch/um/kernel/skas/uaccess.c | 2 | ||||
| -rw-r--r-- | arch/um/kernel/tt/gdb.c | 1 | ||||
| -rw-r--r-- | arch/um/kernel/tt/ptproxy/ptrace.c | 1 | ||||
| -rw-r--r-- | arch/um/kernel/tt/ptproxy/sysdep.c | 1 | ||||
| -rw-r--r-- | arch/um/kernel/user_util.c | 174 |
6 files changed, 6 insertions, 178 deletions
diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile index 193cc2b7448d..165c8639c9f6 100644 --- a/arch/um/kernel/Makefile +++ b/arch/um/kernel/Makefile | |||
| @@ -10,8 +10,7 @@ obj-y = config.o exec_kern.o exitcode.o \ | |||
| 10 | init_task.o irq.o irq_user.o ksyms.o mem.o physmem.o \ | 10 | init_task.o irq.o irq_user.o ksyms.o mem.o physmem.o \ |
| 11 | process_kern.o ptrace.o reboot.o resource.o sigio_user.o sigio_kern.o \ | 11 | process_kern.o ptrace.o reboot.o resource.o sigio_user.o sigio_kern.o \ |
| 12 | signal_kern.o smp.o syscall_kern.o sysrq.o time.o \ | 12 | signal_kern.o smp.o syscall_kern.o sysrq.o time.o \ |
| 13 | time_kern.o tlb.o trap_kern.o uaccess.o um_arch.o umid.o \ | 13 | time_kern.o tlb.o trap_kern.o uaccess.o um_arch.o umid.o |
| 14 | user_util.o | ||
| 15 | 14 | ||
| 16 | obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o | 15 | obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o |
| 17 | obj-$(CONFIG_GPROF) += gprof_syms.o | 16 | obj-$(CONFIG_GPROF) += gprof_syms.o |
| @@ -24,7 +23,7 @@ obj-$(CONFIG_MODE_SKAS) += skas/ | |||
| 24 | 23 | ||
| 25 | user-objs-$(CONFIG_TTY_LOG) += tty_log.o | 24 | user-objs-$(CONFIG_TTY_LOG) += tty_log.o |
| 26 | 25 | ||
| 27 | USER_OBJS := $(user-objs-y) config.o time.o tty_log.o user_util.o | 26 | USER_OBJS := $(user-objs-y) config.o time.o tty_log.o |
| 28 | 27 | ||
| 29 | include arch/um/scripts/Makefile.rules | 28 | include arch/um/scripts/Makefile.rules |
| 30 | 29 | ||
diff --git a/arch/um/kernel/skas/uaccess.c b/arch/um/kernel/skas/uaccess.c index a5a47528dec7..5992c3257167 100644 --- a/arch/um/kernel/skas/uaccess.c +++ b/arch/um/kernel/skas/uaccess.c | |||
| @@ -13,7 +13,7 @@ | |||
| 13 | #include "asm/pgtable.h" | 13 | #include "asm/pgtable.h" |
| 14 | #include "asm/uaccess.h" | 14 | #include "asm/uaccess.h" |
| 15 | #include "kern_util.h" | 15 | #include "kern_util.h" |
| 16 | #include "user_util.h" | 16 | #include "os.h" |
| 17 | 17 | ||
| 18 | extern void *um_virt_to_phys(struct task_struct *task, unsigned long addr, | 18 | extern void *um_virt_to_phys(struct task_struct *task, unsigned long addr, |
| 19 | pte_t *pte_out); | 19 | pte_t *pte_out); |
diff --git a/arch/um/kernel/tt/gdb.c b/arch/um/kernel/tt/gdb.c index 37e22d71a0d9..786e4edd86c5 100644 --- a/arch/um/kernel/tt/gdb.c +++ b/arch/um/kernel/tt/gdb.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include "user_util.h" | 20 | #include "user_util.h" |
| 21 | #include "tt.h" | 21 | #include "tt.h" |
| 22 | #include "sysdep/thread.h" | 22 | #include "sysdep/thread.h" |
| 23 | #include "os.h" | ||
| 23 | 24 | ||
| 24 | extern int debugger_pid; | 25 | extern int debugger_pid; |
| 25 | extern int debugger_fd; | 26 | extern int debugger_fd; |
diff --git a/arch/um/kernel/tt/ptproxy/ptrace.c b/arch/um/kernel/tt/ptproxy/ptrace.c index 528a5fc8d887..03774427d468 100644 --- a/arch/um/kernel/tt/ptproxy/ptrace.c +++ b/arch/um/kernel/tt/ptproxy/ptrace.c | |||
| @@ -20,6 +20,7 @@ Jeff Dike (jdike@karaya.com) : Modified for integration into uml | |||
| 20 | #include "kern_util.h" | 20 | #include "kern_util.h" |
| 21 | #include "ptrace_user.h" | 21 | #include "ptrace_user.h" |
| 22 | #include "tt.h" | 22 | #include "tt.h" |
| 23 | #include "os.h" | ||
| 23 | 24 | ||
| 24 | long proxy_ptrace(struct debugger *debugger, int arg1, pid_t arg2, | 25 | long proxy_ptrace(struct debugger *debugger, int arg1, pid_t arg2, |
| 25 | long arg3, long arg4, pid_t child, int *ret) | 26 | long arg3, long arg4, pid_t child, int *ret) |
diff --git a/arch/um/kernel/tt/ptproxy/sysdep.c b/arch/um/kernel/tt/ptproxy/sysdep.c index a5f0e01e214e..99f178319d03 100644 --- a/arch/um/kernel/tt/ptproxy/sysdep.c +++ b/arch/um/kernel/tt/ptproxy/sysdep.c | |||
| @@ -15,6 +15,7 @@ terms and conditions. | |||
| 15 | #include "ptrace_user.h" | 15 | #include "ptrace_user.h" |
| 16 | #include "user_util.h" | 16 | #include "user_util.h" |
| 17 | #include "user.h" | 17 | #include "user.h" |
| 18 | #include "os.h" | ||
| 18 | 19 | ||
| 19 | int get_syscall(pid_t pid, long *arg1, long *arg2, long *arg3, long *arg4, | 20 | int get_syscall(pid_t pid, long *arg1, long *arg2, long *arg3, long *arg4, |
| 20 | long *arg5) | 21 | long *arg5) |
diff --git a/arch/um/kernel/user_util.c b/arch/um/kernel/user_util.c deleted file mode 100644 index 4c231161f257..000000000000 --- a/arch/um/kernel/user_util.c +++ /dev/null | |||
| @@ -1,174 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) | ||
| 3 | * Licensed under the GPL | ||
| 4 | */ | ||
| 5 | |||
| 6 | #include <stdio.h> | ||
| 7 | #include <stdlib.h> | ||
| 8 | #include <unistd.h> | ||
| 9 | #include <limits.h> | ||
| 10 | #include <setjmp.h> | ||
| 11 | #include <sys/mman.h> | ||
| 12 | #include <sys/stat.h> | ||
| 13 | #include <sys/utsname.h> | ||
| 14 | #include <sys/param.h> | ||
| 15 | #include <sys/time.h> | ||
| 16 | #include "asm/types.h" | ||
| 17 | #include <ctype.h> | ||
| 18 | #include <signal.h> | ||
| 19 | #include <wait.h> | ||
| 20 | #include <errno.h> | ||
| 21 | #include <stdarg.h> | ||
| 22 | #include <sched.h> | ||
| 23 | #include <termios.h> | ||
| 24 | #include <string.h> | ||
| 25 | #include "user_util.h" | ||
| 26 | #include "kern_util.h" | ||
| 27 | #include "user.h" | ||
| 28 | #include "mem_user.h" | ||
| 29 | #include "init.h" | ||
| 30 | #include "ptrace_user.h" | ||
| 31 | #include "uml-config.h" | ||
| 32 | |||
| 33 | void stop(void) | ||
| 34 | { | ||
| 35 | while(1) sleep(1000000); | ||
| 36 | } | ||
| 37 | |||
| 38 | void stack_protections(unsigned long address) | ||
| 39 | { | ||
| 40 | int prot = PROT_READ | PROT_WRITE | PROT_EXEC; | ||
| 41 | |||
| 42 | if(mprotect((void *) address, page_size(), prot) < 0) | ||
| 43 | panic("protecting stack failed, errno = %d", errno); | ||
| 44 | } | ||
| 45 | |||
| 46 | void task_protections(unsigned long address) | ||
| 47 | { | ||
| 48 | unsigned long guard = address + page_size(); | ||
| 49 | unsigned long stack = guard + page_size(); | ||
| 50 | int prot = 0, pages; | ||
| 51 | |||
| 52 | #ifdef notdef | ||
| 53 | if(mprotect((void *) stack, page_size(), prot) < 0) | ||
| 54 | panic("protecting guard page failed, errno = %d", errno); | ||
| 55 | #endif | ||
| 56 | pages = (1 << UML_CONFIG_KERNEL_STACK_ORDER) - 2; | ||
| 57 | prot = PROT_READ | PROT_WRITE | PROT_EXEC; | ||
| 58 | if(mprotect((void *) stack, pages * page_size(), prot) < 0) | ||
| 59 | panic("protecting stack failed, errno = %d", errno); | ||
| 60 | } | ||
| 61 | |||
| 62 | int wait_for_stop(int pid, int sig, int cont_type, void *relay) | ||
| 63 | { | ||
| 64 | sigset_t *relay_signals = relay; | ||
| 65 | int status, ret; | ||
| 66 | |||
| 67 | while(1){ | ||
| 68 | CATCH_EINTR(ret = waitpid(pid, &status, WUNTRACED)); | ||
| 69 | if((ret < 0) || | ||
| 70 | !WIFSTOPPED(status) || (WSTOPSIG(status) != sig)){ | ||
| 71 | if(ret < 0){ | ||
| 72 | printk("wait failed, errno = %d\n", | ||
| 73 | errno); | ||
| 74 | } | ||
| 75 | else if(WIFEXITED(status)) | ||
| 76 | printk("process %d exited with status %d\n", | ||
| 77 | pid, WEXITSTATUS(status)); | ||
| 78 | else if(WIFSIGNALED(status)) | ||
| 79 | printk("process %d exited with signal %d\n", | ||
| 80 | pid, WTERMSIG(status)); | ||
| 81 | else if((WSTOPSIG(status) == SIGVTALRM) || | ||
| 82 | (WSTOPSIG(status) == SIGALRM) || | ||
| 83 | (WSTOPSIG(status) == SIGIO) || | ||
| 84 | (WSTOPSIG(status) == SIGPROF) || | ||
| 85 | (WSTOPSIG(status) == SIGCHLD) || | ||
| 86 | (WSTOPSIG(status) == SIGWINCH) || | ||
| 87 | (WSTOPSIG(status) == SIGINT)){ | ||
| 88 | ptrace(cont_type, pid, 0, WSTOPSIG(status)); | ||
| 89 | continue; | ||
| 90 | } | ||
| 91 | else if((relay_signals != NULL) && | ||
| 92 | sigismember(relay_signals, WSTOPSIG(status))){ | ||
| 93 | ptrace(cont_type, pid, 0, WSTOPSIG(status)); | ||
| 94 | continue; | ||
| 95 | } | ||
| 96 | else printk("process %d stopped with signal %d\n", | ||
| 97 | pid, WSTOPSIG(status)); | ||
| 98 | panic("wait_for_stop failed to wait for %d to stop " | ||
| 99 | "with %d\n", pid, sig); | ||
| 100 | } | ||
| 101 | return(status); | ||
| 102 | } | ||
| 103 | } | ||
| 104 | |||
| 105 | int raw(int fd) | ||
| 106 | { | ||
| 107 | struct termios tt; | ||
| 108 | int err; | ||
| 109 | |||
| 110 | CATCH_EINTR(err = tcgetattr(fd, &tt)); | ||
| 111 | if(err < 0) | ||
| 112 | return -errno; | ||
| 113 | |||
| 114 | cfmakeraw(&tt); | ||
| 115 | |||
| 116 | CATCH_EINTR(err = tcsetattr(fd, TCSADRAIN, &tt)); | ||
| 117 | if(err < 0) | ||
| 118 | return -errno; | ||
| 119 | |||
| 120 | /* XXX tcsetattr could have applied only some changes | ||
| 121 | * (and cfmakeraw() is a set of changes) */ | ||
| 122 | return(0); | ||
| 123 | } | ||
| 124 | |||
| 125 | void setup_machinename(char *machine_out) | ||
| 126 | { | ||
| 127 | struct utsname host; | ||
| 128 | |||
| 129 | uname(&host); | ||
| 130 | #if defined(UML_CONFIG_UML_X86) && !defined(UML_CONFIG_64BIT) | ||
| 131 | if (!strcmp(host.machine, "x86_64")) { | ||
| 132 | strcpy(machine_out, "i686"); | ||
| 133 | return; | ||
| 134 | } | ||
| 135 | #endif | ||
| 136 | strcpy(machine_out, host.machine); | ||
| 137 | } | ||
| 138 | |||
| 139 | char host_info[(_UTSNAME_LENGTH + 1) * 4 + _UTSNAME_NODENAME_LENGTH + 1]; | ||
| 140 | |||
| 141 | void setup_hostinfo(void) | ||
| 142 | { | ||
| 143 | struct utsname host; | ||
| 144 | |||
| 145 | uname(&host); | ||
| 146 | sprintf(host_info, "%s %s %s %s %s", host.sysname, host.nodename, | ||
| 147 | host.release, host.version, host.machine); | ||
| 148 | } | ||
| 149 | |||
| 150 | int setjmp_wrapper(void (*proc)(void *, void *), ...) | ||
| 151 | { | ||
| 152 | va_list args; | ||
| 153 | sigjmp_buf buf; | ||
| 154 | int n; | ||
| 155 | |||
| 156 | n = sigsetjmp(buf, 1); | ||
| 157 | if(n == 0){ | ||
| 158 | va_start(args, proc); | ||
| 159 | (*proc)(&buf, &args); | ||
| 160 | } | ||
| 161 | va_end(args); | ||
| 162 | return(n); | ||
| 163 | } | ||
| 164 | |||
| 165 | /* | ||
| 166 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
| 167 | * Emacs will notice this stuff at the end of the file and automatically | ||
| 168 | * adjust the settings for this buffer only. This must remain at the end | ||
| 169 | * of the file. | ||
| 170 | * --------------------------------------------------------------------------- | ||
| 171 | * Local variables: | ||
| 172 | * c-file-style: "linux" | ||
| 173 | * End: | ||
| 174 | */ | ||
