Merge branches 'x86-reboot-for-linus' and 'x86-setup-for-linus' of git://git.kernel...
[linux-2.6/next.git] / arch / um / kernel / skas / clone.c
blob2c8583c1a344df2003ee0f2371ca6ead0a085982
1 /*
2 * Copyright (C) 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL
4 */
6 #include <signal.h>
7 #include <sched.h>
8 #include <asm/unistd.h>
9 #include <sys/time.h>
10 #include "as-layout.h"
11 #include "kern_constants.h"
12 #include "ptrace_user.h"
13 #include "stub-data.h"
14 #include "sysdep/stub.h"
17 * This is in a separate file because it needs to be compiled with any
18 * extraneous gcc flags (-pg, -fprofile-arcs, -ftest-coverage) disabled
20 * Use UM_KERN_PAGE_SIZE instead of PAGE_SIZE because that calls getpagesize
21 * on some systems.
24 void __attribute__ ((__section__ (".__syscall_stub")))
25 stub_clone_handler(void)
27 struct stub_data *data = (struct stub_data *) STUB_DATA;
28 long err;
30 err = stub_syscall2(__NR_clone, CLONE_PARENT | CLONE_FILES | SIGCHLD,
31 STUB_DATA + UM_KERN_PAGE_SIZE / 2 - sizeof(void *));
32 if (err != 0)
33 goto out;
35 err = stub_syscall4(__NR_ptrace, PTRACE_TRACEME, 0, 0, 0);
36 if (err)
37 goto out;
39 err = stub_syscall3(__NR_setitimer, ITIMER_VIRTUAL,
40 (long) &data->timer, 0);
41 if (err)
42 goto out;
44 remap_stack(data->fd, data->offset);
45 goto done;
47 out:
49 * save current result.
50 * Parent: pid;
51 * child: retcode of mmap already saved and it jumps around this
52 * assignment
54 data->err = err;
55 done:
56 trap_myself();