[PATCH] uml: eliminate use of libc PAGE_SIZE
[linux-2.6.22.y-op.git] / arch / um / kernel / skas / clone.c
blobcb37ce9124a6f4a01702f260cab102f8a332b017
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 /* This is in a separate file because it needs to be compiled with any
15 * extraneous gcc flags (-pg, -fprofile-arcs, -ftest-coverage) disabled
17 * Use UM_KERN_PAGE_SIZE instead of PAGE_SIZE because that calls getpagesize
18 * on some systems.
21 #define STUB_DATA(field) (((struct stub_data *) UML_CONFIG_STUB_DATA)->field)
23 void __attribute__ ((__section__ (".__syscall_stub")))
24 stub_clone_handler(void)
26 long err;
28 err = stub_syscall2(__NR_clone, CLONE_PARENT | CLONE_FILES | SIGCHLD,
29 UML_CONFIG_STUB_DATA + UM_KERN_PAGE_SIZE / 2 -
30 sizeof(void *));
31 if(err != 0)
32 goto out;
34 err = stub_syscall4(__NR_ptrace, PTRACE_TRACEME, 0, 0, 0);
35 if(err)
36 goto out;
38 err = stub_syscall3(__NR_setitimer, ITIMER_VIRTUAL,
39 (long) &STUB_DATA(timer), 0);
40 if(err)
41 goto out;
43 err = stub_syscall6(STUB_MMAP_NR, UML_CONFIG_STUB_DATA,
44 UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE,
45 MAP_FIXED | MAP_SHARED, STUB_DATA(fd),
46 STUB_DATA(offset));
47 out:
48 /* save current result. Parent: pid; child: retcode of mmap */
49 STUB_DATA(err) = err;
50 trap_myself();