MOXA linux-2.6.x / linux-2.6.19-uc1 from UC-7110-LX-BOOTLOADER-1.9_VERSION-4.2.tgz
[linux-2.6.19-moxart.git] / arch / um / kernel / skas / clone.c
blob0a33dc1622656faf792387137ad43da3af3fa7ce
1 #include <sched.h>
2 #include <signal.h>
3 #include <sys/mman.h>
4 #include <sys/time.h>
5 #include <asm/unistd.h>
6 #include <asm/page.h>
7 #include "ptrace_user.h"
8 #include "skas.h"
9 #include "stub-data.h"
10 #include "uml-config.h"
11 #include "sysdep/stub.h"
12 #include "kern_constants.h"
14 #ifndef CLONE_PARENT
15 # define CLONE_PARENT 0x00008000
16 #endif
18 /* This is in a separate file because it needs to be compiled with any
19 * extraneous gcc flags (-pg, -fprofile-arcs, -ftest-coverage) disabled
21 * Use UM_KERN_PAGE_SIZE instead of PAGE_SIZE because that calls getpagesize
22 * on some systems.
25 void __attribute__ ((__section__ (".__syscall_stub")))
26 stub_clone_handler(void)
28 struct stub_data *data = (struct stub_data *) UML_CONFIG_STUB_DATA;
29 long err;
31 err = stub_syscall2(__NR_clone, CLONE_PARENT | CLONE_FILES | SIGCHLD,
32 UML_CONFIG_STUB_DATA + UM_KERN_PAGE_SIZE / 2 -
33 sizeof(void *));
34 if(err != 0)
35 goto out;
37 err = stub_syscall4(__NR_ptrace, PTRACE_TRACEME, 0, 0, 0);
38 if(err)
39 goto out;
41 err = stub_syscall3(__NR_setitimer, ITIMER_VIRTUAL,
42 (long) &data->timer, 0);
43 if(err)
44 goto out;
46 remap_stack(data->fd, data->offset);
47 goto done;
49 out:
50 /* save current result.
51 * Parent: pid;
52 * child: retcode of mmap already saved and it jumps around this
53 * assignment
55 data->err = err;
56 done:
57 trap_myself();