CVS commit: src/lib/librumphijack

2021-09-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep 11 14:22:12 UTC 2021

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
remove fake closefrom()


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.134 src/lib/librumphijack/hijack.c:1.135
--- src/lib/librumphijack/hijack.c:1.134	Sat Sep 11 04:32:11 2021
+++ src/lib/librumphijack/hijack.c	Sat Sep 11 10:22:12 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.134 2021/09/11 08:32:11 rillig Exp $	*/
+/*  $NetBSD: hijack.c,v 1.135 2021/09/11 14:22:12 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include 
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.134 2021/09/11 08:32:11 rillig Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.135 2021/09/11 14:22:12 christos Exp $");
 #endif
 
 #include 
@@ -2854,8 +2854,3 @@ nfssvc(int flags, void *argstructp)
 	return op_nfssvc(flags, argstructp);
 }
 #endif /* __NetBSD__ */
-
-int
-closefrom(int fd) {
-	return 0;
-}



CVS commit: src/lib/librumphijack

2021-09-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep 11 14:22:12 UTC 2021

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
remove fake closefrom()


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2021-09-11 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Sep 11 08:32:11 UTC 2021

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
librumphijack: fix typo for NetBSD < 5.99.7


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.133 src/lib/librumphijack/hijack.c:1.134
--- src/lib/librumphijack/hijack.c:1.133	Fri Sep 10 21:22:05 2021
+++ src/lib/librumphijack/hijack.c	Sat Sep 11 08:32:11 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.133 2021/09/10 21:22:05 christos Exp $	*/
+/*  $NetBSD: hijack.c,v 1.134 2021/09/11 08:32:11 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include 
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.133 2021/09/10 21:22:05 christos Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.134 2021/09/11 08:32:11 rillig Exp $");
 #endif
 
 #include 
@@ -187,7 +187,7 @@ enum dualcall {
 #if defined(__NetBSD__)
 
 #if !__NetBSD_Prereq__(5,99,7)
-#define REALSELECT pselect
+#define REALPSELECT pselect
 #define REALSELECT select
 #define REALPOLLTS pollts
 #define REALKEVENT kevent



CVS commit: src/lib/librumphijack

2021-09-11 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Sep 11 08:32:11 UTC 2021

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
librumphijack: fix typo for NetBSD < 5.99.7


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2021-09-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep 10 21:22:05 UTC 2021

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Ignore closefrom(3) for now; too complicated to descern between regular
and rump fds.


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.132 src/lib/librumphijack/hijack.c:1.133
--- src/lib/librumphijack/hijack.c:1.132	Fri Sep 10 16:33:38 2021
+++ src/lib/librumphijack/hijack.c	Fri Sep 10 17:22:05 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.132 2021/09/10 20:33:38 christos Exp $	*/
+/*  $NetBSD: hijack.c,v 1.133 2021/09/10 21:22:05 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include 
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.132 2021/09/10 20:33:38 christos Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.133 2021/09/10 21:22:05 christos Exp $");
 #endif
 
 #include 
@@ -2854,3 +2854,8 @@ nfssvc(int flags, void *argstructp)
 	return op_nfssvc(flags, argstructp);
 }
 #endif /* __NetBSD__ */
+
+int
+closefrom(int fd) {
+	return 0;
+}



CVS commit: src/lib/librumphijack

2021-09-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep 10 21:22:05 UTC 2021

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Ignore closefrom(3) for now; too complicated to descern between regular
and rump fds.


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2021-09-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep 10 20:33:38 UTC 2021

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
- implement pselect so that the ssh test has a chance to work
- 1 -> EXIT_FAILURE
- more info about fds


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.131 src/lib/librumphijack/hijack.c:1.132
--- src/lib/librumphijack/hijack.c:1.131	Wed May 27 14:55:36 2020
+++ src/lib/librumphijack/hijack.c	Fri Sep 10 16:33:38 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.131 2020/05/27 18:55:36 christos Exp $	*/
+/*  $NetBSD: hijack.c,v 1.132 2021/09/10 20:33:38 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include 
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.131 2020/05/27 18:55:36 christos Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.132 2021/09/10 20:33:38 christos Exp $");
 #endif
 
 #include 
@@ -187,6 +187,7 @@ enum dualcall {
 #if defined(__NetBSD__)
 
 #if !__NetBSD_Prereq__(5,99,7)
+#define REALSELECT pselect
 #define REALSELECT select
 #define REALPOLLTS pollts
 #define REALKEVENT kevent
@@ -199,6 +200,7 @@ enum dualcall {
 #define REALMKNOD mknod
 #define REALFHSTAT __fhstat40
 #else /* >= 5.99.7 */
+#define REALPSELECT _sys___pselect50
 #define REALSELECT _sys___select50
 #define REALPOLLTS _sys___pollts50
 #define REALKEVENT _sys___kevent50
@@ -248,6 +250,7 @@ int __getcwd(char *, size_t);
 #define REALREAD read
 #define REALPREAD pread
 #define REALPWRITE pwrite
+#define REALPSELECT pselect
 #define REALSELECT select
 #define REALPOLLTS ppoll
 #define REALUTIMES utimes
@@ -262,6 +265,8 @@ int __getcwd(char *, size_t);
 
 #endif /* platform */
 
+int REALPSELECT(int, fd_set *, fd_set *, fd_set *, const struct timespec *,
+		const sigset_t *);
 int REALSELECT(int, fd_set *, fd_set *, fd_set *, struct timeval *);
 int REALPOLLTS(struct pollfd *, nfds_t,
 	   const struct timespec *, const sigset_t *);
@@ -482,7 +487,7 @@ setdup2(int hostfd, int rumpfd)
 {
 
 	if (hostfd > DUP2HIGH) {
-		_DIAGASSERT(0);
+		_DIAGASSERT(/*CONSTCOND*/0);
 		return;
 	}
 
@@ -494,7 +499,7 @@ clrdup2(int hostfd)
 {
 
 	if (hostfd > DUP2HIGH) {
-		_DIAGASSERT(0);
+		_DIAGASSERT(/*CONSTCOND*/0);
 		return;
 	}
 
@@ -696,7 +701,7 @@ sockparser(char *buf)
 			}
 		}
 		if (socketmap[i].name == NULL) {
-			errx(1, "invalid socket specifier %s", p);
+			errx(EXIT_FAILURE, "invalid socket specifier %s", p);
 		}
 	}
 }
@@ -707,16 +712,17 @@ pathparser(char *buf)
 
 	/* sanity-check */
 	if (*buf != '/')
-		errx(1, "hijack path specifier must begin with ``/''");
+		errx(EXIT_FAILURE,
+		"hijack path specifier must begin with ``/''");
 	rumpprefixlen = strlen(buf);
 	if (rumpprefixlen < 2)
-		errx(1, "invalid hijack prefix: %s", buf);
+		errx(EXIT_FAILURE, "invalid hijack prefix: %s", buf);
 	if (buf[rumpprefixlen-1] == '/' && strspn(buf, "/") != rumpprefixlen)
-		errx(1, "hijack prefix may end in slash only if pure "
-		"slash, gave %s", buf);
+		errx(EXIT_FAILURE, "hijack prefix may end in slash only if "
+		"pure slash, gave %s", buf);
 
 	if ((rumpprefix = strdup(buf)) == NULL)
-		err(1, "strdup");
+		err(EXIT_FAILURE, "strdup");
 	rumpprefixlen = strlen(rumpprefix);
 }
 
@@ -737,19 +743,19 @@ blanketparser(char *buf)
 
 	blanket = malloc(nblanket * sizeof(*blanket));
 	if (blanket == NULL)
-		err(1, "alloc blanket %d", nblanket);
+		err(EXIT_FAILURE, "alloc blanket %d", nblanket);
 
 	for (p = strtok_r(buf, ":", ), i = 0; p;
 	p = strtok_r(NULL, ":", ), i++) {
 		blanket[i].pfx = strdup(p);
 		if (blanket[i].pfx == NULL)
-			err(1, "strdup blanket");
+			err(EXIT_FAILURE, "strdup blanket");
 		blanket[i].len = strlen(p);
 
 		if (blanket[i].len == 0 || *blanket[i].pfx != '/')
-			errx(1, "invalid blanket specifier %s", p);
+			errx(EXIT_FAILURE, "invalid blanket specifier %s", p);
 		if (*(blanket[i].pfx + blanket[i].len-1) == '/')
-			errx(1, "invalid blanket specifier %s", p);
+			errx(EXIT_FAILURE, "invalid blanket specifier %s", p);
 	}
 }
 
@@ -780,7 +786,8 @@ vfsparser(char *buf)
 	fullmask = 0;
 	for (i = 0; vfscalls[i].name != NULL; i++) {
 		if (fullmask & vfscalls[i].bit)
-			errx(1, "problem exists between vi and chair");
+			errx(EXIT_FAILURE,
+			"problem exists between vi and chair");
 		fullmask |= vfscalls[i].bit;
 	}
 
@@ -810,7 +817,7 @@ vfsparser(char *buf)
 			}
 		}
 		if (vfscalls[i].name == NULL) {
-			errx(1, "invalid vfscall specifier %s", p);
+			errx(EXIT_FAILURE, "invalid vfscall specifier %s", p);
 		}
 	}
 }
@@ -836,7 +843,7 @@ sysctlparser(char *buf)
 		return;
 	}
 
