Linux keeps surprising me everytime!
This time its their pipe2 system call which adds flags to the pipe call.
Its the unix-ish way apparently to turn pipes into files on a kernel
filesystem, or so they claim.
Anywho, this fixes glibc pipe2 system calls by wrapping against the
regular pipe systemcall if no flags are set and by signaling we don't
support that if they are.
Okay?
Index: linux_ipc.c
===================================================================
RCS file: /cvs/src/sys/compat/linux/linux_ipc.c,v
retrieving revision 1.11
diff -u -p -r1.11 linux_ipc.c
--- linux_ipc.c 5 Sep 2009 10:28:43 -0000 1.11
+++ linux_ipc.c 19 Sep 2011 22:37:33 -0000
@@ -719,3 +719,21 @@ linux_shmctl(p, v, retval)
}
}
#endif /* SYSVSHM */
+
+int
+linux_sys_pipe2(struct proc *p, void *v, register_t *retval)
+{
+ struct linux_sys_pipe2_args *uap = v;
+ struct sys_pipe_args pargs;
+
+ /*
+ * We don't really support pipe2, but glibc falls back to pipe
+ * we return signal that.
+ * /
+ if (SCARG(uap, flags) != 0)
+ return ENOSYS;
+
+ /* If no flag is set then the this is a plain pipe call. */
+ SCARG(&pargs, fdp) = SCARG(uap, fdp);
+ return sys_pipe(p, &pargs, retval);
+}
Index: linux_syscall.h
===================================================================
RCS file: /cvs/src/sys/compat/linux/linux_syscall.h,v
retrieving revision 1.66
diff -u -p -r1.66 linux_syscall.h
--- linux_syscall.h 19 Sep 2011 14:33:40 -0000 1.66
+++ linux_syscall.h 19 Sep 2011 22:37:34 -0000
@@ -1,10 +1,10 @@
-/* $OpenBSD: linux_syscall.h,v 1.66 2011/09/19 14:33:40 pirofti Exp $
*/
+/* $OpenBSD$ */
/*
* System call numbers.
*
* DO NOT EDIT-- this file is automatically generated.
- * created from OpenBSD: syscalls.master,v 1.62 2011/09/18 02:23:18
pirofti Exp
+ * created from OpenBSD: syscalls.master,v 1.63 2011/09/19 14:33:14
pirofti Exp
*/
/* syscall: "syscall" ret: "int" args: */
@@ -747,5 +747,8 @@
/* syscall: "get_robust_list" ret: "int" args: "int" "struct
linux_robust_list_head **" "size_t *" */
#define LINUX_SYS_get_robust_list 312
+
+/* syscall: "pipe2" ret: "int" args: "int *" "int" */
+#define LINUX_SYS_pipe2 331
#define LINUX_SYS_MAXSYSCALL 338
Index: linux_syscallargs.h
===================================================================
RCS file: /cvs/src/sys/compat/linux/linux_syscallargs.h,v
retrieving revision 1.68
diff -u -p -r1.68 linux_syscallargs.h
--- linux_syscallargs.h 19 Sep 2011 14:33:40 -0000 1.68
+++ linux_syscallargs.h 19 Sep 2011 22:37:35 -0000
@@ -1,10 +1,10 @@
-/* $OpenBSD: linux_syscallargs.h,v 1.68 2011/09/19 14:33:40 pirofti Exp $
*/
+/* $OpenBSD$ */
/*
* System call argument lists.
*
* DO NOT EDIT-- this file is automatically generated.
- * created from OpenBSD: syscalls.master,v 1.62 2011/09/18 02:23:18
pirofti Exp
+ * created from OpenBSD: syscalls.master,v 1.63 2011/09/19 14:33:14
pirofti Exp
*/
#ifdef syscallarg
@@ -610,6 +610,11 @@ struct linux_sys_get_robust_list_args {
syscallarg(size_t *) len;
};
+struct linux_sys_pipe2_args {
+ syscallarg(int *) fdp;
+ syscallarg(int) flags;
+};
+
/*
* System call prototypes.
*/
@@ -876,3 +881,4 @@ int linux_sys_clock_gettime(struct proc
int linux_sys_clock_getres(struct proc *, void *, register_t *);
int linux_sys_set_robust_list(struct proc *, void *, register_t *);
int linux_sys_get_robust_list(struct proc *, void *, register_t *);
+int linux_sys_pipe2(struct proc *, void *, register_t *);
Index: linux_syscalls.c
===================================================================
RCS file: /cvs/src/sys/compat/linux/linux_syscalls.c,v
retrieving revision 1.66
diff -u -p -r1.66 linux_syscalls.c
--- linux_syscalls.c 19 Sep 2011 14:33:40 -0000 1.66
+++ linux_syscalls.c 19 Sep 2011 22:37:35 -0000
@@ -1,10 +1,10 @@
-/* $OpenBSD: linux_syscalls.c,v 1.66 2011/09/19 14:33:40 pirofti Exp $
*/
+/* $OpenBSD$ */
/*
* System call names.
*
* DO NOT EDIT-- this file is automatically generated.
- * created from OpenBSD: syscalls.master,v 1.62 2011/09/18 02:23:18
pirofti Exp
+ * created from OpenBSD: syscalls.master,v 1.63 2011/09/19 14:33:14
pirofti Exp
*/
char *linux_syscallnames[] = {
@@ -359,7 +359,7 @@ char *linux_syscallnames[] = {
"#328 (unimplemented eventfd2)", /* 328 = unimplemented
eventfd2 */
"#329 (unimplemented epoll_create1)", /* 329 = unimplemented
epoll_create1 */
"#330 (unimplemented dup3)", /* 330 = unimplemented dup3 */
- "#331 (unimplemented pipe2)", /* 331 = unimplemented pipe2 */
+ "pipe2", /* 331 = pipe2 */
"#332 (unimplemented inotify_init1)", /* 332 = unimplemented
inotify_init1 */
"#333 (unimplemented preadv)", /* 333 = unimplemented preadv */
"#334 (unimplemented pwritev)", /* 334 = unimplemented pwritev
*/
Index: linux_sysent.c
===================================================================
RCS file: /cvs/src/sys/compat/linux/linux_sysent.c,v
retrieving revision 1.67
diff -u -p -r1.67 linux_sysent.c
--- linux_sysent.c 19 Sep 2011 14:33:40 -0000 1.67
+++ linux_sysent.c 19 Sep 2011 22:37:36 -0000
@@ -1,10 +1,10 @@
-/* $OpenBSD: linux_sysent.c,v 1.67 2011/09/19 14:33:40 pirofti Exp $
*/
+/* $OpenBSD$ */
/*
* System call switch table.
*
* DO NOT EDIT-- this file is automatically generated.
- * created from OpenBSD: syscalls.master,v 1.62 2011/09/18 02:23:18
pirofti Exp
+ * created from OpenBSD: syscalls.master,v 1.63 2011/09/19 14:33:14
pirofti Exp
*/
#include <sys/param.h>
@@ -708,8 +708,8 @@ struct sysent linux_sysent[] = {
sys_nosys }, /* 329 = unimplemented
epoll_create1 */
{ 0, 0, 0,
sys_nosys }, /* 330 = unimplemented dup3 */
- { 0, 0, 0,
- sys_nosys }, /* 331 = unimplemented pipe2 */
+ { 2, s(struct linux_sys_pipe2_args), 0,
+ linux_sys_pipe2 }, /* 331 = pipe2 */
{ 0, 0, 0,
sys_nosys }, /* 332 = unimplemented
inotify_init1 */
{ 0, 0, 0,
Index: syscalls.master
===================================================================
RCS file: /cvs/src/sys/compat/linux/syscalls.master,v
retrieving revision 1.63
diff -u -p -r1.63 syscalls.master
--- syscalls.master 19 Sep 2011 14:33:14 -0000 1.63
+++ syscalls.master 19 Sep 2011 22:37:36 -0000
@@ -479,7 +479,7 @@
328 UNIMPL eventfd2
329 UNIMPL epoll_create1
330 UNIMPL dup3
-331 UNIMPL pipe2
+331 STD { int linux_sys_pipe2(int *fdp, int flags); }
332 UNIMPL inotify_init1
333 UNIMPL preadv
334 UNIMPL pwritev