aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/os-Linux/tt.c
diff options
context:
space:
mode:
authorGennady Sharapov <gennady.v.sharapov@intel.com>2005-09-03 18:57:47 -0400
committerLinus Torvalds <torvalds@evo.osdl.org>2005-09-05 03:06:24 -0400
commit60d339f6fe0831060600c62418b71a62ad26c281 (patch)
treea2f9527bbcfe85b3eb7c063b8af7d2f499ba4cbb /arch/um/os-Linux/tt.c
parent09ace81c1d737bcbb2423db235ac980cac4d5de9 (diff)
[PATCH] uml: move libc-dependent startup and signal code
The serial UML OS-abstraction layer patch (um/kernel dir). This moves all systemcalls from process.c file under os-Linux dir and join process.c and process_kern.c files. Signed-off-by: Gennady Sharapov <gennady.v.sharapov@intel.com> Signed-off-by: Jeff Dike <jdike@addtoit.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um/os-Linux/tt.c')
-rw-r--r--arch/um/os-Linux/tt.c113
1 files changed, 113 insertions, 0 deletions
diff --git a/arch/um/os-Linux/tt.c b/arch/um/os-Linux/tt.c
new file mode 100644
index 000000000000..5b047ab8416a
--- /dev/null
+++ b/arch/um/os-Linux/tt.c
@@ -0,0 +1,113 @@
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 <unistd.h>
8#include <signal.h>
9#include <sched.h>
10#include <errno.h>
11#include <stdarg.h>
12#include <stdlib.h>
13#include <setjmp.h>
14#include <sys/time.h>
15#include <sys/ptrace.h>
16#include <linux/ptrace.h>
17#include <sys/wait.h>
18#include <sys/mman.h>
19#include <asm/ptrace.h>
20#include <asm/unistd.h>
21#include <asm/page.h>
22#include "user_util.h"
23#include "kern_util.h"
24#include "user.h"
25#include "signal_kern.h"
26#include "signal_user.h"
27#include "sysdep/ptrace.h"
28#include "sysdep/sigcontext.h"
29#include "irq_user.h"
30#include "ptrace_user.h"
31#include "time_user.h"
32#include "init.h"
33#include "os.h"
34#include "uml-config.h"
35#include "choose-mode.h"
36#include "mode.h"
37#include "tempfile.h"
38
39/*
40 *-------------------------
41 * only for tt mode (will be deleted in future...)
42 *-------------------------
43 */
44
45struct tramp {
46 int (*tramp)(void *);
47 void *tramp_data;
48 unsigned long temp_stack;
49 int flags;
50 int pid;
51};
52
53/* See above for why sigkill is here */
54
55int sigkill = SIGKILL;
56
57int outer_tramp(void *arg)
58{
59 struct tramp *t;
60 int sig = sigkill;
61
62 t = arg;
63 t->pid = clone(t->tramp, (void *) t->temp_stack + page_size()/2,
64 t->flags, t->tramp_data);
65 if(t->pid > 0) wait_for_stop(t->pid, SIGSTOP, PTRACE_CONT, NULL);
66 kill(os_getpid(), sig);
67 _exit(0);
68}
69
70int start_fork_tramp(void *thread_arg, unsigned long temp_stack,
71 int clone_flags, int (*tramp)(void *))
72{
73 struct tramp arg;
74 unsigned long sp;
75 int new_pid, status, err;
76
77 /* The trampoline will run on the temporary stack */
78 sp = stack_sp(temp_stack);
79
80 clone_flags |= CLONE_FILES | SIGCHLD;
81
82 arg.tramp = tramp;
83 arg.tramp_data = thread_arg;
84 arg.temp_stack = temp_stack;
85 arg.flags = clone_flags;
86
87 /* Start the process and wait for it to kill itself */
88 new_pid = clone(outer_tramp, (void *) sp, clone_flags, &arg);
89 if(new_pid < 0)
90 return(new_pid);
91
92 CATCH_EINTR(err = waitpid(new_pid, &status, 0));
93 if(err < 0)
94 panic("Waiting for outer trampoline failed - errno = %d",
95 errno);
96
97 if(!WIFSIGNALED(status) || (WTERMSIG(status) != SIGKILL))
98 panic("outer trampoline didn't exit with SIGKILL, "
99 "status = %d", status);
100
101 return(arg.pid);
102}
103
104void forward_pending_sigio(int target)
105{
106 sigset_t sigs;
107
108 if(sigpending(&sigs))
109 panic("forward_pending_sigio : sigpending failed");
110 if(sigismember(&sigs, SIGIO))
111 kill(target, SIGIO);
112}
113