-	errx(1, "sysctl value should be y(es)/n(o), gave: %s", buf);
+	errx(EXIT_FAILURE, "sysctl value should be y(es)/n(o), gave: %s", 

CVS commit: src/lib/librumphijack

2021-09-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Sep 10 20:33:38 UTC 2021

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
- implement pselect so that the ssh test has a chance to work
- 1 -> EXIT_FAILURE
- more info about fds


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2020-05-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May 27 18:55:36 UTC 2020

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Add pathconf and lpathconf (fixes lib/librumphijack/nfs test which uses ls
which now uses lpathconf)


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2020-05-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May 27 18:55:36 UTC 2020

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Add pathconf and lpathconf (fixes lib/librumphijack/nfs test which uses ls
which now uses lpathconf)


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.130 src/lib/librumphijack/hijack.c:1.131
--- src/lib/librumphijack/hijack.c:1.130	Mon Feb 10 18:21:42 2020
+++ src/lib/librumphijack/hijack.c	Wed May 27 14:55:36 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.130 2020/02/10 23:21:42 kamil Exp $	*/
+/*  $NetBSD: hijack.c,v 1.131 2020/05/27 18:55:36 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include 
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.130 2020/02/10 23:21:42 kamil Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.131 2020/05/27 18:55:36 christos Exp $");
 #endif
 
 #include 
@@ -170,6 +170,9 @@ enum dualcall {
 #ifdef __NetBSD__
 	DUALCALL_LINKAT,
 #endif
+	DUALCALL_PATHCONF,
+	DUALCALL_LPATHCONF,
+
 	DUALCALL__NUM
 };
 
@@ -405,6 +408,8 @@ struct sysnames {
 #ifdef __NetBSD__
 	{ DUALCALL_LINKAT,	"linkat",	RSYS_NAME(LINKAT)	},
 #endif
+	{ DUALCALL_PATHCONF,	"pathconf",	RSYS_NAME(PATHCONF)	},
+	{ DUALCALL_LPATHCONF,	"lpathconf",	RSYS_NAME(LPATHCONF)	},
 };
 #undef S
 
@@ -1335,6 +1340,39 @@ linkat(int fromfd, const char *from, int
 }
 #endif
 
+static long
+do_pathconf(const char *path, int name, int link)
+{
+	long (*op_pathconf)(const char *, int);
+	enum pathtype pt;
+
+	if ((pt = path_isrump(path)) != PATH_HOST) {
+		op_pathconf = link ?
+		GETSYSCALL(rump, LPATHCONF) :
+		GETSYSCALL(rump, PATHCONF);
+		if (pt == PATH_RUMP)
+			path = path_host2rump(path);
+	} else {
+		op_pathconf = link ? 
+		GETSYSCALL(host, LPATHCONF) :
+		GETSYSCALL(host, PATHCONF);
+	}
+
+	return op_pathconf(path, name);
+}
+
+long
+lpathconf(const char *path, int name)
+{
+	return do_pathconf(path, name, 1);
+}
+
+long
+pathconf(const char *path, int name)
+{
+	return do_pathconf(path, name, 0);
+}
+
 int
 link(const char *from, const char *to)
 {



CVS commit: src/lib/librumphijack

2020-02-10 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Feb 10 23:21:42 UTC 2020

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Change types of DUP2ALIAS and DUP2FDMASK bit masks to unsigned

This is for consistency with the DUP2BIT change.


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.129 src/lib/librumphijack/hijack.c:1.130
--- src/lib/librumphijack/hijack.c:1.129	Mon Feb 10 09:10:58 2020
+++ src/lib/librumphijack/hijack.c	Mon Feb 10 23:21:42 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.129 2020/02/10 09:10:58 kamil Exp $	*/
+/*  $NetBSD: hijack.c,v 1.130 2020/02/10 23:21:42 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include 
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.129 2020/02/10 09:10:58 kamil Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.130 2020/02/10 23:21:42 kamil Exp $");
 #endif
 
 #include 
@@ -441,8 +441,8 @@ static int hijack_fdoff = FD_SETSIZE/2;
 #define DUP2HIGH 2
 static uint32_t dup2vec[DUP2HIGH+1];
 #define DUP2BIT (1U<<31)
-#define DUP2ALIAS (1<<30)
-#define DUP2FDMASK ((1<<30)-1)
+#define DUP2ALIAS (1U<<30)
+#define DUP2FDMASK ((1U<<30)-1)
 
 static bool
 isdup2d(int fd)



CVS commit: src/lib/librumphijack

2020-02-10 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Feb 10 23:21:42 UTC 2020

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Change types of DUP2ALIAS and DUP2FDMASK bit masks to unsigned

This is for consistency with the DUP2BIT change.


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2020-02-10 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Feb 10 09:10:58 UTC 2020

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Avoid unportable bit shift semantics

hijack.c:451:52, left shift of 1 by 31 places cannot be represented in type 'int


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2020-02-10 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Feb 10 09:10:58 UTC 2020

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Avoid unportable bit shift semantics

hijack.c:451:52, left shift of 1 by 31 places cannot be represented in type 'int


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.128 src/lib/librumphijack/hijack.c:1.129
--- src/lib/librumphijack/hijack.c:1.128	Wed Sep 25 20:19:59 2019
+++ src/lib/librumphijack/hijack.c	Mon Feb 10 09:10:58 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.128 2019/09/25 20:19:59 christos Exp $	*/
+/*  $NetBSD: hijack.c,v 1.129 2020/02/10 09:10:58 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include 
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.128 2019/09/25 20:19:59 christos Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.129 2020/02/10 09:10:58 kamil Exp $");
 #endif
 
 #include 
@@ -440,7 +440,7 @@ static int hijack_fdoff = FD_SETSIZE/2;
 /* note: you cannot change this without editing the env-passing code */
 #define DUP2HIGH 2
 static uint32_t dup2vec[DUP2HIGH+1];
-#define DUP2BIT (1<<31)
+#define DUP2BIT (1U<<31)
 #define DUP2ALIAS (1<<30)
 #define DUP2FDMASK ((1<<30)-1)
 



CVS commit: src/lib/librumphijack

2019-09-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep 25 20:19:59 UTC 2019

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
teach hijack about the new vfs syscalls


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2019-09-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Sep 25 20:19:59 UTC 2019

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
teach hijack about the new vfs syscalls


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.127 src/lib/librumphijack/hijack.c:1.128
--- src/lib/librumphijack/hijack.c:1.127	Sun Feb 17 18:35:50 2019
+++ src/lib/librumphijack/hijack.c	Wed Sep 25 16:19:59 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.127 2019/02/17 23:35:50 bad Exp $	*/
+/*  $NetBSD: hijack.c,v 1.128 2019/09/25 20:19:59 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include 
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.127 2019/02/17 23:35:50 bad Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.128 2019/09/25 20:19:59 christos Exp $");
 #endif
 
 #include 
@@ -216,7 +216,17 @@ enum dualcall {
 #define REALMOUNT __mount50
 #define REALGETFH __getfh30
 #define REALFHOPEN __fhopen40
+#if !__NetBSD_Prereq__(9,99,13)
+#define REALSTATVFS1 statvfs1
+#define REALFSTATVFS1 fstatvfs1
+#define REALGETVFSSTAT getvfsstat
 #define REALFHSTATVFS1 __fhstatvfs140
+#else
+#define REALSTATVFS1 __statvfs190
+#define REALFSTATVFS1 __fstatvfs190
+#define REALGETVFSSTAT __getvfsstat90
+#define REALFHSTATVFS1 __fhstatvfs190
+#endif
 #define REALSOCKET __socket30
 
 #define LSEEK_ALIAS _lseek
@@ -264,7 +274,10 @@ int REALMOUNT(const char *, const char *
 int REALGETFH(const char *, void *, size_t *);
 int REALFHOPEN(const void *, size_t, int);
 int REALFHSTAT(const void *, size_t, struct stat *);
+int REALSTATVFS1(const char *, struct statvfs *, int);
+int REALFSTATVFS1(int, struct statvfs *, int);
 int REALFHSTATVFS1(const void *, size_t, struct statvfs *, int);
+int REALGETVFSSTAT(struct statvfs *, size_t, int);
 int REALSOCKET(int, int, int);
 
 #define S(a) __STRING(a)
@@ -365,9 +378,9 @@ struct sysnames {
 #endif
 
 #ifdef __NetBSD__
-	{ DUALCALL_STATVFS1,	"statvfs1",	RSYS_NAME(STATVFS1)	},
-	{ DUALCALL_FSTATVFS1,	"fstatvfs1",	RSYS_NAME(FSTATVFS1)	},
-	{ DUALCALL_GETVFSSTAT,	"getvfsstat",	RSYS_NAME(GETVFSSTAT)	},
+	{ DUALCALL_STATVFS1,	S(REALSTATVFS1),RSYS_NAME(STATVFS1)	},
+	{ DUALCALL_FSTATVFS1,	S(REALFSTATVFS1),RSYS_NAME(FSTATVFS1)	},
+	{ DUALCALL_GETVFSSTAT,	S(REALGETVFSSTAT),RSYS_NAME(GETVFSSTAT)	},
 #endif
 
 #ifdef __NetBSD__
@@ -2497,7 +2510,7 @@ FDCALL(int, REALFSTAT, DUALCALL_FSTAT,		
 #endif
 
 #ifdef __NetBSD__
-FDCALL(int, fstatvfs1, DUALCALL_FSTATVFS1,\
+FDCALL(int, REALFSTATVFS1, DUALCALL_FSTATVFS1,\
 	(int fd, struct statvfs *buf, int flags),			\
 	(int, struct statvfs *, int),	\
 	(fd, buf, flags))
@@ -2599,7 +2612,7 @@ PATHCALL(int, lchmod, DUALCALL_LCHMOD,		
 	(path, mode))
 
 #ifdef __NetBSD__
-PATHCALL(int, statvfs1, DUALCALL_STATVFS1,\
+PATHCALL(int, REALSTATVFS1, DUALCALL_STATVFS1,\
 	(const char *path, struct statvfs *buf, int flags),		\
 	(const char *, struct statvfs *, int),\
 	(path, buf, flags))
@@ -2728,7 +2741,7 @@ PATHCALL(int, REALGETFH, DUALCALL_GETFH,
  */
 
 #ifdef __NetBSD__
-VFSCALL(VFSBIT_GETVFSSTAT, int, getvfsstat, DUALCALL_GETVFSSTAT,	\
+VFSCALL(VFSBIT_GETVFSSTAT, int, REALGETVFSSTAT, DUALCALL_GETVFSSTAT,	\
 	(struct statvfs *buf, size_t buflen, int flags),		\
 	(struct statvfs *, size_t, int),\
 	(buf, buflen, flags))



CVS commit: src/lib/librumphijack

2019-09-15 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Sep 16 00:00:57 UTC 2019

Modified Files:
src/lib/librumphijack: Makefile

Log Message:
Stop passing -D_INCOMPLETE_XOPEN_C063 (obsolete define)


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/librumphijack/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/Makefile
diff -u src/lib/librumphijack/Makefile:1.21 src/lib/librumphijack/Makefile:1.22
--- src/lib/librumphijack/Makefile:1.21	Sun Feb 17 23:33:20 2019
+++ src/lib/librumphijack/Makefile	Mon Sep 16 00:00:56 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.21 2019/02/17 23:33:20 bad Exp $
+#	$NetBSD: Makefile,v 1.22 2019/09/16 00:00:56 kamil Exp $
 #
 
 LIB=		rumphijack
@@ -11,7 +11,6 @@ MAN=		rumphijack.3
 SRCS=		hijack.c hijackdlsym.c
 
 CPPFLAGS+=	-D_DIAGNOSTIC -D_REENTRANT
-CPPFLAGS.hijack.c+= -D_INCOMPLETE_XOPEN_C063
 
 WARNS?=		5
 



CVS commit: src/lib/librumphijack

2019-09-15 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Sep 16 00:00:57 UTC 2019

Modified Files:
src/lib/librumphijack: Makefile

Log Message:
Stop passing -D_INCOMPLETE_XOPEN_C063 (obsolete define)


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/librumphijack/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2019-02-17 Thread Christoph Badura
Module Name:src
Committed By:   bad
Date:   Sun Feb 17 23:35:50 UTC 2019

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Linux doesn't have paccept().


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2019-02-17 Thread Christoph Badura
Module Name:src
Committed By:   bad
Date:   Sun Feb 17 23:35:50 UTC 2019

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Linux doesn't have paccept().


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.126 src/lib/librumphijack/hijack.c:1.127
--- src/lib/librumphijack/hijack.c:1.126	Sun Dec 16 14:03:37 2018
+++ src/lib/librumphijack/hijack.c	Sun Feb 17 23:35:50 2019
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.126 2018/12/16 14:03:37 hannken Exp $	*/
+/*  $NetBSD: hijack.c,v 1.127 2019/02/17 23:35:50 bad Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include 
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.126 2018/12/16 14:03:37 hannken Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.127 2019/02/17 23:35:50 bad Exp $");
 #endif
 
 #include 
@@ -89,7 +89,10 @@ __RCSID("$NetBSD: hijack.c,v 1.126 2018/
 enum dualcall {
 	DUALCALL_WRITE, DUALCALL_WRITEV, DUALCALL_PWRITE, DUALCALL_PWRITEV,
 	DUALCALL_IOCTL, DUALCALL_FCNTL,
-	DUALCALL_SOCKET, DUALCALL_ACCEPT, DUALCALL_PACCEPT,
+	DUALCALL_SOCKET, DUALCALL_ACCEPT,
+#ifndef __linux__
+	DUALCALL_PACCEPT,
+#endif
 	DUALCALL_BIND, DUALCALL_CONNECT,
 	DUALCALL_GETPEERNAME, DUALCALL_GETSOCKNAME, DUALCALL_LISTEN,
 	DUALCALL_RECVFROM, DUALCALL_RECVMSG,
@@ -272,7 +275,9 @@ struct sysnames {
 } syscnames[] = {
 	{ DUALCALL_SOCKET,	S(REALSOCKET),	RSYS_NAME(SOCKET)	},
 	{ DUALCALL_ACCEPT,	"accept",	RSYS_NAME(ACCEPT)	},
+#ifndef __linux__
 	{ DUALCALL_PACCEPT,	"paccept",	RSYS_NAME(PACCEPT)	},
+#endif
 	{ DUALCALL_BIND,	"bind",		RSYS_NAME(BIND)		},
 	{ DUALCALL_CONNECT,	"connect",	RSYS_NAME(CONNECT)	},
 	{ DUALCALL_GETPEERNAME,	"getpeername",	RSYS_NAME(GETPEERNAME)	},
@@ -1382,6 +1387,7 @@ accept(int s, struct sockaddr *addr, soc
 	return fd;
 }
 
+#ifndef __linux__
 int
 paccept(int s, struct sockaddr *addr, socklen_t *addrlen,
 const sigset_t * restrict sigmask, int flags)
@@ -1410,6 +1416,7 @@ paccept(int s, struct sockaddr *addr, so
 
 	return fd;
 }
+#endif
 
 /*
  * ioctl() and fcntl() are varargs calls and need special treatment.



CVS commit: src/lib/librumphijack

2019-02-17 Thread Christoph Badura
Module Name:src
Committed By:   bad
Date:   Sun Feb 17 23:33:20 UTC 2019

Modified Files:
src/lib/librumphijack: Makefile

Log Message:
compile hijack.c with -D_INCOMPLETE_XOPEN_C063 so that AT_FDCWD is alwasy
defined for rumpkernels.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/lib/librumphijack/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/Makefile
diff -u src/lib/librumphijack/Makefile:1.20 src/lib/librumphijack/Makefile:1.21
--- src/lib/librumphijack/Makefile:1.20	Thu May 11 04:33:14 2017
+++ src/lib/librumphijack/Makefile	Sun Feb 17 23:33:20 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.20 2017/05/11 04:33:14 sevan Exp $
+#	$NetBSD: Makefile,v 1.21 2019/02/17 23:33:20 bad Exp $
 #
 
 LIB=		rumphijack
@@ -11,6 +11,7 @@ MAN=		rumphijack.3
 SRCS=		hijack.c hijackdlsym.c
 
 CPPFLAGS+=	-D_DIAGNOSTIC -D_REENTRANT
+CPPFLAGS.hijack.c+= -D_INCOMPLETE_XOPEN_C063
 
 WARNS?=		5
 



CVS commit: src/lib/librumphijack

2019-02-17 Thread Christoph Badura
Module Name:src
Committed By:   bad
Date:   Sun Feb 17 23:33:20 UTC 2019

Modified Files:
src/lib/librumphijack: Makefile

Log Message:
compile hijack.c with -D_INCOMPLETE_XOPEN_C063 so that AT_FDCWD is alwasy
defined for rumpkernels.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/lib/librumphijack/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2018-12-16 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun Dec 16 14:03:37 UTC 2018

Modified Files:
src/lib/librumphijack: hijack.c rumphijack.3

Log Message:
Add an option "modctl" to capture modctl().


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/lib/librumphijack/hijack.c
cvs rdiff -u -r1.12 -r1.13 src/lib/librumphijack/rumphijack.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.125 src/lib/librumphijack/hijack.c:1.126
--- src/lib/librumphijack/hijack.c:1.125	Thu Jun 28 06:20:36 2018
+++ src/lib/librumphijack/hijack.c	Sun Dec 16 14:03:37 2018
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.125 2018/06/28 06:20:36 ozaki-r Exp $	*/
+/*  $NetBSD: hijack.c,v 1.126 2018/12/16 14:03:37 hannken Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include 
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.125 2018/06/28 06:20:36 ozaki-r Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.126 2018/12/16 14:03:37 hannken Exp $");
 #endif
 
 #include 
@@ -138,6 +138,7 @@ enum dualcall {
 
 #ifdef __NetBSD__
 	DUALCALL___SYSCTL,
+	DUALCALL_MODCTL,
 #endif
 
 #ifdef __NetBSD__
@@ -351,6 +352,7 @@ struct sysnames {
 
 #ifdef __NetBSD__
 	{ DUALCALL___SYSCTL,	"__sysctl",	RSYS_NAME(__SYSCTL)	},
+	{ DUALCALL_MODCTL,	"modctl",	RSYS_NAME(MODCTL)	},
 #endif
 
 #ifdef __NetBSD__
@@ -814,6 +816,30 @@ sysctlparser(char *buf)
 	errx(1, "sysctl value should be y(es)/n(o), gave: %s", buf);
 }
 
+static bool rumpmodctl = false;
+
+static void
+modctlparser(char *buf)
+{
+
+	if (buf == NULL) {
+		rumpmodctl = true;
+		return;
+	}
+
+	if (strcasecmp(buf, "y") == 0 || strcasecmp(buf, "yes") == 0 ||
+	strcasecmp(buf, "yep") == 0 || strcasecmp(buf, "tottakai") == 0) {
+		rumpmodctl = true;
+		return;
+	}
+	if (strcasecmp(buf, "n") == 0 || strcasecmp(buf, "no") == 0) {
+		rumpmodctl = false;
+		return;
+	}
+
+	errx(1, "modctl value should be y(es)/n(o), gave: %s", buf);
+}
+
 static void
 fdoffparser(char *buf)
 {
@@ -841,6 +867,7 @@ static struct {
 	{ blanketparser, "blanket", true },
 	{ vfsparser, "vfs", true },
 	{ sysctlparser, "sysctl", false },
+	{ modctlparser, "modctl", false },
 	{ fdoffparser, "fdoff", true },
 	{ NULL, NULL, false },
 };
@@ -2334,6 +2361,20 @@ __sysctl(const int *name, unsigned int n
 
 	return op___sysctl(name, namelen, old, oldlenp, new, newlen);
 }
+int modctl(int, void *);
+int
+modctl(int operation, void *argp)
+{
+	int (*op_modctl)(int operation, void *argp);
+
+	if (rumpmodctl) {
+		op_modctl = GETSYSCALL(rump, MODCTL);
+	} else {
+		op_modctl = GETSYSCALL(host, MODCTL);
+	}
+
+	return op_modctl(operation, argp);
+}
 #endif
 
 /*

Index: src/lib/librumphijack/rumphijack.3
diff -u src/lib/librumphijack/rumphijack.3:1.12 src/lib/librumphijack/rumphijack.3:1.13
--- src/lib/librumphijack/rumphijack.3:1.12	Mon Mar 14 15:21:22 2011
+++ src/lib/librumphijack/rumphijack.3	Sun Dec 16 14:03:37 2018
@@ -1,4 +1,4 @@
-.\" $NetBSD: rumphijack.3,v 1.12 2011/03/14 15:21:22 pooka Exp $
+.\" $NetBSD: rumphijack.3,v 1.13 2018/12/16 14:03:37 hannken Exp $
 .\"
 .\" Copyright (c) 2011 Antti Kantee.  All rights reserved.
 .\"
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd March 14, 2011
+.Dd December 16, 2018
 .Dt RUMPHIJACK 3
 .Os
 .Sh NAME
@@ -173,6 +173,15 @@ Acceptable values are
 and
 .Dq no ,
 meaning to call the rump or the host kernel, respectively.
+.It Dq modctl
+Direct the
+.Fn modctl
+call to the rump kernel.
+Acceptable values are
+.Dq yes
+and
+.Dq no ,
+meaning to call the rump or the host kernel, respectively.
 .It Dq fdoff
 Adjust the library's fd offset to the specified value.
 All rump kernel descriptors have the offset added to them



CVS commit: src/lib/librumphijack

2018-12-16 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun Dec 16 14:03:37 UTC 2018

Modified Files:
src/lib/librumphijack: hijack.c rumphijack.3

Log Message:
Add an option "modctl" to capture modctl().


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/lib/librumphijack/hijack.c
cvs rdiff -u -r1.12 -r1.13 src/lib/librumphijack/rumphijack.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2018-06-28 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Jun 28 06:20:36 UTC 2018

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
rumphijack: don't modify a cmsg on just validating it

Pointed out by k-goda@IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.124 src/lib/librumphijack/hijack.c:1.125
--- src/lib/librumphijack/hijack.c:1.124	Mon Oct 23 06:52:17 2017
+++ src/lib/librumphijack/hijack.c	Thu Jun 28 06:20:36 2018
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.124 2017/10/23 06:52:17 ozaki-r Exp $	*/
+/*  $NetBSD: hijack.c,v 1.125 2018/06/28 06:20:36 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include 
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.124 2017/10/23 06:52:17 ozaki-r Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.125 2018/06/28 06:20:36 ozaki-r Exp $");
 #endif
 
 #include 
@@ -1587,7 +1587,7 @@ write(int fd, const void *buf, size_t bl
  */
 
 static int
-msg_convert(struct msghdr *msg, int (*func)(int))
+_msg_convert_fds(struct msghdr *msg, int (*func)(int), bool dryrun)
 {
 	struct cmsghdr *cmsg;
 
@@ -1607,7 +1607,8 @@ msg_convert(struct msghdr *msg, int (*fu
 if (newval < 0) {
 	return ENOTSUP;
 }
-*fdp = newval;
+if (!dryrun)
+	*fdp = newval;
 fdp++;
 			}
 		}
@@ -1615,6 +1616,20 @@ msg_convert(struct msghdr *msg, int (*fu
 	return 0;
 }
 
+static int
+msg_convert_fds(struct msghdr *msg, int (*func)(int))
+{
+
+	return _msg_convert_fds(msg, func, false);
+}
+
+static int
+msg_check_fds(struct msghdr *msg, int (*func)(int))
+{
+
+	return _msg_convert_fds(msg, func, true);
+}
+
 ssize_t
 recvmsg(int fd, struct msghdr *msg, int flags)
 {
@@ -1636,9 +1651,9 @@ recvmsg(int fd, struct msghdr *msg, int 
 	 * convert descriptors in the message.
 	 */
 	if (isrump) {
-		msg_convert(msg, fd_rump2host);
+		msg_convert_fds(msg, fd_rump2host);
 	} else {
-		msg_convert(msg, fd_host2host);
+		msg_convert_fds(msg, fd_host2host);
 	}
 	return ret;
 }
@@ -1681,7 +1696,7 @@ sendmsg(int fd, const struct msghdr *msg
 	/*
 	 * reject descriptors from a different kernel.
 	 */
-	error = msg_convert(__UNCONST(msg),
+	error = msg_check_fds(__UNCONST(msg),
 	isrump ? fd_check_rump: fd_check_host);
 	if (error != 0) {
 		errno = error;
@@ -1700,7 +1715,7 @@ sendmsg(int fd, const struct msghdr *msg
 		 *
 		 * it's safer to copy and modify instead.
 		 */
-		msg_convert(__UNCONST(msg), fd_host2rump);
+		msg_convert_fds(__UNCONST(msg), fd_host2rump);
 		op_sendmsg = GETSYSCALL(rump, SENDMSG);
 	} else {
 		op_sendmsg = GETSYSCALL(host, SENDMSG);



CVS commit: src/lib/librumphijack

2018-06-28 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Jun 28 06:20:36 UTC 2018

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
rumphijack: don't modify a cmsg on just validating it

Pointed out by k-goda@IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2017-10-23 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Oct 23 06:52:17 UTC 2017

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Provide better debug messages for ioctl


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2017-10-23 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Mon Oct 23 06:52:17 UTC 2017

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Provide better debug messages for ioctl


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.123 src/lib/librumphijack/hijack.c:1.124
--- src/lib/librumphijack/hijack.c:1.123	Tue Jun  6 19:48:42 2017
+++ src/lib/librumphijack/hijack.c	Mon Oct 23 06:52:17 2017
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.123 2017/06/06 19:48:42 christos Exp $	*/
+/*  $NetBSD: hijack.c,v 1.124 2017/10/23 06:52:17 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include 
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.123 2017/06/06 19:48:42 christos Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.124 2017/10/23 06:52:17 ozaki-r Exp $");
 #endif
 
 #include 
@@ -1406,7 +1406,7 @@ ioctl(int fd, unsigned long cmd, ...)
 	va_list ap;
 	int rv;
 
-	DPRINTF(("ioctl -> %d\n", fd));
+	DPRINTF(("ioctl -> %d (%s)\n", fd, whichfd(fd)));
 	if (fd_isrump(fd)) {
 		fd = fd_host2rump(fd);
 		op_ioctl = GETSYSCALL(rump, IOCTL);
@@ -1417,6 +1417,7 @@ ioctl(int fd, unsigned long cmd, ...)
 	va_start(ap, cmd);
 	rv = op_ioctl(fd, cmd, va_arg(ap, void *));
 	va_end(ap);
+	DPRINTF(("ioctl <- %d\n", rv));
 	return rv;
 }
 



CVS commit: src/lib/librumphijack

2017-06-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jun  6 19:48:42 UTC 2017

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
since ln(1) now uses linkat(2) provide a dumb wrapper.


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.122 src/lib/librumphijack/hijack.c:1.123
--- src/lib/librumphijack/hijack.c:1.122	Thu Feb 16 03:08:01 2017
+++ src/lib/librumphijack/hijack.c	Tue Jun  6 15:48:42 2017
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.122 2017/02/16 08:08:01 ozaki-r Exp $	*/
+/*  $NetBSD: hijack.c,v 1.123 2017/06/06 19:48:42 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include 
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.122 2017/02/16 08:08:01 ozaki-r Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.123 2017/06/06 19:48:42 christos Exp $");
 #endif
 
 #include 
@@ -163,6 +163,9 @@ enum dualcall {
 #ifdef HAVE___QUOTACTL
 	DUALCALL_QUOTACTL,
 #endif
+#ifdef __NetBSD__
+	DUALCALL_LINKAT,
+#endif
 	DUALCALL__NUM
 };
 
@@ -379,6 +382,9 @@ struct sysnames {
 	{ DUALCALL_QUOTACTL,	"__quotactl",	RSYS_NAME(__QUOTACTL)	},
 #endif /* HAVE___QUOTACTL */
 
+#ifdef __NetBSD__
+	{ DUALCALL_LINKAT,	"linkat",	RSYS_NAME(LINKAT)	},
+#endif
 };
 #undef S
 
@@ -1271,6 +1277,19 @@ moveish(const char *from, const char *to
 	return op(from, to);
 }
 
+#ifdef __NetBSD__
+int
+linkat(int fromfd, const char *from, int tofd, const char *to, int flags)
+{
+	if (fromfd != AT_FDCWD || tofd != AT_FDCWD
+	|| flags != AT_SYMLINK_FOLLOW)
+		return ENOSYS;
+
+	return moveish(from, to,
+	GETSYSCALL(rump, LINK), GETSYSCALL(host, LINK));
+}
+#endif
+
 int
 link(const char *from, const char *to)
 {



CVS commit: src/lib/librumphijack

2017-06-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jun  6 19:48:42 UTC 2017

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
since ln(1) now uses linkat(2) provide a dumb wrapper.


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2017-02-16 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Feb 16 08:08:01 UTC 2017

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Support paccept for nc


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.121 src/lib/librumphijack/hijack.c:1.122
--- src/lib/librumphijack/hijack.c:1.121	Fri Dec  2 20:53:36 2016
+++ src/lib/librumphijack/hijack.c	Thu Feb 16 08:08:01 2017
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.121 2016/12/02 20:53:36 christos Exp $	*/
+/*  $NetBSD: hijack.c,v 1.122 2017/02/16 08:08:01 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include 
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.121 2016/12/02 20:53:36 christos Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.122 2017/02/16 08:08:01 ozaki-r Exp $");
 #endif
 
 #include 
@@ -89,7 +89,8 @@ __RCSID("$NetBSD: hijack.c,v 1.121 2016/
 enum dualcall {
 	DUALCALL_WRITE, DUALCALL_WRITEV, DUALCALL_PWRITE, DUALCALL_PWRITEV,
 	DUALCALL_IOCTL, DUALCALL_FCNTL,
-	DUALCALL_SOCKET, DUALCALL_ACCEPT, DUALCALL_BIND, DUALCALL_CONNECT,
+	DUALCALL_SOCKET, DUALCALL_ACCEPT, DUALCALL_PACCEPT,
+	DUALCALL_BIND, DUALCALL_CONNECT,
 	DUALCALL_GETPEERNAME, DUALCALL_GETSOCKNAME, DUALCALL_LISTEN,
 	DUALCALL_RECVFROM, DUALCALL_RECVMSG,
 	DUALCALL_SENDTO, DUALCALL_SENDMSG,
@@ -267,6 +268,7 @@ struct sysnames {
 } syscnames[] = {
 	{ DUALCALL_SOCKET,	S(REALSOCKET),	RSYS_NAME(SOCKET)	},
 	{ DUALCALL_ACCEPT,	"accept",	RSYS_NAME(ACCEPT)	},
+	{ DUALCALL_PACCEPT,	"paccept",	RSYS_NAME(PACCEPT)	},
 	{ DUALCALL_BIND,	"bind",		RSYS_NAME(BIND)		},
 	{ DUALCALL_CONNECT,	"connect",	RSYS_NAME(CONNECT)	},
 	{ DUALCALL_GETPEERNAME,	"getpeername",	RSYS_NAME(GETPEERNAME)	},
@@ -1334,6 +1336,35 @@ accept(int s, struct sockaddr *addr, soc
 	return fd;
 }
 
+int
+paccept(int s, struct sockaddr *addr, socklen_t *addrlen,
+const sigset_t * restrict sigmask, int flags)
+{
+	int (*op_paccept)(int, struct sockaddr *, socklen_t *,
+	const sigset_t * restrict, int);
+	int fd;
+	bool isrump;
+
+	isrump = fd_isrump(s);
+
+	DPRINTF(("paccept -> %d", s));
+	if (isrump) {
+		op_paccept = GETSYSCALL(rump, PACCEPT);
+		s = fd_host2rump(s);
+	} else {
+		op_paccept = GETSYSCALL(host, PACCEPT);
+	}
+	fd = op_paccept(s, addr, addrlen, sigmask, flags);
+	if (fd != -1 && isrump)
+		fd = fd_rump2host(fd);
+	else
+		fd = fd_host2host(fd);
+
+	DPRINTF((" <- %d\n", fd));
+
+	return fd;
+}
+
 /*
  * ioctl() and fcntl() are varargs calls and need special treatment.
  */



CVS commit: src/lib/librumphijack

2017-02-16 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Thu Feb 16 08:08:01 UTC 2017

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Support paccept for nc


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2016-12-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Dec  2 20:53:37 UTC 2016

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
fix test lib/librumphijack/t_sh/runscript
(handle F_DUPFD_CLOEXEC that the shell is now using)


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2016-12-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Dec  2 20:53:37 UTC 2016

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
fix test lib/librumphijack/t_sh/runscript
(handle F_DUPFD_CLOEXEC that the shell is now using)


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.120 src/lib/librumphijack/hijack.c:1.121
--- src/lib/librumphijack/hijack.c:1.120	Thu Aug 11 05:48:57 2016
+++ src/lib/librumphijack/hijack.c	Fri Dec  2 15:53:36 2016
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.120 2016/08/11 09:48:57 kre Exp $	*/
+/*  $NetBSD: hijack.c,v 1.121 2016/12/02 20:53:36 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include 
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.120 2016/08/11 09:48:57 kre Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.121 2016/12/02 20:53:36 christos Exp $");
 #endif
 
 #include 
@@ -987,7 +987,6 @@ fd_rump2host_withdup(int fd)
 static int
 fd_host2rump(int fd)
 {
-
 	if (!isdup2d(fd))
 		return fd - hijack_fdoff;
 	else
@@ -1381,6 +1380,7 @@ fcntl(int fd, int cmd, ...)
 	DPRINTF(("fcntl -> %d (cmd %d)\n", fd, cmd));
 
 	switch (cmd) {
+	case F_DUPFD_CLOEXEC:	/* Ignore CLOEXEC bit for now */
 	case F_DUPFD:
 		va_start(ap, cmd);
 		minfd = va_arg(ap, int);



CVS commit: src/lib/librumphijack

2016-08-11 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Aug 11 09:48:57 UTC 2016

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Object to dup2() if target fd is in the range of fd's that
librumphijack reserves for rump to use.

This is not normally a problem, as most applications don't attempt
to use very high fds - but /bin/sh does.

This fix is something of a kludge - really the apparent fd resource limit
ought to be lowered as well, but this is sufficient to allow the shell
to work (when its dup2() gets rejected, it just tries again with a smaller
target fd until it eventually succeeds.)   This fixes the librumphijack
shell ATF tests.

A better, more comprehensive, fix would be good...


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.119 src/lib/librumphijack/hijack.c:1.120
--- src/lib/librumphijack/hijack.c:1.119	Tue Aug 25 13:50:19 2015
+++ src/lib/librumphijack/hijack.c	Thu Aug 11 09:48:57 2016
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.119 2015/08/25 13:50:19 pooka Exp $	*/
+/*  $NetBSD: hijack.c,v 1.120 2016/08/11 09:48:57 kre Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include 
 
 #if !defined(lint)
-__RCSID("$NetBSD: hijack.c,v 1.119 2015/08/25 13:50:19 pooka Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.120 2016/08/11 09:48:57 kre Exp $");
 #endif
 
 #include 
@@ -1064,6 +1064,10 @@ dodup(int oldd, int minfd)
 			minfd -= hijack_fdoff;
 		isrump = 1;
 	} else {
+		if (minfd >= hijack_fdoff) {
+			errno = EINVAL;
+			return -1;
+		}
 		op_fcntl = GETSYSCALL(host, FCNTL);
 		isrump = 0;
 	}



CVS commit: src/lib/librumphijack

2016-08-11 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Aug 11 09:48:57 UTC 2016

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Object to dup2() if target fd is in the range of fd's that
librumphijack reserves for rump to use.

This is not normally a problem, as most applications don't attempt
to use very high fds - but /bin/sh does.

This fix is something of a kludge - really the apparent fd resource limit
ought to be lowered as well, but this is sufficient to allow the shell
to work (when its dup2() gets rejected, it just tries again with a smaller
target fd until it eventually succeeds.)   This fixes the librumphijack
shell ATF tests.

A better, more comprehensive, fix would be good...


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2015-08-25 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Aug 25 13:50:19 UTC 2015

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Remember that dlsym() tends to fail on PowerPC during init (or at least
tended), so call rumphijack_dlsym() instead to be safe.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2015-08-25 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Aug 25 13:50:19 UTC 2015

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Remember that dlsym() tends to fail on PowerPC during init (or at least
tended), so call rumphijack_dlsym() instead to be safe.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.118 src/lib/librumphijack/hijack.c:1.119
--- src/lib/librumphijack/hijack.c:1.118	Tue Aug 25 13:45:00 2015
+++ src/lib/librumphijack/hijack.c	Tue Aug 25 13:50:19 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.118 2015/08/25 13:45:00 pooka Exp $	*/
+/*  $NetBSD: hijack.c,v 1.119 2015/08/25 13:50:19 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include rump/rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: hijack.c,v 1.118 2015/08/25 13:45:00 pooka Exp $);
+__RCSID($NetBSD: hijack.c,v 1.119 2015/08/25 13:50:19 pooka Exp $);
 #endif
 
 #include sys/param.h
@@ -2235,7 +2235,7 @@ mmap(void *addr, size_t len, int prot, i
 		return MAP_FAILED;
 	}
 	if (__predict_false(host_mmap == NULL)) {
-		host_mmap = dlsym(RTLD_NEXT, mmap);
+		host_mmap = rumphijack_dlsym(RTLD_NEXT, mmap);
 	}
 	return host_mmap(addr, len, prot, flags, fd, offset);
 }



CVS commit: src/lib/librumphijack

2015-08-25 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Aug 25 13:45:00 UTC 2015

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
allow mmap() to be called before init runs


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.117 src/lib/librumphijack/hijack.c:1.118
--- src/lib/librumphijack/hijack.c:1.117	Sat Apr 11 12:54:41 2015
+++ src/lib/librumphijack/hijack.c	Tue Aug 25 13:45:00 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.117 2015/04/11 12:54:41 riastradh Exp $	*/
+/*  $NetBSD: hijack.c,v 1.118 2015/08/25 13:45:00 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include rump/rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: hijack.c,v 1.117 2015/04/11 12:54:41 riastradh Exp $);
+__RCSID($NetBSD: hijack.c,v 1.118 2015/08/25 13:45:00 pooka Exp $);
 #endif
 
 #include sys/param.h
@@ -885,7 +885,8 @@ rcinit(void)
 
 	host_fork = dlsym(RTLD_NEXT, fork);
 	host_daemon = dlsym(RTLD_NEXT, daemon);
-	host_mmap = dlsym(RTLD_NEXT, mmap);
+	if (host_mmap == NULL)
+		host_mmap = dlsym(RTLD_NEXT, mmap);
 
 	/*
 	 * In theory cannot print anything during lookups because
@@ -2233,6 +2234,9 @@ mmap(void *addr, size_t len, int prot, i
 		errno = ENOSYS;
 		return MAP_FAILED;
 	}
+	if (__predict_false(host_mmap == NULL)) {
+		host_mmap = dlsym(RTLD_NEXT, mmap);
+	}
 	return host_mmap(addr, len, prot, flags, fd, offset);
 }
 



CVS commit: src/lib/librumphijack

2015-08-25 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Aug 25 13:45:00 UTC 2015

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
allow mmap() to be called before init runs


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2015-04-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Apr 11 12:54:41 UTC 2015

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Define the expansion of the VFORK macro, not the symbol `VFORK'.

Fixes hijacking processes that vfork and exec.  Symptom was the child
would spin with read/EAGAIN - kevent/EBADF because the inheritance
mechanism relied on setting the holyfd to -1 on fork...which didn't
happen if we didn't hijack vfork.

ok pooka@


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2015-04-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Apr 11 12:54:41 UTC 2015

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Define the expansion of the VFORK macro, not the symbol `VFORK'.

Fixes hijacking processes that vfork and exec.  Symptom was the child
would spin with read/EAGAIN - kevent/EBADF because the inheritance
mechanism relied on setting the holyfd to -1 on fork...which didn't
happen if we didn't hijack vfork.

ok pooka@


To generate a diff of this commit:
cvs rdiff -u -r1.116 -r1.117 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.116 src/lib/librumphijack/hijack.c:1.117
--- src/lib/librumphijack/hijack.c:1.116	Thu Mar  5 00:26:17 2015
+++ src/lib/librumphijack/hijack.c	Sat Apr 11 12:54:41 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.116 2015/03/05 00:26:17 pooka Exp $	*/
+/*  $NetBSD: hijack.c,v 1.117 2015/04/11 12:54:41 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include rump/rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: hijack.c,v 1.116 2015/03/05 00:26:17 pooka Exp $);
+__RCSID($NetBSD: hijack.c,v 1.117 2015/04/11 12:54:41 riastradh Exp $);
 #endif
 
 #include sys/param.h
@@ -1721,7 +1721,8 @@ fork(void)
 }
 #ifdef VFORK
 /* we do not have the luxury of not requiring a stackframe */
-__strong_alias(VFORK,fork);
+#define	__strong_alias_macro(m, f)	__strong_alias(m, f)
+__strong_alias_macro(VFORK,fork);
 #endif
 
 int



CVS commit: src/lib/librumphijack

2015-03-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Mar  4 23:31:49 UTC 2015

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Define a generic ATCALL() and use it to implement utimensat()


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.113 src/lib/librumphijack/hijack.c:1.114
--- src/lib/librumphijack/hijack.c:1.113	Tue Mar  3 01:24:39 2015
+++ src/lib/librumphijack/hijack.c	Wed Mar  4 23:31:49 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.113 2015/03/03 01:24:39 enami Exp $	*/
+/*  $NetBSD: hijack.c,v 1.114 2015/03/04 23:31:49 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include rump/rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: hijack.c,v 1.113 2015/03/03 01:24:39 enami Exp $);
+__RCSID($NetBSD: hijack.c,v 1.114 2015/03/04 23:31:49 pooka Exp $);
 #endif
 
 #include sys/param.h
@@ -525,6 +525,33 @@ whichpath(const char *path)
 #define DPRINTF(x)
 #endif
 
+#define ATCALL(type, name, rcname, args, proto, vars)			\
+type name args\
+{	\
+	type (*fun) proto;		\
+	int isrump = -1;		\
+	\
+	if (fd == AT_FDCWD) {		\
+		isrump = path_isrump(path);\
+	} else {			\
+		isrump = fd_isrump(fd);	\
+	}\
+	\
+	DPRINTF((%s - %d:%s (%s)\n, __STRING(name),			\
+	fd, path, isrump ? rump : host));			\
+	\
+	assert(isrump != -1);		\
+	if (isrump) {			\
+		fun = syscalls[rcname].bs_rump;\
+		if (fd != AT_FDCWD)	\
+			fd = fd_host2rump(fd);\
+		path = path_host2rump(path);\
+	} else {			\
+		fun = syscalls[rcname].bs_host;\
+	}\
+	return fun vars;		\
+}
+
 #define FDCALL(type, name, rcname, args, proto, vars)			\
 type name args\
 {	\
@@ -2238,6 +2265,11 @@ __sysctl(const int *name, unsigned int n
  * Rest are std type calls.
  */
 
+ATCALL(int, utimensat, DUALCALL_UTIMENSAT,\
+	(int fd, const char *path, const struct timespec t[2], int f),	\
+	(int, const char *, const struct timespec [2], int),
+	(fd, path, t, f))
+
 FDCALL(int, bind, DUALCALL_BIND,	\
 	(int fd, const struct sockaddr *name, socklen_t namelen),	\
 	(int, const struct sockaddr *, socklen_t),			\
@@ -2504,11 +2536,6 @@ PATHCALL(int, lutimes, DUALCALL_LUTIMES,
 	(const char *, const struct timeval *),\
 	(path, tv))
 
-PATHCALL(int, utimensat, DUALCALL_UTIMENSAT,\
-	(int fd, const char *path, const struct timespec *ts, int flags), \
-	(int, const char *, const struct timespec *, int),		\
-	(fd, path, ts, flags))
-
 #ifdef HAVE_CHFLAGS
 PATHCALL(int, chflags, DUALCALL_CHFLAGS,\
 	(const char *path, u_long flags),\



CVS commit: src/lib/librumphijack

2015-03-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Mar  4 23:31:49 UTC 2015

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Define a generic ATCALL() and use it to implement utimensat()


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2015-03-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Mar  4 23:42:26 UTC 2015

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Make ATCALL() behave for absolute paths too.


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2015-03-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Mar  4 23:42:26 UTC 2015

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Make ATCALL() behave for absolute paths too.


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.114 src/lib/librumphijack/hijack.c:1.115
--- src/lib/librumphijack/hijack.c:1.114	Wed Mar  4 23:31:49 2015
+++ src/lib/librumphijack/hijack.c	Wed Mar  4 23:42:26 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.114 2015/03/04 23:31:49 pooka Exp $	*/
+/*  $NetBSD: hijack.c,v 1.115 2015/03/04 23:42:26 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include rump/rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: hijack.c,v 1.114 2015/03/04 23:31:49 pooka Exp $);
+__RCSID($NetBSD: hijack.c,v 1.115 2015/03/04 23:42:26 pooka Exp $);
 #endif
 
 #include sys/param.h
@@ -531,7 +531,7 @@ type name args\
 	type (*fun) proto;		\
 	int isrump = -1;		\
 	\
-	if (fd == AT_FDCWD) {		\
+	if (fd == AT_FDCWD || *path == '/') {\
 		isrump = path_isrump(path);\
 	} else {			\
 		isrump = fd_isrump(fd);	\



CVS commit: src/lib/librumphijack

2015-03-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Mar  5 00:26:17 UTC 2015

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Wrap utimensat() only if present on host

fixes buildrump.sh on NetBSD 6.1.5


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.115 src/lib/librumphijack/hijack.c:1.116
--- src/lib/librumphijack/hijack.c:1.115	Wed Mar  4 23:42:26 2015
+++ src/lib/librumphijack/hijack.c	Thu Mar  5 00:26:17 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.115 2015/03/04 23:42:26 pooka Exp $	*/
+/*  $NetBSD: hijack.c,v 1.116 2015/03/05 00:26:17 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include rump/rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: hijack.c,v 1.115 2015/03/04 23:42:26 pooka Exp $);
+__RCSID($NetBSD: hijack.c,v 1.116 2015/03/05 00:26:17 pooka Exp $);
 #endif
 
 #include sys/param.h
@@ -2265,10 +2265,12 @@ __sysctl(const int *name, unsigned int n
  * Rest are std type calls.
  */
 
+#ifdef HAVE_UTIMENSAT
 ATCALL(int, utimensat, DUALCALL_UTIMENSAT,\
 	(int fd, const char *path, const struct timespec t[2], int f),	\
 	(int, const char *, const struct timespec [2], int),
 	(fd, path, t, f))
+#endif
 
 FDCALL(int, bind, DUALCALL_BIND,	\
 	(int fd, const struct sockaddr *name, socklen_t namelen),	\



CVS commit: src/lib/librumphijack

2015-03-04 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Mar  5 00:26:17 UTC 2015

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Wrap utimensat() only if present on host

fixes buildrump.sh on NetBSD 6.1.5


To generate a diff of this commit:
cvs rdiff -u -r1.115 -r1.116 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2015-03-02 Thread enami tsugutomo
Module Name:src
Committed By:   enami
Date:   Tue Mar  3 00:19:07 UTC 2015

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Hijack utimensat(2) so that t_vfs test passes after cp(1)/mv(1) are
changed to use the system call.  Linux also has this system call, but
not tested this on linux.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.111 src/lib/librumphijack/hijack.c:1.112
--- src/lib/librumphijack/hijack.c:1.111	Tue Nov  4 19:05:17 2014
+++ src/lib/librumphijack/hijack.c	Tue Mar  3 00:19:07 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.111 2014/11/04 19:05:17 pooka Exp $	*/
+/*  $NetBSD: hijack.c,v 1.112 2015/03/03 00:19:07 enami Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include rump/rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: hijack.c,v 1.111 2014/11/04 19:05:17 pooka Exp $);
+__RCSID($NetBSD: hijack.c,v 1.112 2015/03/03 00:19:07 enami Exp $);
 #endif
 
 #include sys/param.h
@@ -113,6 +113,7 @@ enum dualcall {
 	DUALCALL_LINK, DUALCALL_RENAME,
 	DUALCALL_MKDIR, DUALCALL_RMDIR,
 	DUALCALL_UTIMES, DUALCALL_LUTIMES, DUALCALL_FUTIMES,
+	DUALCALL_UTIMENSAT,
 	DUALCALL_TRUNCATE, DUALCALL_FTRUNCATE,
 	DUALCALL_FSYNC,
 	DUALCALL_ACCESS,
@@ -305,6 +306,7 @@ struct sysnames {
 	{ DUALCALL_UTIMES,	S(REALUTIMES),	RSYS_NAME(UTIMES)	},
 	{ DUALCALL_LUTIMES,	S(REALLUTIMES),	RSYS_NAME(LUTIMES)	},
 	{ DUALCALL_FUTIMES,	S(REALFUTIMES),	RSYS_NAME(FUTIMES)	},
+	{ DUALCALL_UTIMENSAT,	utimensat,	RSYS_NAME(UTIMENSAT)	},
 	{ DUALCALL_OPEN,	open,		RSYS_NAME(OPEN)		},
 	{ DUALCALL_CHDIR,	chdir,	RSYS_NAME(CHDIR)	},
 	{ DUALCALL_FCHDIR,	fchdir,	RSYS_NAME(FCHDIR)	},
@@ -2496,6 +2498,11 @@ PATHCALL(int, lutimes, DUALCALL_LUTIMES,
 	(const char *, const struct timeval *),\
 	(path, tv))
 
+PATHCALL(int, utimensat, DUALCALL_UTIMENSAT,\
+	(int fd, const char *path, const struct timespec *ts, int flags), \
+	(int, const char *, const struct timespec *, int),		\
+	(fd, path, ts, flags))
+
 #ifdef HAVE_CHFLAGS
 PATHCALL(int, chflags, DUALCALL_CHFLAGS,\
 	(const char *path, u_long flags),\



CVS commit: src/lib/librumphijack

2015-03-02 Thread enami tsugutomo
Module Name:src
Committed By:   enami
Date:   Tue Mar  3 00:19:07 UTC 2015

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Hijack utimensat(2) so that t_vfs test passes after cp(1)/mv(1) are
changed to use the system call.  Linux also has this system call, but
not tested this on linux.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




CVS commit: src/lib/librumphijack

2015-03-02 Thread enami tsugutomo
Module Name:src
Committed By:   enami
Date:   Tue Mar  3 01:24:39 UTC 2015

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Also hijack futimens(2) so that t_sh test passes.


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2015-03-02 Thread enami tsugutomo
Module Name:src
Committed By:   enami
Date:   Tue Mar  3 01:24:39 UTC 2015

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Also hijack futimens(2) so that t_sh test passes.


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.112 src/lib/librumphijack/hijack.c:1.113
--- src/lib/librumphijack/hijack.c:1.112	Tue Mar  3 00:19:07 2015
+++ src/lib/librumphijack/hijack.c	Tue Mar  3 01:24:39 2015
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.112 2015/03/03 00:19:07 enami Exp $	*/
+/*  $NetBSD: hijack.c,v 1.113 2015/03/03 01:24:39 enami Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -34,7 +34,7 @@
 #include rump/rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: hijack.c,v 1.112 2015/03/03 00:19:07 enami Exp $);
+__RCSID($NetBSD: hijack.c,v 1.113 2015/03/03 01:24:39 enami Exp $);
 #endif
 
 #include sys/param.h
@@ -113,7 +113,7 @@ enum dualcall {
 	DUALCALL_LINK, DUALCALL_RENAME,
 	DUALCALL_MKDIR, DUALCALL_RMDIR,
 	DUALCALL_UTIMES, DUALCALL_LUTIMES, DUALCALL_FUTIMES,
-	DUALCALL_UTIMENSAT,
+	DUALCALL_UTIMENSAT, DUALCALL_FUTIMENS,
 	DUALCALL_TRUNCATE, DUALCALL_FTRUNCATE,
 	DUALCALL_FSYNC,
 	DUALCALL_ACCESS,
@@ -307,6 +307,7 @@ struct sysnames {
 	{ DUALCALL_LUTIMES,	S(REALLUTIMES),	RSYS_NAME(LUTIMES)	},
 	{ DUALCALL_FUTIMES,	S(REALFUTIMES),	RSYS_NAME(FUTIMES)	},
 	{ DUALCALL_UTIMENSAT,	utimensat,	RSYS_NAME(UTIMENSAT)	},
+	{ DUALCALL_FUTIMENS,	futimens,	RSYS_NAME(FUTIMENS)	},
 	{ DUALCALL_OPEN,	open,		RSYS_NAME(OPEN)		},
 	{ DUALCALL_CHDIR,	chdir,	RSYS_NAME(CHDIR)	},
 	{ DUALCALL_FCHDIR,	fchdir,	RSYS_NAME(FCHDIR)	},
@@ -2392,6 +2393,11 @@ FDCALL(int, futimes, DUALCALL_FUTIMES,		
 	(int, const struct timeval *),	\
 	(fd, tv))
 
+FDCALL(int, futimens, DUALCALL_FUTIMENS,\
+	(int fd, const struct timespec *ts),\
+	(int, const struct timespec *),	\
+	(fd, ts))
+
 #ifdef HAVE_CHFLAGS
 FDCALL(int, fchflags, DUALCALL_FCHFLAGS,\
 	(int fd, u_long flags),		\



CVS commit: src/lib/librumphijack

2014-08-12 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Aug 12 23:47:09 UTC 2014

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
In case of no dup2'd fd's, make sure that F_CLOSEM for the
rump kernel starts from 0.

Fixes rumphijack fdoff test (notably, this bug had nothing to do with
fdoff, and was exposed 3 years after writing the test when rump kernels
started providing fd's 0/1/2)


To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.109 src/lib/librumphijack/hijack.c:1.110
--- src/lib/librumphijack/hijack.c:1.109	Mon Jul 21 14:23:43 2014
+++ src/lib/librumphijack/hijack.c	Tue Aug 12 23:47:09 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.109 2014/07/21 14:23:43 gson Exp $	*/
+/*  $NetBSD: hijack.c,v 1.110 2014/08/12 23:47:09 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include rump/rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: hijack.c,v 1.109 2014/07/21 14:23:43 gson Exp $);
+__RCSID($NetBSD: hijack.c,v 1.110 2014/08/12 23:47:09 pooka Exp $);
 #endif
 
 #include sys/param.h
@@ -1380,7 +1380,7 @@ fcntl(int fd, int cmd, ...)
 		 * for the file descriptors not dup2'd.
 		 */
 
-		for (i = 0, maxdup2 = 0; i = DUP2HIGH; i++) {
+		for (i = 0, maxdup2 = -1; i = DUP2HIGH; i++) {
 			if (dup2vec[i]  DUP2BIT) {
 int val;
 



CVS commit: src/lib/librumphijack

2014-08-12 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Aug 12 23:47:09 UTC 2014

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
In case of no dup2'd fd's, make sure that F_CLOSEM for the
rump kernel starts from 0.

Fixes rumphijack fdoff test (notably, this bug had nothing to do with
fdoff, and was exposed 3 years after writing the test when rump kernels
started providing fd's 0/1/2)


To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2014-07-21 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Mon Jul 21 14:23:43 UTC 2014

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Ignore the contents of revents when poll() returns failure.
This is one more part to the fix for PR kern/46464.  Patch
from pooka.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.108 src/lib/librumphijack/hijack.c:1.109
--- src/lib/librumphijack/hijack.c:1.108	Sat Jul 19 14:14:21 2014
+++ src/lib/librumphijack/hijack.c	Mon Jul 21 14:23:43 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.108 2014/07/19 14:14:21 gson Exp $	*/
+/*  $NetBSD: hijack.c,v 1.109 2014/07/21 14:23:43 gson Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include rump/rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: hijack.c,v 1.108 2014/07/19 14:14:21 gson Exp $);
+__RCSID($NetBSD: hijack.c,v 1.109 2014/07/21 14:23:43 gson Exp $);
 #endif
 
 #include sys/param.h
@@ -2069,12 +2069,10 @@ REALPOLLTS(struct pollfd *fds, nfds_t nf
 		errno_host = parg.errnum;
 
 		/* strip cross-thread notification from real results */
-		if (pfd_host[nfds].revents  POLLIN) {
-			assert(rv_host  0);
+		if (rv_host  0  pfd_host[nfds].revents  POLLIN) {
 			rv_host--;
 		}
-		if (pfd_rump[nfds].revents  POLLIN) {
-			assert(rv_rump  0);
+		if (rv_rump  0  pfd_rump[nfds].revents  POLLIN) {
 			rv_rump--;
 		}
 



CVS commit: src/lib/librumphijack

2014-07-21 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Mon Jul 21 14:23:43 UTC 2014

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Ignore the contents of revents when poll() returns failure.
This is one more part to the fix for PR kern/46464.  Patch
from pooka.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2014-07-19 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Sat Jul 19 14:14:21 UTC 2014

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Do not assert that the two threads do not simultanously notify each
other, because sometimes they do.  Should fix PR kern/46464.  OK pooka.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.107 src/lib/librumphijack/hijack.c:1.108
--- src/lib/librumphijack/hijack.c:1.107	Wed Apr  2 17:09:23 2014
+++ src/lib/librumphijack/hijack.c	Sat Jul 19 14:14:21 2014
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.107 2014/04/02 17:09:23 justin Exp $	*/
+/*  $NetBSD: hijack.c,v 1.108 2014/07/19 14:14:21 gson Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include rump/rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: hijack.c,v 1.107 2014/04/02 17:09:23 justin Exp $);
+__RCSID($NetBSD: hijack.c,v 1.108 2014/07/19 14:14:21 gson Exp $);
 #endif
 
 #include sys/param.h
@@ -2070,12 +2070,10 @@ REALPOLLTS(struct pollfd *fds, nfds_t nf
 
 		/* strip cross-thread notification from real results */
 		if (pfd_host[nfds].revents  POLLIN) {
-			assert((pfd_rump[nfds].revents  POLLIN) == 0);
 			assert(rv_host  0);
 			rv_host--;
 		}
 		if (pfd_rump[nfds].revents  POLLIN) {
-			assert((pfd_host[nfds].revents  POLLIN) == 0);
 			assert(rv_rump  0);
 			rv_rump--;
 		}



CVS commit: src/lib/librumphijack

2014-07-19 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Sat Jul 19 14:14:21 UTC 2014

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Do not assert that the two threads do not simultanously notify each
other, because sometimes they do.  Should fix PR kern/46464.  OK pooka.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2014-01-18 Thread Matthias Scheler
Module Name:src
Committed By:   tron
Date:   Sat Jan 18 18:37:30 UTC 2014

Modified Files:
src/lib/librumphijack: Makefile

Log Message:
Make sure that _FORTIFY_SOURCE really gets undefined even if USE_SSP
is set to yes to fix build problems caused by the recent change to
this makefile.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/lib/librumphijack/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/Makefile
diff -u src/lib/librumphijack/Makefile:1.15 src/lib/librumphijack/Makefile:1.16
--- src/lib/librumphijack/Makefile:1.15	Fri Jan 10 15:54:29 2014
+++ src/lib/librumphijack/Makefile	Sat Jan 18 18:37:30 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.15 2014/01/10 15:54:29 christos Exp $
+#	$NetBSD: Makefile,v 1.16 2014/01/18 18:37:30 tron Exp $
 #
 
 LIB=		rumphijack
@@ -18,6 +18,6 @@ WARNS?=		5
 # a stack frame
 COPTS.hijackdlsym.c+=	-O0
 
-CPPFLAGS+=	-U_FORTIFY_SOURCE
-
 .include bsd.lib.mk
+
+CPPFLAGS+=	-U_FORTIFY_SOURCE



CVS commit: src/lib/librumphijack

2014-01-18 Thread Matthias Scheler
Module Name:src
Committed By:   tron
Date:   Sat Jan 18 18:37:30 UTC 2014

Modified Files:
src/lib/librumphijack: Makefile

Log Message:
Make sure that _FORTIFY_SOURCE really gets undefined even if USE_SSP
is set to yes to fix build problems caused by the recent change to
this makefile.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/lib/librumphijack/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2014-01-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 10 15:54:29 UTC 2014

Modified Files:
src/lib/librumphijack: Makefile

Log Message:
don't need to include anything before bsd.lib.mk since we don't use any
variables


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/lib/librumphijack/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/Makefile
diff -u src/lib/librumphijack/Makefile:1.14 src/lib/librumphijack/Makefile:1.15
--- src/lib/librumphijack/Makefile:1.14	Fri Jan 10 10:00:16 2014
+++ src/lib/librumphijack/Makefile	Fri Jan 10 10:54:29 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.14 2014/01/10 15:00:16 martin Exp $
+#	$NetBSD: Makefile,v 1.15 2014/01/10 15:54:29 christos Exp $
 #
 
 LIB=		rumphijack
@@ -18,9 +18,6 @@ WARNS?=		5
 # a stack frame
 COPTS.hijackdlsym.c+=	-O0
 
-.include bsd.own.mk	# prerequisite for bsd.sys.mk
-.include bsd.sys.mk
-
 CPPFLAGS+=	-U_FORTIFY_SOURCE
 
 .include bsd.lib.mk



CVS commit: src/lib/librumphijack

2014-01-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan 10 15:54:29 UTC 2014

Modified Files:
src/lib/librumphijack: Makefile

Log Message:
don't need to include anything before bsd.lib.mk since we don't use any
variables


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/lib/librumphijack/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2013-07-31 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Jul 31 12:23:25 UTC 2013

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
remove unnecessary sys/poll.h -- musl whines when it's included


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.104 src/lib/librumphijack/hijack.c:1.105
--- src/lib/librumphijack/hijack.c:1.104	Sat Jul 27 17:37:29 2013
+++ src/lib/librumphijack/hijack.c	Wed Jul 31 12:23:25 2013
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.104 2013/07/27 17:37:29 pooka Exp $	*/
+/*  $NetBSD: hijack.c,v 1.105 2013/07/31 12:23:25 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: hijack.c,v 1.104 2013/07/27 17:37:29 pooka Exp $);
+__RCSID($NetBSD: hijack.c,v 1.105 2013/07/31 12:23:25 pooka Exp $);
 #endif
 
 #include sys/param.h
@@ -36,7 +36,6 @@ __RCSID($NetBSD: hijack.c,v 1.104 2013/
 #include sys/ioctl.h
 #include sys/mman.h
 #include sys/mount.h
-#include sys/poll.h
 #include sys/socket.h
 #include sys/stat.h
 #include sys/statvfs.h



CVS commit: src/lib/librumphijack

2013-07-31 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Wed Jul 31 12:23:25 UTC 2013

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
remove unnecessary sys/poll.h -- musl whines when it's included


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2013-07-29 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Jul 29 10:13:21 UTC 2013

Modified Files:
src/lib/librumphijack: Makefile

Log Message:
Override ssp also in case where it doesn't come intrinsically
from the compiler.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/librumphijack/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/Makefile
diff -u src/lib/librumphijack/Makefile:1.11 src/lib/librumphijack/Makefile:1.12
--- src/lib/librumphijack/Makefile:1.11	Sat Jul 27 17:37:29 2013
+++ src/lib/librumphijack/Makefile	Mon Jul 29 10:13:21 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.11 2013/07/27 17:37:29 pooka Exp $
+#	$NetBSD: Makefile,v 1.12 2013/07/29 10:13:21 pooka Exp $
 #
 
 LIB=		rumphijack
@@ -11,7 +11,6 @@ MAN=		rumphijack.3
 SRCS=		hijack.c hijackdlsym.c
 
 CPPFLAGS+=	-D_DIAGNOSTIC -D_REENTRANT -I${.CURDIR}/../librumpuser
-CPPFLAGS+=	-U_FORTIFY_SOURCE
 
 WARNS?=		5
 
@@ -19,4 +18,8 @@ WARNS?=		5
 # a stack frame
 COPTS.hijackdlsym.c+=	-O0
 
+.include bsd.sys.mk
+
+CPPFLAGS+=	-U_FORTIFY_SOURCE
+
 .include bsd.lib.mk



CVS commit: src/lib/librumphijack

2013-07-29 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Jul 29 10:13:21 UTC 2013

Modified Files:
src/lib/librumphijack: Makefile

Log Message:
Override ssp also in case where it doesn't come intrinsically
from the compiler.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/librumphijack/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2013-07-27 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Sat Jul 27 17:37:29 UTC 2013

Modified Files:
src/lib/librumphijack: Makefile hijack.c

Log Message:
Extend #undef _FORTIFY_SOURCE to both files to avoid compiler
warning for -O0 and fortify combination.

from Alessio Sergi via github


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/librumphijack/Makefile
cvs rdiff -u -r1.103 -r1.104 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/Makefile
diff -u src/lib/librumphijack/Makefile:1.10 src/lib/librumphijack/Makefile:1.11
--- src/lib/librumphijack/Makefile:1.10	Sat Aug 25 18:00:06 2012
+++ src/lib/librumphijack/Makefile	Sat Jul 27 17:37:29 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.10 2012/08/25 18:00:06 pooka Exp $
+#	$NetBSD: Makefile,v 1.11 2013/07/27 17:37:29 pooka Exp $
 #
 
 LIB=		rumphijack
@@ -11,6 +11,7 @@ MAN=		rumphijack.3
 SRCS=		hijack.c hijackdlsym.c
 
 CPPFLAGS+=	-D_DIAGNOSTIC -D_REENTRANT -I${.CURDIR}/../librumpuser
+CPPFLAGS+=	-U_FORTIFY_SOURCE
 
 WARNS?=		5
 

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.103 src/lib/librumphijack/hijack.c:1.104
--- src/lib/librumphijack/hijack.c:1.103	Mon Jul 22 12:11:03 2013
+++ src/lib/librumphijack/hijack.c	Sat Jul 27 17:37:29 2013
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.103 2013/07/22 12:11:03 pooka Exp $	*/
+/*  $NetBSD: hijack.c,v 1.104 2013/07/27 17:37:29 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -25,13 +25,10 @@
  * SUCH DAMAGE.
  */
 
-/* Disable namespace mangling, Fortification is useless here anyway. */
-#undef _FORTIFY_SOURCE
-
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: hijack.c,v 1.103 2013/07/22 12:11:03 pooka Exp $);
+__RCSID($NetBSD: hijack.c,v 1.104 2013/07/27 17:37:29 pooka Exp $);
 #endif
 
 #include sys/param.h



CVS commit: src/lib/librumphijack

2013-07-22 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Jul 22 12:11:03 UTC 2013

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Support Linuxen where libc ioctl has cmd as int unstead of unsigned long.


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.102 src/lib/librumphijack/hijack.c:1.103
--- src/lib/librumphijack/hijack.c:1.102	Sat Jul 20 18:46:15 2013
+++ src/lib/librumphijack/hijack.c	Mon Jul 22 12:11:03 2013
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.102 2013/07/20 18:46:15 pooka Exp $	*/
+/*  $NetBSD: hijack.c,v 1.103 2013/07/22 12:11:03 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -31,7 +31,7 @@
 #include rumpuser_port.h
 
 #if !defined(lint)
-__RCSID($NetBSD: hijack.c,v 1.102 2013/07/20 18:46:15 pooka Exp $);
+__RCSID($NetBSD: hijack.c,v 1.103 2013/07/22 12:11:03 pooka Exp $);
 #endif
 
 #include sys/param.h
@@ -1305,12 +1305,24 @@ accept(int s, struct sockaddr *addr, soc
 }
 
 /*
- * ioctl and fcntl are varargs calls and need special treatment
+ * ioctl() and fcntl() are varargs calls and need special treatment.
+ */
+
+/*
+ * Various [Linux] libc's have various signatures for ioctl so we
+ * need to handle the discrepancies.  On NetBSD, we use the
+ * one with unsigned long cmd.
  */
 int
+#ifdef HAVE_IOCTL_CMD_INT
+ioctl(int fd, int cmd, ...)
+{
+	int (*op_ioctl)(int, int cmd, ...);
+#else
 ioctl(int fd, unsigned long cmd, ...)
 {
 	int (*op_ioctl)(int, unsigned long cmd, ...);
+#endif
 	va_list ap;
 	int rv;
 



CVS commit: src/lib/librumphijack

2013-07-22 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Jul 22 12:11:03 UTC 2013

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Support Linuxen where libc ioctl has cmd as int unstead of unsigned long.


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2013-07-18 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Jul 18 22:58:35 UTC 2013

Modified Files:
src/lib/librumphijack: hijack.c hijackdlsym.c

Log Message:
sys/cdefs.h should come from rumpuser_port.h

Noticed by Justin Cormack while building against musl libc.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/lib/librumphijack/hijack.c
cvs rdiff -u -r1.3 -r1.4 src/lib/librumphijack/hijackdlsym.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.100 src/lib/librumphijack/hijack.c:1.101
--- src/lib/librumphijack/hijack.c:1.100	Tue Oct 16 12:56:10 2012
+++ src/lib/librumphijack/hijack.c	Thu Jul 18 22:58:35 2013
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.100 2012/10/16 12:56:10 pooka Exp $	*/
+/*  $NetBSD: hijack.c,v 1.101 2013/07/18 22:58:35 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -30,8 +30,9 @@
 
 #include rumpuser_port.h
 
-#include sys/cdefs.h
-__RCSID($NetBSD: hijack.c,v 1.100 2012/10/16 12:56:10 pooka Exp $);
+#if !defined(lint)
+__RCSID($NetBSD: hijack.c,v 1.101 2013/07/18 22:58:35 pooka Exp $);
+#endif
 
 #include sys/param.h
 #include sys/types.h

Index: src/lib/librumphijack/hijackdlsym.c
diff -u src/lib/librumphijack/hijackdlsym.c:1.3 src/lib/librumphijack/hijackdlsym.c:1.4
--- src/lib/librumphijack/hijackdlsym.c:1.3	Sat Aug 25 18:00:06 2012
+++ src/lib/librumphijack/hijackdlsym.c	Thu Jul 18 22:58:35 2013
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijackdlsym.c,v 1.3 2012/08/25 18:00:06 pooka Exp $	*/
+/*  $NetBSD: hijackdlsym.c,v 1.4 2013/07/18 22:58:35 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -27,8 +27,9 @@
 
 #include rumpuser_port.h
 
-#include sys/cdefs.h
-__RCSID($NetBSD: hijackdlsym.c,v 1.3 2012/08/25 18:00:06 pooka Exp $);
+#if !defined(lint)
+__RCSID($NetBSD: hijackdlsym.c,v 1.4 2013/07/18 22:58:35 pooka Exp $);
+#endif
 
 #include dlfcn.h
 



CVS commit: src/lib/librumphijack

2013-07-18 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Jul 18 22:58:35 UTC 2013

Modified Files:
src/lib/librumphijack: hijack.c hijackdlsym.c

Log Message:
sys/cdefs.h should come from rumpuser_port.h

Noticed by Justin Cormack while building against musl libc.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/lib/librumphijack/hijack.c
cvs rdiff -u -r1.3 -r1.4 src/lib/librumphijack/hijackdlsym.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2012-10-16 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Oct 16 12:56:10 UTC 2012

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
* avoid problems if the platform calls readlink() from dlsym()
* alias __read_chk() to read() on Linux (technically, though,
  it should call host __read_chk() instead of read())


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.99 src/lib/librumphijack/hijack.c:1.100
--- src/lib/librumphijack/hijack.c:1.99	Wed Sep 12 10:35:10 2012
+++ src/lib/librumphijack/hijack.c	Tue Oct 16 12:56:10 2012
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.99 2012/09/12 10:35:10 martin Exp $	*/
+/*  $NetBSD: hijack.c,v 1.100 2012/10/16 12:56:10 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -31,7 +31,7 @@
 #include rumpuser_port.h
 
 #include sys/cdefs.h
-__RCSID($NetBSD: hijack.c,v 1.99 2012/09/12 10:35:10 martin Exp $);
+__RCSID($NetBSD: hijack.c,v 1.100 2012/10/16 12:56:10 pooka Exp $);
 
 #include sys/param.h
 #include sys/types.h
@@ -1769,7 +1769,8 @@ REALSELECT(int nfds, fd_set *readfds, fd
 	int i, j;
 	int rv, incr;
 
-	DPRINTF((select\n));
+	DPRINTF((select %d %p %p %p %p\n, nfds,
+	readfds, writefds, exceptfds, timeout));
 
 	/*
 	 * Well, first we must scan the fds to figure out how many
@@ -1949,7 +1950,7 @@ REALPOLLTS(struct pollfd *fds, nfds_t nf
 	nfds_t i;
 	int rv;
 
-	DPRINTF((poll\n));
+	DPRINTF((poll %p %d %p %p\n, fds, (int)nfds, ts, sigmask));
 	checkpoll(fds, nfds, hostcall, rumpcall);
 
 	if (hostcall  rumpcall) {
@@ -2287,6 +2288,11 @@ FDCALL(ssize_t, REALREAD, DUALCALL_READ,
 	(int, void *, size_t),		\
 	(fd, buf, buflen))
 
+#ifdef __linux__
+ssize_t __read_chk(int, void *, size_t)
+__attribute__((alias(read)));
+#endif
+
 FDCALL(ssize_t, readv, DUALCALL_READV, 	\
 	(int fd, const struct iovec *iov, int iovcnt),			\
 	(int, const struct iovec *, int),\
@@ -2438,10 +2444,31 @@ PATHCALL(int, symlink, DUALCALL_SYMLINK,
 	(const char *, const char *),	\
 	(target, path))
 
-PATHCALL(ssize_t, readlink, DUALCALL_READLINK,\
-	(const char *path, char *buf, size_t bufsiz),			\
-	(const char *, char *, size_t),	\
-	(path, buf, bufsiz))
+/*
+ * readlink() can be called from malloc which can be called
+ * from dlsym() during init
+ */
+ssize_t
+readlink(const char *path, char *buf, size_t bufsiz)
+{
+	int (*op_readlink)(const char *, char *, size_t);
+	enum pathtype pt;
+
+	if ((pt = path_isrump(path)) != PATH_HOST) {
+		op_readlink = GETSYSCALL(rump, READLINK);
+		if (pt == PATH_RUMP)
+			path = path_host2rump(path);
+	} else {
+		op_readlink = GETSYSCALL(host, READLINK);
+	}
+
+	if (__predict_false(op_readlink == NULL)) {
+		errno = ENOENT;
+		return -1;
+	}
+
+	return op_readlink(path, buf, bufsiz);
+}
 
 PATHCALL(int, mkdir, DUALCALL_MKDIR,	\
 	(const char *path, mode_t mode),\



CVS commit: src/lib/librumphijack

2012-10-16 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Oct 16 12:56:10 UTC 2012

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
* avoid problems if the platform calls readlink() from dlsym()
* alias __read_chk() to read() on Linux (technically, though,
  it should call host __read_chk() instead of read())


To generate a diff of this commit:
cvs rdiff -u -r1.99 -r1.100 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2012-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 12 10:35:10 UTC 2012

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
When emulating poll/select better tell the events of the host kernel
apart from those received from the rump kernel. Also handle timeout.
Patch from pooka.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.98 src/lib/librumphijack/hijack.c:1.99
--- src/lib/librumphijack/hijack.c:1.98	Mon Sep  3 12:07:42 2012
+++ src/lib/librumphijack/hijack.c	Wed Sep 12 10:35:10 2012
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.98 2012/09/03 12:07:42 pooka Exp $	*/
+/*  $NetBSD: hijack.c,v 1.99 2012/09/12 10:35:10 martin Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -31,7 +31,7 @@
 #include rumpuser_port.h
 
 #include sys/cdefs.h
-__RCSID($NetBSD: hijack.c,v 1.98 2012/09/03 12:07:42 pooka Exp $);
+__RCSID($NetBSD: hijack.c,v 1.99 2012/09/12 10:35:10 martin Exp $);
 
 #include sys/param.h
 #include sys/types.h
@@ -1502,7 +1502,7 @@ msg_convert(struct msghdr *msg, int (*fu
 			int *fdp = (void *)CMSG_DATA(cmsg);
 			const size_t size =
 			cmsg-cmsg_len - __CMSG_ALIGN(sizeof(*cmsg));
-			const int nfds = size / sizeof(int);
+			const int nfds = (int)(size / sizeof(int));
 			const int * const efdp = fdp + nfds;
 
 			while (fdp  efdp) {
@@ -1957,7 +1957,7 @@ REALPOLLTS(struct pollfd *fds, nfds_t nf
 		int rpipe[2] = {-1,-1}, hpipe[2] = {-1,-1};
 		struct pollarg parg;
 		void *trv_val;
-		int sverrno = 0, lrv, trv;
+		int sverrno = 0, rv_rump, rv_host, errno_rump, errno_host;
 
 		/*
 		 * ok, this is where it gets tricky.  We must support
@@ -2047,30 +2047,63 @@ REALPOLLTS(struct pollfd *fds, nfds_t nf
 		pthread_create(pt, NULL, hostpoll, parg);
 
 		op_pollts = GETSYSCALL(rump, POLLTS);
-		lrv = op_pollts(pfd_rump, nfds+1, ts, NULL);
-		sverrno = errno;
+		rv_rump = op_pollts(pfd_rump, nfds+1, ts, NULL);
+		errno_rump = errno;
 		write(hpipe[1], rv, sizeof(rv));
 		pthread_join(pt, trv_val);
-		trv = (int)(intptr_t)trv_val;
+		rv_host = (int)(intptr_t)trv_val;
+		errno_host = parg.errnum;
 
-		/* check who won and merge results */
-		if (lrv != 0  pfd_host[nfds].revents  POLLIN) {
-			rv = trv;
-
-			for (i = 0; i  nfds; i++) {
-if (pfd_rump[i].fd != -1)
-	fds[i].revents = pfd_rump[i].revents;
+		/* strip cross-thread notification from real results */
+		if (pfd_host[nfds].revents  POLLIN) {
+			assert((pfd_rump[nfds].revents  POLLIN) == 0);
+			assert(rv_host  0);
+			rv_host--;
+		}
+		if (pfd_rump[nfds].revents  POLLIN) {
+			assert((pfd_host[nfds].revents  POLLIN) == 0);
+			assert(rv_rump  0);
+			rv_rump--;
+		}
+
+		/* then merge the results into what's reported to the caller */
+		if (rv_rump  0 || rv_host  0) {
+			/* SUCCESS */
+
+			rv = 0;
+			if (rv_rump  0) {
+for (i = 0; i  nfds; i++) {
+	if (pfd_rump[i].fd != -1)
+		fds[i].revents
+		= pfd_rump[i].revents;
+}
+rv += rv_rump;
 			}
-			sverrno = parg.errnum;
-		} else if (trv != 0  pfd_rump[nfds].revents  POLLIN) {
-			rv = trv;
-
-			for (i = 0; i  nfds; i++) {
-if (pfd_host[i].fd != -1)
-	fds[i].revents = pfd_host[i].revents;
+			if (rv_host  0) {
+for (i = 0; i  nfds; i++) {
+	if (pfd_host[i].fd != -1)
+		fds[i].revents
+		= pfd_host[i].revents;
+}
+rv += rv_host;
+			}
+			assert(rv  0);
+			sverrno = 0;
+		} else if (rv_rump == -1 || rv_host == -1) {
+			/* ERROR */
+
+			/* just pick one kernel at random */
+			rv = -1;
+			if (rv_host == -1) {
+sverrno = errno_host;
+			} else if (rv_rump == -1) {
+sverrno = errno_rump;
 			}
 		} else {
+			/* TIMEOUT */
+
 			rv = 0;
+			assert(rv_rump == 0  rv_host == 0);
 		}
 
  out:



CVS commit: src/lib/librumphijack

2012-09-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Sep 12 10:35:10 UTC 2012

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
When emulating poll/select better tell the events of the host kernel
apart from those received from the rump kernel. Also handle timeout.
Patch from pooka.


To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2012-09-03 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Sep  3 12:07:42 UTC 2012

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
one more patch for supporting linux-based networking clients


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.97 src/lib/librumphijack/hijack.c:1.98
--- src/lib/librumphijack/hijack.c:1.97	Mon Sep  3 11:33:35 2012
+++ src/lib/librumphijack/hijack.c	Mon Sep  3 12:07:42 2012
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.97 2012/09/03 11:33:35 pooka Exp $	*/
+/*  $NetBSD: hijack.c,v 1.98 2012/09/03 12:07:42 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -31,7 +31,7 @@
 #include rumpuser_port.h
 
 #include sys/cdefs.h
-__RCSID($NetBSD: hijack.c,v 1.97 2012/09/03 11:33:35 pooka Exp $);
+__RCSID($NetBSD: hijack.c,v 1.98 2012/09/03 12:07:42 pooka Exp $);
 
 #include sys/param.h
 #include sys/types.h
@@ -102,7 +102,6 @@ enum dualcall {
 	DUALCALL_OPEN,
 	DUALCALL_CHDIR, DUALCALL_FCHDIR,
 	DUALCALL_LSEEK,
-	DUALCALL_GETDENTS,
 	DUALCALL_UNLINK, DUALCALL_SYMLINK, DUALCALL_READLINK,
 	DUALCALL_LINK, DUALCALL_RENAME,
 	DUALCALL_MKDIR, DUALCALL_RMDIR,
@@ -113,6 +112,7 @@ enum dualcall {
 
 #ifndef __linux__
 	DUALCALL___GETCWD,
+	DUALCALL_GETDENTS,
 #endif
 
 #ifndef __linux__
@@ -211,6 +211,7 @@ int REALSTAT(const char *, struct stat *
 int REALLSTAT(const char *, struct stat *);
 int REALFSTAT(int, struct stat *);
 int REALMKNOD(const char *, mode_t, dev_t);
+int REALGETDENTS(int, char *, size_t);
 
 int __getcwd(char *, size_t);
 
@@ -219,7 +220,6 @@ int __getcwd(char *, size_t);
 #define REALREAD read
 #define REALPREAD pread
 #define REALPWRITE pwrite
-#define REALGETDENTS readdir
 #define REALSELECT select
 #define REALPOLLTS ppoll
 #define REALUTIMES utimes
@@ -242,7 +242,6 @@ int REALKEVENT(int, const struct kevent 
 ssize_t REALREAD(int, void *, size_t);
 ssize_t REALPREAD(int, void *, size_t, off_t);
 ssize_t REALPWRITE(int, const void *, size_t, off_t);
-int REALGETDENTS(int, char *, size_t);
 int REALUTIMES(const char *, const struct timeval [2]);
 int REALLUTIMES(const char *, const struct timeval [2]);
 int REALFUTIMES(int, const struct timeval [2]);
@@ -308,7 +307,6 @@ struct sysnames {
 	{ DUALCALL_CHDIR,	chdir,	RSYS_NAME(CHDIR)	},
 	{ DUALCALL_FCHDIR,	fchdir,	RSYS_NAME(FCHDIR)	},
 	{ DUALCALL_LSEEK,	lseek,	RSYS_NAME(LSEEK)	},
-	{ DUALCALL_GETDENTS,	S(REALGETDENTS),RSYS_NAME(GETDENTS)	},
 	{ DUALCALL_UNLINK,	unlink,	RSYS_NAME(UNLINK)	},
 	{ DUALCALL_SYMLINK,	symlink,	RSYS_NAME(SYMLINK)	},
 	{ DUALCALL_READLINK,	readlink,	RSYS_NAME(READLINK)	},
@@ -323,6 +321,7 @@ struct sysnames {
 
 #ifndef __linux__
 	{ DUALCALL___GETCWD,	__getcwd,	RSYS_NAME(__GETCWD)	},
+	{ DUALCALL_GETDENTS,	S(REALGETDENTS),RSYS_NAME(GETDENTS)	},
 #endif
 
 #ifndef __linux__
@@ -2307,10 +2306,12 @@ FDCALL(off_t, lseek, DUALCALL_LSEEK,
 __strong_alias(LSEEK_ALIAS,lseek);
 #endif
 
+#ifndef __linux__
 FDCALL(int, REALGETDENTS, DUALCALL_GETDENTS,\
 	(int fd, char *buf, size_t nbytes),\
 	(int, char *, size_t),		\
 	(fd, buf, nbytes))
+#endif
 
 FDCALL(int, fchown, DUALCALL_FCHOWN,	\
 	(int fd, uid_t owner, gid_t group),\



CVS commit: src/lib/librumphijack

2012-09-03 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Sep  3 12:07:42 UTC 2012

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
one more patch for supporting linux-based networking clients


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2012-06-29 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Fri Jun 29 13:20:25 UTC 2012

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
implement descriptor passing.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.93 src/lib/librumphijack/hijack.c:1.94
--- src/lib/librumphijack/hijack.c:1.93	Mon Jun 25 22:32:47 2012
+++ src/lib/librumphijack/hijack.c	Fri Jun 29 13:20:25 2012
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.93 2012/06/25 22:32:47 abs Exp $	*/
+/*  $NetBSD: hijack.c,v 1.94 2012/06/29 13:20:25 yamt Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -29,7 +29,7 @@
 #undef _FORTIFY_SOURCE
 
 #include sys/cdefs.h
-__RCSID($NetBSD: hijack.c,v 1.93 2012/06/25 22:32:47 abs Exp $);
+__RCSID($NetBSD: hijack.c,v 1.94 2012/06/29 13:20:25 yamt Exp $);
 
 #include sys/param.h
 #include sys/types.h
@@ -1335,6 +1335,122 @@ write(int fd, const void *buf, size_t bl
 }
 
 /*
+ * file descriptor passing
+ *
+ * we intercept sendmsg and recvmsg to convert file descriptors in
+ * control messages.  an attempt to send a descriptor from a different kernel
+ * is rejected.  (ENOTSUP)
+ */
+
+static int
+msg_convert(struct msghdr *msg, int (*func)(int))
+{
+	struct cmsghdr *cmsg;
+
+	for (cmsg = CMSG_FIRSTHDR(msg); cmsg != NULL;
+	cmsg = CMSG_NXTHDR(msg, cmsg)) {
+		if (cmsg-cmsg_level == SOL_SOCKET 
+		cmsg-cmsg_type == SCM_RIGHTS) {
+			int *fdp = (void *)CMSG_DATA(cmsg);
+			const size_t size =
+			cmsg-cmsg_len - __CMSG_ALIGN(sizeof(*cmsg));
+			const int nfds = size / sizeof(int);
+			const int * const efdp = fdp + nfds;
+
+			while (fdp  efdp) {
+const int newval = func(*fdp);
+
+if (newval  0) {
+	return ENOTSUP;
+}
+*fdp = newval;
+fdp++;
+			}
+		}
+	}
+	return 0;
+}
+
+ssize_t
+recvmsg(int fd, struct msghdr *msg, int flags)
+{
+	ssize_t (*op_recvmsg)(int, struct msghdr *, int);
+	ssize_t ret;
+	const bool isrump = fd_isrump(fd);
+
+	if (isrump) {
+		fd = fd_host2rump(fd);
+		op_recvmsg = GETSYSCALL(rump, RECVMSG);
+	} else {
+		op_recvmsg = GETSYSCALL(host, RECVMSG);
+	}
+	ret = op_recvmsg(fd, msg, flags);
+	if (ret == -1) {
+		return ret;
+	}
+	/*
+	 * convert descriptors in the message.
+	 */
+	if (isrump) {
+		msg_convert(msg, fd_rump2host);
+	} else {
+		msg_convert(msg, fd_host2host);
+	}
+	return ret;
+}
+
+static int
+fd_check_rump(int fd)
+{
+
+	return fd_isrump(fd) ? 0 : -1;
+}
+
+static int
+fd_check_host(int fd)
+{
+
+	return !fd_isrump(fd) ? 0 : -1;
+}
+
+ssize_t
+sendmsg(int fd, const struct msghdr *msg, int flags)
+{
+	ssize_t (*op_sendmsg)(int, const struct msghdr *, int);
+	const bool isrump = fd_isrump(fd);
+	int error;
+
+	/*
+	 * reject descriptors from a different kernel.
+	 */
+	error = msg_convert(__UNCONST(msg),
+	isrump ? fd_check_rump: fd_check_host);
+	if (error != 0) {
+		errno = error;
+		return -1;
+	}
+	/*
+	 * convert descriptors in the message to raw values.
+	 */
+	if (isrump) {
+		fd = fd_host2rump(fd);
+		/*
+		 * XXX we directly modify the given message assuming:
+		 * - cmsg is writable (typically on caller's stack)
+		 * - caller don't care cmsg's contents after calling sendmsg.
+		 *   (thus no need to restore values)
+		 *
+		 * it's safer to copy and modify instead.
+		 */
+		msg_convert(__UNCONST(msg), fd_host2rump);
+		op_sendmsg = GETSYSCALL(rump, SENDMSG);
+	} else {
+		op_sendmsg = GETSYSCALL(host, SENDMSG);
+	}
+	return op_sendmsg(fd, msg, flags);
+}
+
+/*
  * dup2 is special.  we allow dup2 of a rump kernel fd to 0-2 since
  * many programs do that.  dup2 of a rump kernel fd to another value
  * not = fdoff is an error.
@@ -1949,16 +2065,6 @@ FDCALL(ssize_t, sendto, DUALCALL_SENDTO,
 	const struct sockaddr *, socklen_t),			\
 	(fd, buf, len, flags, to, tolen))
 
-FDCALL(ssize_t, recvmsg, DUALCALL_RECVMSG, \
-	(int fd, struct msghdr *msg, int flags),			\
-	(int, struct msghdr *, int),	\
-	(fd, msg, flags))
-
-FDCALL(ssize_t, sendmsg, DUALCALL_SENDMSG, \
-	(int fd, const struct msghdr *msg, int flags),			\
-	(int, const struct msghdr *, int),\
-	(fd, msg, flags))
-
 FDCALL(int, getsockopt, DUALCALL_GETSOCKOPT, \
 	(int fd, int level, int optn, void *optval, socklen_t *optlen),	\
 	(int, int, int, void *, socklen_t *),\



CVS commit: src/lib/librumphijack

2012-06-29 Thread YAMAMOTO Takashi
Module Name:src
Committed By:   yamt
Date:   Fri Jun 29 13:20:25 UTC 2012

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
implement descriptor passing.


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2012-04-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 18 10:37:37 UTC 2012

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
poll(), pollts() and select() all return int values, but in the hijack
emulation of them these get passed as exit values from a pthread as
a void* (c.f. pthread_join(), pthread_exit()).
Do not use the address of an int variable for these, but provide the address
of a void* and assign the value afterwards.
Fixes hijacking of pollts/select on 64bit big endian hosts.
Spotted by and fix from pooka.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.91 src/lib/librumphijack/hijack.c:1.92
--- src/lib/librumphijack/hijack.c:1.91	Wed Feb  1 05:34:41 2012
+++ src/lib/librumphijack/hijack.c	Wed Apr 18 10:37:37 2012
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.91 2012/02/01 05:34:41 dholland Exp $	*/
+/*  $NetBSD: hijack.c,v 1.92 2012/04/18 10:37:37 martin Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -29,7 +29,7 @@
 #undef _FORTIFY_SOURCE
 
 #include sys/cdefs.h
-__RCSID($NetBSD: hijack.c,v 1.91 2012/02/01 05:34:41 dholland Exp $);
+__RCSID($NetBSD: hijack.c,v 1.92 2012/04/18 10:37:37 martin Exp $);
 
 #include sys/param.h
 #include sys/types.h
@@ -1654,7 +1654,7 @@ hostpoll(void *arg)
 		parg-errnum = errno;
 	rump_sys_write(parg-pipefd, rv, sizeof(rv));
 
-	return (void *)(intptr_t)rv;
+	return (void *)rv;
 }
 
 int
@@ -1676,8 +1676,8 @@ REALPOLLTS(struct pollfd *fds, nfds_t nf
 		struct pollfd *pfd_host = NULL, *pfd_rump = NULL;
 		int rpipe[2] = {-1,-1}, hpipe[2] = {-1,-1};
 		struct pollarg parg;
-		uintptr_t lrv;
-		int sverrno = 0, trv;
+		void *trv_val;
+		int sverrno = 0, lrv, trv;
 
 		/*
 		 * ok, this is where it gets tricky.  We must support
@@ -1770,7 +1770,8 @@ REALPOLLTS(struct pollfd *fds, nfds_t nf
 		lrv = op_pollts(pfd_rump, nfds+1, ts, NULL);
 		sverrno = errno;
 		write(hpipe[1], rv, sizeof(rv));
-		pthread_join(pt, (void *)trv);
+		pthread_join(pt, trv_val);
+		trv = (int)(intptr_t)trv_val;
 
 		/* check who won and merge results */
 		if (lrv != 0  pfd_host[nfds].revents  POLLIN) {



CVS commit: src/lib/librumphijack

2012-04-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 18 10:37:37 UTC 2012

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
poll(), pollts() and select() all return int values, but in the hijack
emulation of them these get passed as exit values from a pthread as
a void* (c.f. pthread_join(), pthread_exit()).
Do not use the address of an int variable for these, but provide the address
of a void* and assign the value afterwards.
Fixes hijacking of pollts/select on 64bit big endian hosts.
Spotted by and fix from pooka.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2011-04-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 21 08:21:13 UTC 2011

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Backout previous, it breaks lots of tests (tests/lib/librumphijack for
example).


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.88 src/lib/librumphijack/hijack.c:1.89
--- src/lib/librumphijack/hijack.c:1.88	Wed Apr 13 12:40:54 2011
+++ src/lib/librumphijack/hijack.c	Thu Apr 21 08:21:13 2011
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.88 2011/04/13 12:40:54 he Exp $	*/
+/*  $NetBSD: hijack.c,v 1.89 2011/04/21 08:21:13 martin Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: hijack.c,v 1.88 2011/04/13 12:40:54 he Exp $);
+__RCSID($NetBSD: hijack.c,v 1.89 2011/04/21 08:21:13 martin Exp $);
 
 #define __ssp_weak_name(fun) _hijack_ ## fun
 
@@ -1970,11 +1970,9 @@
 	(int, int),			\
 	(fd, how))
 
-ssize_t _sys_readlink(const char * __restrict, char * __restrict, size_t);
-
 #if _FORTIFY_SOURCE  0
 #define STUB(fun) __ssp_weak_name(fun)
-ssize_t STUB(readlink)(const char * __restrict, char * __restrict, size_t);
+ssize_t _sys_readlink(const char * __restrict, char * __restrict, size_t);
 ssize_t
 STUB(readlink)(const char * __restrict path, char * __restrict buf,
 size_t bufsiz)
@@ -1982,7 +1980,6 @@
 	return _sys_readlink(path, buf, bufsiz);
 }
 
-char *STUB(getcwd)(char *, size_t);
 char *_sys_getcwd(char *, size_t);
 char *
 STUB(getcwd)(char *buf, size_t size)
@@ -2133,7 +2130,7 @@
 	(const char *, const char *),	\
 	(target, path))
 
-PATHCALL(ssize_t, _sys_readlink, DUALCALL_READLINK,			\
+PATHCALL(ssize_t, readlink, DUALCALL_READLINK,\
 	(const char *path, char *buf, size_t bufsiz),			\
 	(const char *, char *, size_t),	\
 	(path, buf, bufsiz))



CVS commit: src/lib/librumphijack

2011-04-21 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr 21 08:21:13 UTC 2011

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Backout previous, it breaks lots of tests (tests/lib/librumphijack for
example).


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2011-04-13 Thread Havard Eidnes
Module Name:src
Committed By:   he
Date:   Wed Apr 13 12:40:54 UTC 2011

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Move the forward declaration of _sys_readlink() outside of the #if,
so that the build succeeds even if _FORTIFY_SOURCE isn't  0.


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2011-04-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Apr 12 19:49:48 UTC 2011

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Fix SSP builds (Vladimir Kirillov)


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.86 src/lib/librumphijack/hijack.c:1.87
--- src/lib/librumphijack/hijack.c:1.86	Mon Mar 14 11:15:47 2011
+++ src/lib/librumphijack/hijack.c	Tue Apr 12 15:49:48 2011
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.86 2011/03/14 15:15:47 pooka Exp $	*/
+/*  $NetBSD: hijack.c,v 1.87 2011/04/12 19:49:48 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: hijack.c,v 1.86 2011/03/14 15:15:47 pooka Exp $);
+__RCSID($NetBSD: hijack.c,v 1.87 2011/04/12 19:49:48 christos Exp $);
 
 #define __ssp_weak_name(fun) _hijack_ ## fun
 
@@ -1972,6 +1972,7 @@
 
 #if _FORTIFY_SOURCE  0
 #define STUB(fun) __ssp_weak_name(fun)
+ssize_t STUB(readlink)(const char * __restrict, char * __restrict, size_t);
 ssize_t _sys_readlink(const char * __restrict, char * __restrict, size_t);
 ssize_t
 STUB(readlink)(const char * __restrict path, char * __restrict buf,
@@ -1980,6 +1981,7 @@
 	return _sys_readlink(path, buf, bufsiz);
 }
 
+char *STUB(getcwd)(char *, size_t);
 char *_sys_getcwd(char *, size_t);
 char *
 STUB(getcwd)(char *buf, size_t size)
@@ -2130,7 +2132,7 @@
 	(const char *, const char *),	\
 	(target, path))
 
-PATHCALL(ssize_t, readlink, DUALCALL_READLINK,\
+PATHCALL(ssize_t, _sys_readlink, DUALCALL_READLINK,			\
 	(const char *path, char *buf, size_t bufsiz),			\
 	(const char *, char *, size_t),	\
 	(path, buf, bufsiz))



CVS commit: src/lib/librumphijack

2011-04-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Apr 12 19:49:48 UTC 2011

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Fix SSP builds (Vladimir Kirillov)


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2011-03-14 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Mar 14 15:13:26 UTC 2011

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Make fdoffset configurable.  Also, enforce that host descriptors
are smaller than the offset.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.84 src/lib/librumphijack/hijack.c:1.85
--- src/lib/librumphijack/hijack.c:1.84	Thu Mar 10 23:02:56 2011
+++ src/lib/librumphijack/hijack.c	Mon Mar 14 15:13:26 2011
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.84 2011/03/10 23:02:56 pooka Exp $	*/
+/*  $NetBSD: hijack.c,v 1.85 2011/03/14 15:13:26 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: hijack.c,v 1.84 2011/03/10 23:02:56 pooka Exp $);
+__RCSID($NetBSD: hijack.c,v 1.85 2011/03/14 15:13:26 pooka Exp $);
 
 #define __ssp_weak_name(fun) _hijack_ ## fun
 
@@ -274,6 +274,9 @@
 static bool		fd_isrump(int);
 static enum pathtype	path_isrump(const char *);
 
+/* default FD_SETSIZE is 256 == default fdoff is 128 */
+static int hijack_fdoff = FD_SETSIZE/2;
+
 /*
  * Maintain a mapping table for the usual dup2 suspects.
  * Could use atomic ops to operate on dup2vec, but an application
@@ -647,6 +650,23 @@
 	errx(1, sysctl value should be y(es)/n(o), gave: %s, buf);
 }
 
+static void
+fdoffparser(char *buf)
+{
+	unsigned long fdoff;
+	char *ep;
+
+	if (*buf == '-') {
+		errx(1, fdoff must not be negative);
+	}
+	fdoff = strtoul(buf, ep, 10);
+	if (*ep != '\0')
+		errx(1, invalid fdoff specifier \%s\, buf);
+	if (fdoff = INT_MAX/2 || fdoff  3)
+		errx(1, fdoff out of range);
+	hijack_fdoff = fdoff;
+}
+
 static struct {
 	void (*parsefn)(char *);
 	const char *name;
@@ -657,6 +677,7 @@
 	{ blanketparser, blanket, true },
 	{ vfsparser, vfs, true },
 	{ sysctlparser, sysctl, false },
+	{ fdoffparser, fdoffset, true },
 	{ NULL, NULL, false },
 };
 
@@ -783,16 +804,13 @@
 	}
 }
 
-/* Need runtime selection.  low for now due to FD_SETSIZE */
-#define HIJACK_FDOFF 128
-
 static int
 fd_rump2host(int fd)
 {
 
 	if (fd == -1)
 		return fd;
-	return fd + HIJACK_FDOFF;
+	return fd + hijack_fdoff;
 }
 
 static int
@@ -814,7 +832,7 @@
 {
 
 	if (!isdup2d(fd))
-		return fd - HIJACK_FDOFF;
+		return fd - hijack_fdoff;
 	else
 		return mapdup2(fd);
 }
@@ -823,10 +841,10 @@
 fd_isrump(int fd)
 {
 
-	return isdup2d(fd) || fd = HIJACK_FDOFF;
+	return isdup2d(fd) || fd = hijack_fdoff;
 }
 
-#define assertfd(_fd_) assert(ISDUP2D(_fd_) || (_fd_) = HIJACK_FDOFF)
+#define assertfd(_fd_) assert(ISDUP2D(_fd_) || (_fd_) = hijack_fdoff)
 
 static enum pathtype
 path_isrump(const char *path)
@@ -885,8 +903,8 @@
 	if (fd_isrump(oldd)) {
 		op_fcntl = GETSYSCALL(rump, FCNTL);
 		oldd = fd_host2rump(oldd);
-		if (minfd = HIJACK_FDOFF)
-			minfd -= HIJACK_FDOFF;
+		if (minfd = hijack_fdoff)
+			minfd -= hijack_fdoff;
 		isrump = 1;
 	} else {
 		op_fcntl = GETSYSCALL(host, FCNTL);
@@ -903,15 +921,22 @@
 }
 
 /*
- * dup a host file descriptor so that it doesn't collide with the dup2mask
+ * Check that host fd value does not exceed fdoffset and if necessary
+ * dup the file descriptor so that it doesn't collide with the dup2mask.
  */
 static int
-fd_dupgood(int fd)
+fd_host2host(int fd)
 {
 	int (*op_fcntl)(int, int, ...) = GETSYSCALL(host, FCNTL);
 	int (*op_close)(int) = GETSYSCALL(host, CLOSE);
 	int ofd, i;
 
+	if (fd = hijack_fdoff) {
+		op_close(fd);
+		errno = ENFILE;
+		return -1;
+	}
+
 	for (i = 1; isdup2d(fd); i++) {
 		ofd = fd;
 		fd = op_fcntl(ofd, F_DUPFD, i);
@@ -949,7 +974,7 @@
 	if (isrump)
 		fd = fd_rump2host(fd);
 	else
-		fd = fd_dupgood(fd);
+		fd = fd_host2host(fd);
 
 	DPRINTF((open - %d (%s)\n, fd, whichfd(fd)));
 	return fd;
@@ -1099,7 +1124,7 @@
 	if (isrump)
 		fd = fd_rump2host(fd);
 	else
-		fd = fd_dupgood(fd);
+		fd = fd_host2host(fd);
 	DPRINTF((socket - %d\n, fd));
 
 	return fd;
@@ -1125,7 +1150,7 @@
 	if (fd != -1  isrump)
 		fd = fd_rump2host(fd);
 	else
-		fd = fd_dupgood(fd);
+		fd = fd_host2host(fd);
 
 	DPRINTF(( - %d\n, fd));
 
@@ -1177,7 +1202,7 @@
 		 * So, if fd  HIJACKOFF, we want to do a host closem.
 		 */
 
-		if (fd  HIJACK_FDOFF) {
+		if (fd  hijack_fdoff) {
 			int closemfd = fd;
 
 			if (rumpclient__closenotify(closemfd,
@@ -1203,8 +1228,8 @@
 			}
 		}
 		
-		if (fd = HIJACK_FDOFF)
-			fd -= HIJACK_FDOFF;
+		if (fd = hijack_fdoff)
+			fd -= hijack_fdoff;
 		else
 			fd = 0;
 		fd = MAX(maxdup2+1, fd);



CVS commit: src/lib/librumphijack

2011-03-14 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Mar 14 15:15:47 UTC 2011

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
fdoff is descriptive enough


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.85 src/lib/librumphijack/hijack.c:1.86
--- src/lib/librumphijack/hijack.c:1.85	Mon Mar 14 15:13:26 2011
+++ src/lib/librumphijack/hijack.c	Mon Mar 14 15:15:47 2011
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.85 2011/03/14 15:13:26 pooka Exp $	*/
+/*  $NetBSD: hijack.c,v 1.86 2011/03/14 15:15:47 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: hijack.c,v 1.85 2011/03/14 15:13:26 pooka Exp $);
+__RCSID($NetBSD: hijack.c,v 1.86 2011/03/14 15:15:47 pooka Exp $);
 
 #define __ssp_weak_name(fun) _hijack_ ## fun
 
@@ -677,7 +677,7 @@
 	{ blanketparser, blanket, true },
 	{ vfsparser, vfs, true },
 	{ sysctlparser, sysctl, false },
-	{ fdoffparser, fdoffset, true },
+	{ fdoffparser, fdoff, true },
 	{ NULL, NULL, false },
 };
 



CVS commit: src/lib/librumphijack

2011-03-14 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Mar 14 15:21:23 UTC 2011

Modified Files:
src/lib/librumphijack: rumphijack.3

Log Message:
document fdoff


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/librumphijack/rumphijack.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/rumphijack.3
diff -u src/lib/librumphijack/rumphijack.3:1.11 src/lib/librumphijack/rumphijack.3:1.12
--- src/lib/librumphijack/rumphijack.3:1.11	Thu Mar 10 08:53:04 2011
+++ src/lib/librumphijack/rumphijack.3	Mon Mar 14 15:21:22 2011
@@ -1,4 +1,4 @@
-.\ $NetBSD: rumphijack.3,v 1.11 2011/03/10 08:53:04 wiz Exp $
+.\ $NetBSD: rumphijack.3,v 1.12 2011/03/14 15:21:22 pooka Exp $
 .\
 .\ Copyright (c) 2011 Antti Kantee.  All rights reserved.
 .\
@@ -23,7 +23,7 @@
 .\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\ SUCH DAMAGE.
 .\
-.Dd March 9, 2011
+.Dd March 14, 2011
 .Dt RUMPHIJACK 3
 .Os
 .Sh NAME
@@ -173,6 +173,16 @@
 and
 .Dq no ,
 meaning to call the rump or the host kernel, respectively.
+.It Dq fdoff
+Adjust the library's fd offset to the specified value.
+All rump kernel descriptors have the offset added to them
+before they are returned to the application.
+This should be changed only if the application defines a low non-default
+.Dv FD_SETSIZE
+for
+.Fn select
+or if it opens a very large number of file descriptors.
+The default value is 128.
 .El
 .Pp
 If the environment variable is unset, the default value



CVS commit: src/lib/librumphijack

2011-03-14 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Mar 14 15:13:26 UTC 2011

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Make fdoffset configurable.  Also, enforce that host descriptors
are smaller than the offset.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2011-03-14 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Mar 14 15:15:47 UTC 2011

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
fdoff is descriptive enough


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/lib/librumphijack

2011-03-11 Thread Antti Kantee
On Fri Mar 11 2011 at 03:34:47 +0300, Valeriy E. Ushakov wrote:
 On Thu, Mar 10, 2011 at 23:02:56 +, Antti Kantee wrote:
 
  Use rumphijack_dlsym() to figure out where __sysctl() is during
  init.  Otherwise powerpc dlsym() DTWT and returns NULL.
  (now i have no idea why dlsym() it works from rcinit(), but i'll
  opt to not care)
 
 I don't remember if I brought this up here already, but I strongly
 suspect suspect that libexec/ld.elf_so/rtld.c
 
 revision 1.121
 date: 2008/09/27 03:52:05;  author: macallan;  state: Exp;  lines: +15 -3
 avoid usind __builtin_return_address(0) on PowerPC because it fails in
 Xorg's module loader.
 Should fix PR37812
 
 broke it (hi, Mac!).  IIRC, it tries to work around dlsym in tail call
 position (badness!) and fixes it only by chance, causing grief
 elsewhere.

If there only were a test, someone could try to fix things without
worrying about reintroducing the original problem again ...

-- 
älä karot toivorikkauttas, kyl rätei ja lumpui piisaa


Re: CVS commit: src/lib/librumphijack

2011-03-10 Thread Valeriy E. Ushakov
On Thu, Mar 10, 2011 at 23:02:56 +, Antti Kantee wrote:

 Use rumphijack_dlsym() to figure out where __sysctl() is during
 init.  Otherwise powerpc dlsym() DTWT and returns NULL.
 (now i have no idea why dlsym() it works from rcinit(), but i'll
 opt to not care)

I don't remember if I brought this up here already, but I strongly
suspect suspect that libexec/ld.elf_so/rtld.c

revision 1.121
date: 2008/09/27 03:52:05;  author: macallan;  state: Exp;  lines: +15 -3
avoid usind __builtin_return_address(0) on PowerPC because it fails in
Xorg's module loader.
Should fix PR37812

broke it (hi, Mac!).  IIRC, it tries to work around dlsym in tail call
position (badness!) and fixes it only by chance, causing grief
elsewhere.

-uwe


CVS commit: src/lib/librumphijack

2011-03-10 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Mar 10 08:53:04 UTC 2011

Modified Files:
src/lib/librumphijack: rumphijack.3

Log Message:
Add serial commas.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/librumphijack/rumphijack.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/rumphijack.3
diff -u src/lib/librumphijack/rumphijack.3:1.10 src/lib/librumphijack/rumphijack.3:1.11
--- src/lib/librumphijack/rumphijack.3:1.10	Wed Mar  9 23:40:44 2011
+++ src/lib/librumphijack/rumphijack.3	Thu Mar 10 08:53:04 2011
@@ -1,4 +1,4 @@
-.\ $NetBSD: rumphijack.3,v 1.10 2011/03/09 23:40:44 pooka Exp $
+.\ $NetBSD: rumphijack.3,v 1.11 2011/03/10 08:53:04 wiz Exp $
 .\
 .\ Copyright (c) 2011 Antti Kantee.  All rights reserved.
 .\
@@ -144,16 +144,16 @@
 there is no pathname to make the selection based on.
 Current possible values are
 .Dq nfssvc ,
-.Dq getvfsstat
+.Dq getvfsstat ,
 and
-.Dq fhcalls.
+.Dq fhcalls .
 They indicate hijacking
 .Fn nfssvc ,
-.Fn getvfsstat
+.Fn getvfsstat ,
 and all file handle calls, respectively.
 The file handle calls include
 .Fn fhopen ,
-.Fn fhstat
+.Fn fhstat ,
 and
 .Fn fhstatvfs1 .
 .Pp



CVS commit: src/lib/librumphijack

2011-03-10 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Mar 10 09:47:32 UTC 2011

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Revert 1.81 and do it in a saner way with an ifdef.  Later, when
the naming crisis is resolved, we can probably support rump kernel
quotas from nb5 also.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.82 src/lib/librumphijack/hijack.c:1.83
--- src/lib/librumphijack/hijack.c:1.82	Wed Mar  9 23:26:19 2011
+++ src/lib/librumphijack/hijack.c	Thu Mar 10 09:47:32 2011
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.82 2011/03/09 23:26:19 pooka Exp $	*/
+/*  $NetBSD: hijack.c,v 1.83 2011/03/10 09:47:32 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: hijack.c,v 1.82 2011/03/09 23:26:19 pooka Exp $);
+__RCSID($NetBSD: hijack.c,v 1.83 2011/03/10 09:47:32 pooka Exp $);
 
 #define __ssp_weak_name(fun) _hijack_ ## fun
 
@@ -97,7 +97,9 @@
 	DUALCALL___SYSCTL,
 	DUALCALL_GETVFSSTAT, DUALCALL_NFSSVC,
 	DUALCALL_GETFH, DUALCALL_FHOPEN, DUALCALL_FHSTAT, DUALCALL_FHSTATVFS1,
+#if __NetBSD_Prereq__(5,99,48)
 	DUALCALL_QUOTACTL,
+#endif
 	DUALCALL__NUM
 };
 
@@ -133,7 +135,6 @@
 #define REALMKNOD __mknod50
 #define REALFHSTAT __fhstat50
 #endif
-
 #define REALREAD _sys_read
 #define REALPREAD _sys_pread
 #define REALPWRITE _sys_pwrite
@@ -173,9 +174,7 @@
 	enum dualcall scm_callnum;
 	const char *scm_hostname;
 	const char *scm_rumpname;
-};
-
-struct sysnames sys_mandatory[] = {
+} syscnames[] = {
 	{ DUALCALL_SOCKET,	__socket30,	RSYS_NAME(SOCKET)	},
 	{ DUALCALL_ACCEPT,	accept,	RSYS_NAME(ACCEPT)	},
 	{ DUALCALL_BIND,	bind,		RSYS_NAME(BIND)		},
@@ -245,23 +244,15 @@
 	{ DUALCALL_GETVFSSTAT,	getvfsstat,	RSYS_NAME(GETVFSSTAT)	},
 	{ DUALCALL_NFSSVC,	nfssvc,	RSYS_NAME(NFSSVC)	},
 	{ DUALCALL_GETFH,	S(REALGETFH),	RSYS_NAME(GETFH)	},
-	{ DUALCALL_FHOPEN,	S(REALFHOPEN),	RSYS_NAME(FHOPEN)	},
-	{ DUALCALL_FHSTAT,	S(REALFHSTAT),	RSYS_NAME(FHSTAT)	},
+	{ DUALCALL_FHOPEN,	S(REALFHOPEN),RSYS_NAME(FHOPEN)		},
+	{ DUALCALL_FHSTAT,	S(REALFHSTAT),RSYS_NAME(FHSTAT)		},
 	{ DUALCALL_FHSTATVFS1,	S(REALFHSTATVFS1),RSYS_NAME(FHSTATVFS1)	},
-};
-
-struct sysnames sys_optional[] = {
+#if __NetBSD_Prereq__(5,99,48)
 	{ DUALCALL_QUOTACTL,	S(REALQUOTACTL),RSYS_NAME(QUOTACTL)	},
+#endif
 };
 #undef S
 
-static int
-nolibcstub(void)
-{
-
-	return ENOSYS;
-}
-
 struct bothsys {
 	void *bs_host;
 	void *bs_rump;
@@ -713,8 +704,6 @@
 rcinit(void)
 {
 	char buf[1024];
-	struct sysnames *sysvec;
-	size_t totalsys;
 	unsigned i, j;
 
 	host_fork = dlsym(RTLD_NEXT, fork);
@@ -727,38 +716,27 @@
 	 * is a bit of a strech, but it might work.
 	 */
 
-	totalsys = __arraycount(sys_mandatory) + __arraycount(sys_optional);
 	for (i = 0; i  DUALCALL__NUM; i++) {
 		/* build runtime O(1) access */
-
-		sysvec = sys_mandatory;
-		for (j = 0; j  __arraycount(sys_mandatory); j++) {
-			if (sys_mandatory[j].scm_callnum == i)
-goto found;
-		}
-		sysvec = sys_optional;
-		for (j = 0; j  __arraycount(sys_optional); j++, j++) {
-			if (sys_optional[j].scm_callnum == i)
-goto found;
+		for (j = 0; j  __arraycount(syscnames); j++) {
+			if (syscnames[j].scm_callnum == i)
+break;
 		}
-		errx(1, rumphijack error: syscall pos %d missing, i);
 
- found:
+		if (j == __arraycount(syscnames))
+			errx(1, rumphijack error: syscall pos %d missing, i);
+
 		syscalls[i].bs_host = dlsym(RTLD_NEXT,
-		sysvec[j].scm_hostname);
-		if (syscalls[i].bs_host == NULL) {
-			if (sysvec == sys_optional)
-syscalls[i].bs_host = nolibcstub;
-			else
-errx(1, hostcall %s not found!,
-sysvec[j].scm_hostname);
-		}
+		syscnames[j].scm_hostname);
+		if (syscalls[i].bs_host == NULL)
+			errx(1, hostcall %s not found!,
+			syscnames[j].scm_hostname);
 
 		syscalls[i].bs_rump = dlsym(RTLD_NEXT,
-		sysvec[j].scm_rumpname);
+		syscnames[j].scm_rumpname);
 		if (syscalls[i].bs_rump == NULL)
 			errx(1, rumpcall %s not found!,
-			sysvec[j].scm_rumpname);
+			syscnames[j].scm_rumpname);
 	}
 
 	if (rumpclient_init() == -1)
@@ -2194,10 +2172,12 @@
 	(const char *, int),		\
 	(path, flags))
 
+#if __NetBSD_Prereq__(5,99,48)
 PATHCALL(int, REALQUOTACTL, DUALCALL_QUOTACTL,\
 	(const char *path, struct plistref *p),\
 	(const char *, struct plistref *),\
 	(path, p))
+#endif
 
 PATHCALL(int, REALGETFH, DUALCALL_GETFH,\
 	(const char *path, void *fhp, size_t *fh_size),			\



CVS commit: src/lib/librumphijack

2011-03-10 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Mar 10 23:02:56 UTC 2011

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Use rumphijack_dlsym() to figure out where __sysctl() is during
init.  Otherwise powerpc dlsym() DTWT and returns NULL.
(now i have no idea why dlsym() it works from rcinit(), but i'll
opt to not care)

Hah, only took 15min to debug that crap this time around.  I'm
quickly approaching zero-time with it.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/librumphijack/hijack.c
diff -u src/lib/librumphijack/hijack.c:1.83 src/lib/librumphijack/hijack.c:1.84
--- src/lib/librumphijack/hijack.c:1.83	Thu Mar 10 09:47:32 2011
+++ src/lib/librumphijack/hijack.c	Thu Mar 10 23:02:56 2011
@@ -1,4 +1,4 @@
-/*  $NetBSD: hijack.c,v 1.83 2011/03/10 09:47:32 pooka Exp $	*/
+/*  $NetBSD: hijack.c,v 1.84 2011/03/10 23:02:56 pooka Exp $	*/
 
 /*-
  * Copyright (c) 2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: hijack.c,v 1.83 2011/03/10 09:47:32 pooka Exp $);
+__RCSID($NetBSD: hijack.c,v 1.84 2011/03/10 23:02:56 pooka Exp $);
 
 #define __ssp_weak_name(fun) _hijack_ ## fun
 
@@ -1870,7 +1870,7 @@
 		op___sysctl = GETSYSCALL(host, __SYSCTL);
 		/* we haven't inited yet */
 		if (__predict_false(op___sysctl == NULL)) {
-			op___sysctl = dlsym(RTLD_NEXT, __sysctl);
+			op___sysctl = rumphijack_dlsym(RTLD_NEXT, __sysctl);
 		}
 	}
 



CVS commit: src/lib/librumphijack

2011-03-10 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Mar 10 08:53:04 UTC 2011

Modified Files:
src/lib/librumphijack: rumphijack.3

Log Message:
Add serial commas.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/librumphijack/rumphijack.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2011-03-10 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Mar 10 09:47:32 UTC 2011

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Revert 1.81 and do it in a saner way with an ifdef.  Later, when
the naming crisis is resolved, we can probably support rump kernel
quotas from nb5 also.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/lib/librumphijack

2011-03-10 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Thu Mar 10 23:02:56 UTC 2011

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Use rumphijack_dlsym() to figure out where __sysctl() is during
init.  Otherwise powerpc dlsym() DTWT and returns NULL.
(now i have no idea why dlsym() it works from rcinit(), but i'll
opt to not care)

Hah, only took 15min to debug that crap this time around.  I'm
quickly approaching zero-time with it.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/lib/librumphijack/hijack.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/lib/librumphijack

2011-03-09 Thread Christoph Egger

On 03/09/11 16:03, Antti Kantee wrote:

Module Name:src
Committed By:   pooka
Date:   Wed Mar  9 15:03:18 UTC 2011

Modified Files:
src/lib/librumphijack: hijack.c

Log Message:
Add a bunch of process-wide hijack calls.  Among other things, it's
now possible to use unmodified userspace binaries (rpcbind, mountd,
nfsd) to start a rump nfs service and mount file systems from it.

pain-rustique:42:~  mount
rumpfs on / type rumpfs (local)
10.1.1.1:/export on /mnt type nfs


Cool. Is it possible to have anita booting NetBSD in qemu
with root on nfs?

Christoph


  1   2   3   >