summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/amd64/linux32/linux32_dummy.c1
-rw-r--r--sys/amd64/linux32/linux32_machdep.c19
-rw-r--r--sys/amd64/linux32/syscalls.master4
-rw-r--r--sys/compat/linux/linux_file.c49
-rw-r--r--sys/i386/linux/linux_dummy.c1
-rw-r--r--sys/i386/linux/linux_machdep.c19
-rw-r--r--sys/i386/linux/syscalls.master4
-rw-r--r--sys/kern/sys_pipe.c24
8 files changed, 72 insertions, 49 deletions
diff --git a/sys/amd64/linux32/linux32_dummy.c b/sys/amd64/linux32/linux32_dummy.c
index 38c920d..9abc0ee 100644
--- a/sys/amd64/linux32/linux32_dummy.c
+++ b/sys/amd64/linux32/linux32_dummy.c
@@ -122,7 +122,6 @@ DUMMY(signalfd4);
DUMMY(eventfd2);
DUMMY(epoll_create1);
DUMMY(dup3);
-DUMMY(pipe2);
DUMMY(inotify_init1);
/* linux 2.6.30: */
DUMMY(preadv);
diff --git a/sys/amd64/linux32/linux32_machdep.c b/sys/amd64/linux32/linux32_machdep.c
index abcdd3e..7725163 100644
--- a/sys/amd64/linux32/linux32_machdep.c
+++ b/sys/amd64/linux32/linux32_machdep.c
@@ -698,25 +698,6 @@ linux_iopl(struct thread *td, struct linux_iopl_args *args)
}
int
-linux_pipe(struct thread *td, struct linux_pipe_args *args)
-{
- int error;
- int fildes[2];
-
-#ifdef DEBUG
- if (ldebug(pipe))
- printf(ARGS(pipe, "*"));
-#endif
-
- error = kern_pipe(td, fildes);
- if (error)
- return (error);
-
- /* XXX: Close descriptors on error. */
- return (copyout(fildes, args->pipefds, sizeof fildes));
-}
-
-int
linux_sigaction(struct thread *td, struct linux_sigaction_args *args)
{
l_osigaction_t osa;
diff --git a/sys/amd64/linux32/syscalls.master b/sys/amd64/linux32/syscalls.master
index d29966f..4b85bf0 100644
--- a/sys/amd64/linux32/syscalls.master
+++ b/sys/amd64/linux32/syscalls.master
@@ -95,7 +95,7 @@
39 AUE_MKDIR STD { int linux_mkdir(char *path, l_int mode); }
40 AUE_RMDIR STD { int linux_rmdir(char *path); }
41 AUE_DUP NOPROTO { int dup(u_int fd); }
-42 AUE_PIPE STD { int linux_pipe(l_ulong *pipefds); }
+42 AUE_PIPE STD { int linux_pipe(l_int *pipefds); }
43 AUE_NULL STD { int linux_times(struct l_times_argv *buf); }
44 AUE_NULL UNIMPL prof
45 AUE_NULL STD { int linux_brk(l_ulong dsend); }
@@ -536,7 +536,7 @@
328 AUE_NULL STD { int linux_eventfd2(void); }
329 AUE_NULL STD { int linux_epoll_create1(void); }
330 AUE_NULL STD { int linux_dup3(void); }
-331 AUE_NULL STD { int linux_pipe2(void); }
+331 AUE_NULL STD { int linux_pipe2(l_int *pipefds, l_int flags); }
332 AUE_NULL STD { int linux_inotify_init1(void); }
; linux 2.6.30:
333 AUE_NULL STD { int linux_preadv(void); }
diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c
index 0888e64..67b1b38 100644
--- a/sys/compat/linux/linux_file.c
+++ b/sys/compat/linux/linux_file.c
@@ -69,6 +69,9 @@ __FBSDID("$FreeBSD$");
#include <compat/linux/linux_util.h>
#include <compat/linux/linux_file.h>
+/* XXX */
+int do_pipe(struct thread *td, int fildes[2], int flags);
+
int
linux_creat(struct thread *td, struct linux_creat_args *args)
{
@@ -1575,3 +1578,49 @@ linux_fadvise64_64(struct thread *td, struct linux_fadvise64_64_args *args)
return (kern_posix_fadvise(td, args->fd, args->offset, args->len,
advice));
}
+
+int
+linux_pipe(struct thread *td, struct linux_pipe_args *args)
+{
+ int fildes[2];
+ int error;
+
+#ifdef DEBUG
+ if (ldebug(pipe))
+ printf(ARGS(pipe, "*"));
+#endif
+
+ error = do_pipe(td, fildes, 0);
+ if (error)
+ return (error);
+
+ /* XXX: Close descriptors on error. */
+ return (copyout(fildes, args->pipefds, sizeof(fildes)));
+}
+
+int
+linux_pipe2(struct thread *td, struct linux_pipe2_args *args)
+{
+ int fildes[2];
+ int error, flags;
+
+#ifdef DEBUG
+ if (ldebug(pipe2))
+ printf(ARGS(pipe2, "*, %d"), args->flags);
+#endif
+
+ if ((args->flags & ~(LINUX_O_NONBLOCK | LINUX_O_CLOEXEC)) != 0)
+ return (EINVAL);
+
+ flags = 0;
+ if ((args->flags & LINUX_O_NONBLOCK) != 0)
+ flags |= O_NONBLOCK;
+ if ((args->flags & LINUX_O_CLOEXEC) != 0)
+ flags |= O_CLOEXEC;
+ error = do_pipe(td, fildes, flags);
+ if (error)
+ return (error);
+
+ /* XXX: Close descriptors on error. */
+ return (copyout(fildes, args->pipefds, sizeof(fildes)));
+}
diff --git a/sys/i386/linux/linux_dummy.c b/sys/i386/linux/linux_dummy.c
index d507b1f..31bbf6f 100644
--- a/sys/i386/linux/linux_dummy.c
+++ b/sys/i386/linux/linux_dummy.c
@@ -113,7 +113,6 @@ DUMMY(signalfd4);
DUMMY(eventfd2);
DUMMY(epoll_create1);
DUMMY(dup3);
-DUMMY(pipe2);
DUMMY(inotify_init1);
/* linux 2.6.30: */
DUMMY(preadv);
diff --git a/sys/i386/linux/linux_machdep.c b/sys/i386/linux/linux_machdep.c
index 396740a..14d1892 100644
--- a/sys/i386/linux/linux_machdep.c
+++ b/sys/i386/linux/linux_machdep.c
@@ -587,25 +587,6 @@ linux_mprotect(struct thread *td, struct linux_mprotect_args *uap)
}
int
-linux_pipe(struct thread *td, struct linux_pipe_args *args)
-{
- int error;
- int fildes[2];
-
-#ifdef DEBUG
- if (ldebug(pipe))
- printf(ARGS(pipe, "*"));
-#endif
-
- error = kern_pipe(td, fildes);
- if (error)
- return (error);
-
- /* XXX: Close descriptors on error. */
- return (copyout(fildes, args->pipefds, sizeof fildes));
-}
-
-int
linux_ioperm(struct thread *td, struct linux_ioperm_args *args)
{
int error;
diff --git a/sys/i386/linux/syscalls.master b/sys/i386/linux/syscalls.master
index b158630..f452434 100644
--- a/sys/i386/linux/syscalls.master
+++ b/sys/i386/linux/syscalls.master
@@ -95,7 +95,7 @@
39 AUE_MKDIR STD { int linux_mkdir(char *path, l_int mode); }
40 AUE_RMDIR STD { int linux_rmdir(char *path); }
41 AUE_DUP NOPROTO { int dup(u_int fd); }
-42 AUE_PIPE STD { int linux_pipe(l_ulong *pipefds); }
+42 AUE_PIPE STD { int linux_pipe(l_int *pipefds); }
43 AUE_NULL STD { int linux_times(struct l_times_argv *buf); }
44 AUE_NULL UNIMPL prof
45 AUE_NULL STD { int linux_brk(l_ulong dsend); }
@@ -546,7 +546,7 @@
328 AUE_NULL STD { int linux_eventfd2(void); }
329 AUE_NULL STD { int linux_epoll_create1(void); }
330 AUE_NULL STD { int linux_dup3(void); }
-331 AUE_NULL STD { int linux_pipe2(void); }
+331 AUE_NULL STD { int linux_pipe2(l_int *pipefds, l_int flags); }
332 AUE_NULL STD { int linux_inotify_init1(void); }
; linux 2.6.30:
333 AUE_NULL STD { int linux_preadv(void); }
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index 6719bda..43c39fc 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -129,6 +129,9 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_page.h>
#include <vm/uma.h>
+/* XXX */
+int do_pipe(struct thread *td, int fildes[2], int flags);
+
/*
* Use this define if you want to disable *fancy* VM things. Expect an
* approx 30% decrease in transfer rate. This could be useful for
@@ -405,11 +408,18 @@ pipe_dtor(struct pipe *dpipe)
int
kern_pipe(struct thread *td, int fildes[2])
{
+
+ return (do_pipe(td, fildes, 0));
+}
+
+int
+do_pipe(struct thread *td, int fildes[2], int flags)
+{
struct filedesc *fdp;
struct file *rf, *wf;
struct pipe *rpipe, *wpipe;
struct pipepair *pp;
- int fd, error;
+ int fd, fflags, error;
fdp = td->td_proc->p_fd;
error = pipe_paircreate(td, &pp);
@@ -417,7 +427,7 @@ kern_pipe(struct thread *td, int fildes[2])
return (error);
rpipe = &pp->pp_rpipe;
wpipe = &pp->pp_wpipe;
- error = falloc(td, &rf, &fd, 0);
+ error = falloc(td, &rf, &fd, flags);
if (error) {
pipeclose(rpipe);
pipeclose(wpipe);
@@ -426,14 +436,18 @@ kern_pipe(struct thread *td, int fildes[2])
/* An extra reference on `rf' has been held for us by falloc(). */
fildes[0] = fd;
+ fflags = FREAD | FWRITE;
+ if ((flags & O_NONBLOCK) != 0)
+ fflags |= FNONBLOCK;
+
/*
* Warning: once we've gotten past allocation of the fd for the
* read-side, we can only drop the read side via fdrop() in order
* to avoid races against processes which manage to dup() the read
* side while we are blocked trying to allocate the write side.
*/
- finit(rf, FREAD | FWRITE, DTYPE_PIPE, rpipe, &pipeops);
- error = falloc(td, &wf, &fd, 0);
+ finit(rf, fflags, DTYPE_PIPE, rpipe, &pipeops);
+ error = falloc(td, &wf, &fd, flags);
if (error) {
fdclose(fdp, rf, fildes[0], td);
fdrop(rf, td);
@@ -442,7 +456,7 @@ kern_pipe(struct thread *td, int fildes[2])
return (error);
}
/* An extra reference on `wf' has been held for us by falloc(). */
- finit(wf, FREAD | FWRITE, DTYPE_PIPE, wpipe, &pipeops);
+ finit(wf, fflags, DTYPE_PIPE, wpipe, &pipeops);
fdrop(wf, td);
fildes[1] = fd;
fdrop(rf, td);
OpenPOWER on IntegriCloud