summaryrefslogtreecommitdiffstats
path: root/sys/compat/linux
diff options
context:
space:
mode:
Diffstat (limited to 'sys/compat/linux')
-rw-r--r--sys/compat/linux/linux_file.c92
-rw-r--r--sys/compat/linux/linux_fork.c32
2 files changed, 39 insertions, 85 deletions
diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c
index e56e61f..19104a4 100644
--- a/sys/compat/linux/linux_file.c
+++ b/sys/compat/linux/linux_file.c
@@ -55,10 +55,6 @@ __FBSDID("$FreeBSD$");
#include <security/mac/mac_framework.h>
-#include <ufs/ufs/extattr.h>
-#include <ufs/ufs/quota.h>
-#include <ufs/ufs/ufsmount.h>
-
#ifdef COMPAT_LINUX32
#include <machine/../linux32/linux.h>
#include <machine/../linux32/linux32_proto.h>
@@ -136,39 +132,39 @@ linux_common_open(struct thread *td, int dirfd, char *path, int l_flags, int mod
/* XXX LINUX_O_NOATIME: unable to be easily implemented. */
error = kern_openat(td, dirfd, path, UIO_SYSSPACE, bsd_flags, mode);
-
- if (!error) {
- fd = td->td_retval[0];
- /*
- * XXX In between kern_open() and fget(), another process
- * having the same filedesc could use that fd without
- * checking below.
- */
- error = fget(td, fd, cap_rights_init(&rights, CAP_IOCTL), &fp);
- if (!error) {
- sx_slock(&proctree_lock);
- PROC_LOCK(p);
- if (!(bsd_flags & O_NOCTTY) &&
- SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
- PROC_UNLOCK(p);
- sx_unlock(&proctree_lock);
- /* XXXPJD: Verify if TIOCSCTTY is allowed. */
- if (fp->f_type == DTYPE_VNODE)
- (void) fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0,
- td->td_ucred, td);
- } else {
- PROC_UNLOCK(p);
- sx_sunlock(&proctree_lock);
- }
+ if (error != 0)
+ goto done;
+
+ if (bsd_flags & O_NOCTTY)
+ goto done;
+
+ /*
+ * XXX In between kern_open() and fget(), another process
+ * having the same filedesc could use that fd without
+ * checking below.
+ */
+ fd = td->td_retval[0];
+ if (fget(td, fd, cap_rights_init(&rights, CAP_IOCTL), &fp) == 0) {
+ if (fp->f_type != DTYPE_VNODE) {
fdrop(fp, td);
- /*
- * XXX as above, fdrop()/kern_close() pair is racy.
- */
- if (error)
- kern_close(td, fd);
+ goto done;
+ }
+ sx_slock(&proctree_lock);
+ PROC_LOCK(p);
+ if (SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
+ PROC_UNLOCK(p);
+ sx_sunlock(&proctree_lock);
+ /* XXXPJD: Verify if TIOCSCTTY is allowed. */
+ (void) fo_ioctl(fp, TIOCSCTTY, (caddr_t) 0,
+ td->td_ucred, td);
+ } else {
+ PROC_UNLOCK(p);
+ sx_sunlock(&proctree_lock);
}
+ fdrop(fp, td);
}
+done:
#ifdef DEBUG
if (ldebug(open))
printf(LMSG("open returns error %d"), error);
@@ -1072,12 +1068,10 @@ linux_pwrite(td, uap)
int
linux_mount(struct thread *td, struct linux_mount_args *args)
{
- struct ufs_args ufs;
char fstypename[MFSNAMELEN];
char mntonname[MNAMELEN], mntfromname[MNAMELEN];
int error;
int fsflags;
- void *fsdata;
error = copyinstr(args->filesystemtype, fstypename, MFSNAMELEN - 1,
NULL);
@@ -1098,20 +1092,10 @@ linux_mount(struct thread *td, struct linux_mount_args *args)
if (strcmp(fstypename, "ext2") == 0) {
strcpy(fstypename, "ext2fs");
- fsdata = &ufs;
- ufs.fspec = mntfromname;
-#define DEFAULT_ROOTID -2
- ufs.export.ex_root = DEFAULT_ROOTID;
- ufs.export.ex_flags =
- args->rwflag & LINUX_MS_RDONLY ? MNT_EXRDONLY : 0;
} else if (strcmp(fstypename, "proc") == 0) {
strcpy(fstypename, "linprocfs");
- fsdata = NULL;
} else if (strcmp(fstypename, "vfat") == 0) {
strcpy(fstypename, "msdosfs");
- fsdata = NULL;
- } else {
- return (ENODEV);
}
fsflags = 0;
@@ -1131,19 +1115,11 @@ linux_mount(struct thread *td, struct linux_mount_args *args)
fsflags |= MNT_UPDATE;
}
- if (strcmp(fstypename, "linprocfs") == 0) {
- error = kernel_vmount(fsflags,
- "fstype", fstypename,
- "fspath", mntonname,
- NULL);
- } else if (strcmp(fstypename, "msdosfs") == 0) {
- error = kernel_vmount(fsflags,
- "fstype", fstypename,
- "fspath", mntonname,
- "from", mntfromname,
- NULL);
- } else
- error = EOPNOTSUPP;
+ error = kernel_vmount(fsflags,
+ "fstype", fstypename,
+ "fspath", mntonname,
+ "from", mntfromname,
+ NULL);
return (error);
}
diff --git a/sys/compat/linux/linux_fork.c b/sys/compat/linux/linux_fork.c
index 2103636..0ab7d3a 100644
--- a/sys/compat/linux/linux_fork.c
+++ b/sys/compat/linux/linux_fork.c
@@ -111,9 +111,8 @@ linux_vfork(struct thread *td, struct linux_vfork_args *args)
printf(ARGS(vfork, ""));
#endif
- /* Exclude RFPPWAIT */
- if ((error = fork1(td, RFFDG | RFPROC | RFMEM | RFSTOPPED, 0, &p2,
- NULL, 0)) != 0)
+ if ((error = fork1(td, RFFDG | RFPROC | RFMEM | RFPPWAIT | RFSTOPPED,
+ 0, &p2, NULL, 0)) != 0)
return (error);
td->td_retval[0] = p2->p_pid;
@@ -122,10 +121,6 @@ linux_vfork(struct thread *td, struct linux_vfork_args *args)
if (error)
return (error);
- PROC_LOCK(p2);
- p2->p_flag |= P_PPWAIT;
- PROC_UNLOCK(p2);
-
td2 = FIRST_THREAD_IN_PROC(p2);
/*
@@ -136,12 +131,6 @@ linux_vfork(struct thread *td, struct linux_vfork_args *args)
sched_add(td2, SRQ_BORING);
thread_unlock(td2);
- /* wait for the children to exit, ie. emulate vfork */
- PROC_LOCK(p2);
- while (p2->p_flag & P_PPWAIT)
- cv_wait(&p2->p_pwait, &p2->p_mtx);
- PROC_UNLOCK(p2);
-
return (0);
}
@@ -203,6 +192,9 @@ linux_clone(struct thread *td, struct linux_clone_args *args)
if (args->parent_tidptr == NULL)
return (EINVAL);
+ if (args->flags & LINUX_CLONE_VFORK)
+ ff |= RFPPWAIT;
+
error = fork1(td, ff, 0, &p2, NULL, 0);
if (error)
return (error);
@@ -271,12 +263,6 @@ linux_clone(struct thread *td, struct linux_clone_args *args)
"stack %p sig = %d"), (int)p2->p_pid, args->stack,
exit_signal);
#endif
- if (args->flags & LINUX_CLONE_VFORK) {
- PROC_LOCK(p2);
- p2->p_flag |= P_PPWAIT;
- PROC_UNLOCK(p2);
- }
-
/*
* Make this runnable after we are finished with it.
*/
@@ -288,13 +274,5 @@ linux_clone(struct thread *td, struct linux_clone_args *args)
td->td_retval[0] = p2->p_pid;
td->td_retval[1] = 0;
- if (args->flags & LINUX_CLONE_VFORK) {
- /* wait for the children to exit, ie. emulate vfork */
- PROC_LOCK(p2);
- while (p2->p_flag & P_PPWAIT)
- cv_wait(&p2->p_pwait, &p2->p_mtx);
- PROC_UNLOCK(p2);
- }
-
return (0);
}
OpenPOWER on IntegriCloud