summaryrefslogtreecommitdiffstats
path: root/sys/compat
diff options
context:
space:
mode:
authormjg <mjg@FreeBSD.org>2016-02-04 04:22:18 +0000
committermjg <mjg@FreeBSD.org>2016-02-04 04:22:18 +0000
commit9a7c585ab535448da4519e461a2216e335686144 (patch)
tree85458aa64b140adb018b8056f3f355fb4345dade /sys/compat
parente807599e3ffdfd1caaff4c43f3e2a3b7b6289440 (diff)
downloadFreeBSD-src-9a7c585ab535448da4519e461a2216e335686144.zip
FreeBSD-src-9a7c585ab535448da4519e461a2216e335686144.tar.gz
fork: pass arguments to fork1 in a dedicated structure
Suggested by: kib
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/cloudabi/cloudabi_proc.c8
-rw-r--r--sys/compat/linux/linux_fork.c20
2 files changed, 22 insertions, 6 deletions
diff --git a/sys/compat/cloudabi/cloudabi_proc.c b/sys/compat/cloudabi/cloudabi_proc.c
index d917337..7320af0 100644
--- a/sys/compat/cloudabi/cloudabi_proc.c
+++ b/sys/compat/cloudabi/cloudabi_proc.c
@@ -75,12 +75,18 @@ int
cloudabi_sys_proc_fork(struct thread *td,
struct cloudabi_sys_proc_fork_args *uap)
{
+ struct fork_req fr;
struct filecaps fcaps = {};
struct proc *p2;
int error, fd;
cap_rights_init(&fcaps.fc_rights, CAP_FSTAT, CAP_EVENT);
- error = fork1(td, RFFDG | RFPROC | RFPROCDESC, 0, &p2, &fd, 0, &fcaps);
+ bzero(&fr, sizeof(fr));
+ fr.fr_flags = RFFDG | RFPROC | RFPROCDESC;
+ fr.fr_procp = &p2;
+ fr.fr_pd_fd = &fd;
+ fr.fr_pd_fcaps = &fcaps;
+ error = fork1(td, &fr);
if (error != 0)
return (error);
/* Return the file descriptor to the parent process. */
diff --git a/sys/compat/linux/linux_fork.c b/sys/compat/linux/linux_fork.c
index d0f73ad..c12f198 100644
--- a/sys/compat/linux/linux_fork.c
+++ b/sys/compat/linux/linux_fork.c
@@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
int
linux_fork(struct thread *td, struct linux_fork_args *args)
{
+ struct fork_req fr;
int error;
struct proc *p2;
struct thread *td2;
@@ -73,8 +74,10 @@ linux_fork(struct thread *td, struct linux_fork_args *args)
printf(ARGS(fork, ""));
#endif
- if ((error = fork1(td, RFFDG | RFPROC | RFSTOPPED, 0, &p2, NULL, 0,
- NULL)) != 0)
+ bzero(&fr, sizeof(fr));
+ fr.fr_flags = RFFDG | RFPROC | RFSTOPPED;
+ fr.fr_procp = &p2;
+ if ((error = fork1(td, &fr)) != 0)
return (error);
td2 = FIRST_THREAD_IN_PROC(p2);
@@ -97,6 +100,7 @@ linux_fork(struct thread *td, struct linux_fork_args *args)
int
linux_vfork(struct thread *td, struct linux_vfork_args *args)
{
+ struct fork_req fr;
int error;
struct proc *p2;
struct thread *td2;
@@ -106,8 +110,10 @@ linux_vfork(struct thread *td, struct linux_vfork_args *args)
printf(ARGS(vfork, ""));
#endif
- if ((error = fork1(td, RFFDG | RFPROC | RFMEM | RFPPWAIT | RFSTOPPED,
- 0, &p2, NULL, 0, NULL)) != 0)
+ bzero(&fr, sizeof(fr));
+ fr.fr_flags = RFFDG | RFPROC | RFMEM | RFPPWAIT | RFSTOPPED;
+ fr.fr_procp = &p2;
+ if ((error = fork1(td, &fr)) != 0)
return (error);
td2 = FIRST_THREAD_IN_PROC(p2);
@@ -130,6 +136,7 @@ linux_vfork(struct thread *td, struct linux_vfork_args *args)
static int
linux_clone_proc(struct thread *td, struct linux_clone_args *args)
{
+ struct fork_req fr;
int error, ff = RFPROC | RFSTOPPED;
struct proc *p2;
struct thread *td2;
@@ -170,7 +177,10 @@ linux_clone_proc(struct thread *td, struct linux_clone_args *args)
if (args->flags & LINUX_CLONE_VFORK)
ff |= RFPPWAIT;
- error = fork1(td, ff, 0, &p2, NULL, 0, NULL);
+ bzero(&fr, sizeof(fr));
+ fr.fr_flags = ff;
+ fr.fr_procp = &p2;
+ error = fork1(td, &fr);
if (error)
return (error);
OpenPOWER on IntegriCloud