Files
OrangePi_CM5/arch/um/kernel/skas/clone.c
T

57 lines
1.3 KiB
C
Raw Normal View History

2008-02-04 22:30:43 -08:00
/*
* Copyright (C) 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
* Licensed under the GPL
*/
2005-07-07 17:56:50 -07:00
#include <signal.h>
2008-02-04 22:30:43 -08:00
#include <sched.h>
2005-07-07 17:56:50 -07:00
#include <asm/unistd.h>
2008-02-04 22:30:43 -08:00
#include <sys/time.h>
2007-10-16 01:27:33 -07:00
#include "as-layout.h"
2008-02-04 22:30:43 -08:00
#include "kern_constants.h"
2005-07-07 17:56:50 -07:00
#include "ptrace_user.h"
#include "stub-data.h"
#include "sysdep/stub.h"
2008-02-04 22:30:43 -08:00
/*
* This is in a separate file because it needs to be compiled with any
2005-07-07 17:56:50 -07:00
* extraneous gcc flags (-pg, -fprofile-arcs, -ftest-coverage) disabled
*
* Use UM_KERN_PAGE_SIZE instead of PAGE_SIZE because that calls getpagesize
* on some systems.
2005-07-07 17:56:50 -07:00
*/
2005-07-07 17:56:50 -07:00
void __attribute__ ((__section__ (".__syscall_stub")))
stub_clone_handler(void)
{
2007-10-16 01:27:33 -07:00
struct stub_data *data = (struct stub_data *) STUB_DATA;
2005-07-07 17:56:50 -07:00
long err;
err = stub_syscall2(__NR_clone, CLONE_PARENT | CLONE_FILES | SIGCHLD,
2007-10-16 01:27:33 -07:00
STUB_DATA + UM_KERN_PAGE_SIZE / 2 - sizeof(void *));
2008-02-04 22:30:43 -08:00
if (err != 0)
2005-07-07 17:56:50 -07:00
goto out;
err = stub_syscall4(__NR_ptrace, PTRACE_TRACEME, 0, 0, 0);
2008-02-04 22:30:43 -08:00
if (err)
2005-07-07 17:56:50 -07:00
goto out;
2008-02-04 22:30:43 -08:00
err = stub_syscall3(__NR_setitimer, ITIMER_VIRTUAL,
2005-12-18 17:50:39 +01:00
(long) &data->timer, 0);
2008-02-04 22:30:43 -08:00
if (err)
2005-07-07 17:56:50 -07:00
goto out;
2005-12-18 17:50:39 +01:00
remap_stack(data->fd, data->offset);
goto done;
2005-07-07 17:56:50 -07:00
out:
2008-02-04 22:30:43 -08:00
/*
* save current result.
* Parent: pid;
* child: retcode of mmap already saved and it jumps around this
2005-12-18 17:50:39 +01:00
* assignment
*/
data->err = err;
done:
2005-07-07 17:56:50 -07:00
trap_myself();
}