linux32_machdep.c (156440) | linux32_machdep.c (161310) |
---|---|
1/*- 2 * Copyright (c) 2004 Tim J. Robbins 3 * Copyright (c) 2002 Doug Rabson 4 * Copyright (c) 2000 Marcel Moolenaar 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 15 unchanged lines hidden (view full) --- 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2004 Tim J. Robbins 3 * Copyright (c) 2002 Doug Rabson 4 * Copyright (c) 2000 Marcel Moolenaar 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 15 unchanged lines hidden (view full) --- 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31#include <sys/cdefs.h> |
32__FBSDID("$FreeBSD: head/sys/amd64/linux32/linux32_machdep.c 156440 2006-03-08 20:21:54Z ups $"); | 32__FBSDID("$FreeBSD: head/sys/amd64/linux32/linux32_machdep.c 161310 2006-08-15 12:54:30Z netchild $"); |
33 34#include <sys/param.h> 35#include <sys/kernel.h> 36#include <sys/systm.h> 37#include <sys/imgact.h> | 33 34#include <sys/param.h> 35#include <sys/kernel.h> 36#include <sys/systm.h> 37#include <sys/imgact.h> |
38#include <sys/limits.h> |
|
38#include <sys/lock.h> 39#include <sys/malloc.h> 40#include <sys/mman.h> 41#include <sys/mutex.h> 42#include <sys/proc.h> 43#include <sys/resource.h> 44#include <sys/resourcevar.h> 45#include <sys/syscallsubr.h> --- 421 unchanged lines hidden (view full) --- 467 if ((error = vfork(td, (struct vfork_args *)args)) != 0) 468 return (error); 469 /* Are we the child? */ 470 if (td->td_retval[1] == 1) 471 td->td_retval[0] = 0; 472 return (0); 473} 474 | 39#include <sys/lock.h> 40#include <sys/malloc.h> 41#include <sys/mman.h> 42#include <sys/mutex.h> 43#include <sys/proc.h> 44#include <sys/resource.h> 45#include <sys/resourcevar.h> 46#include <sys/syscallsubr.h> --- 421 unchanged lines hidden (view full) --- 468 if ((error = vfork(td, (struct vfork_args *)args)) != 0) 469 return (error); 470 /* Are we the child? */ 471 if (td->td_retval[1] == 1) 472 td->td_retval[0] = 0; 473 return (0); 474} 475 |
475#define CLONE_VM 0x100 476#define CLONE_FS 0x200 477#define CLONE_FILES 0x400 478#define CLONE_SIGHAND 0x800 479#define CLONE_PID 0x1000 480 | |
481int 482linux_clone(struct thread *td, struct linux_clone_args *args) 483{ 484 int error, ff = RFPROC | RFSTOPPED; 485 struct proc *p2; 486 struct thread *td2; 487 int exit_signal; 488 489#ifdef DEBUG 490 if (ldebug(clone)) { 491 printf(ARGS(clone, "flags %x, stack %x"), 492 (unsigned int)(uintptr_t)args->flags, 493 (unsigned int)(uintptr_t)args->stack); | 476int 477linux_clone(struct thread *td, struct linux_clone_args *args) 478{ 479 int error, ff = RFPROC | RFSTOPPED; 480 struct proc *p2; 481 struct thread *td2; 482 int exit_signal; 483 484#ifdef DEBUG 485 if (ldebug(clone)) { 486 printf(ARGS(clone, "flags %x, stack %x"), 487 (unsigned int)(uintptr_t)args->flags, 488 (unsigned int)(uintptr_t)args->stack); |
494 if (args->flags & CLONE_PID) 495 printf(LMSG("CLONE_PID not yet supported")); | |
496 } 497#endif 498 | 489 } 490#endif 491 |
499 if (!args->stack) 500 return (EINVAL); 501 | |
502 exit_signal = args->flags & 0x000000ff; 503 if (exit_signal >= LINUX_NSIG) 504 return (EINVAL); 505 506 if (exit_signal <= LINUX_SIGTBLSZ) 507 exit_signal = linux_to_bsd_signal[_SIG_IDX(exit_signal)]; 508 509 if (args->flags & CLONE_VM) --- 7 unchanged lines hidden (view full) --- 517 if (error) 518 return (error); 519 520 521 PROC_LOCK(p2); 522 p2->p_sigparent = exit_signal; 523 PROC_UNLOCK(p2); 524 td2 = FIRST_THREAD_IN_PROC(p2); | 492 exit_signal = args->flags & 0x000000ff; 493 if (exit_signal >= LINUX_NSIG) 494 return (EINVAL); 495 496 if (exit_signal <= LINUX_SIGTBLSZ) 497 exit_signal = linux_to_bsd_signal[_SIG_IDX(exit_signal)]; 498 499 if (args->flags & CLONE_VM) --- 7 unchanged lines hidden (view full) --- 507 if (error) 508 return (error); 509 510 511 PROC_LOCK(p2); 512 p2->p_sigparent = exit_signal; 513 PROC_UNLOCK(p2); 514 td2 = FIRST_THREAD_IN_PROC(p2); |
525 td2->td_frame->tf_rsp = PTROUT(args->stack); | 515 /* in a case of stack = NULL we are supposed to COW calling process stack 516 * this is what normal fork() does so we just keep the tf_rsp arg intact 517 */ 518 if (args->stack) 519 td2->td_frame->tf_rsp = PTROUT(args->stack); |
526 527#ifdef DEBUG 528 if (ldebug(clone)) 529 printf(LMSG("clone: successful rfork to %ld, stack %p sig = %d"), 530 (long)p2->p_pid, args->stack, exit_signal); 531#endif 532 533 /* --- 488 unchanged lines hidden --- | 520 521#ifdef DEBUG 522 if (ldebug(clone)) 523 printf(LMSG("clone: successful rfork to %ld, stack %p sig = %d"), 524 (long)p2->p_pid, args->stack, exit_signal); 525#endif 526 527 /* --- 488 unchanged lines hidden --- |