summaryrefslogtreecommitdiffstats
path: root/sys/compat/linux
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2012-04-16 21:22:02 +0000
committerjkim <jkim@FreeBSD.org>2012-04-16 21:22:02 +0000
commite210f689a88fc9c69c2a71393cc5e81321bd8320 (patch)
tree0929b9d6ba911ed85df4be1049f50e0052c10a5d /sys/compat/linux
parent10552859c1b4a35e872654ec21f766ebac5186ee (diff)
downloadFreeBSD-src-e210f689a88fc9c69c2a71393cc5e81321bd8320.zip
FreeBSD-src-e210f689a88fc9c69c2a71393cc5e81321bd8320.tar.gz
- Implement pipe2 syscall for Linuxulator. This syscall appeared in 2.6.27
but GNU libc used it without checking its kernel version, e. g., Fedora 10. - Move pipe(2) implementation for Linuxulator from MD files to MI file, sys/compat/linux/linux_file.c. There is no MD code for this syscall at all. - Correct an argument type for pipe() from l_ulong * to l_int *. Probably this was the source of MI/MD confusion. Reviewed by: emulation
Diffstat (limited to 'sys/compat/linux')
-rw-r--r--sys/compat/linux/linux_file.c49
1 files changed, 49 insertions, 0 deletions
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)));
+}
OpenPOWER on IntegriCloud