Module Name: src
Committed By: pooka
Date: Wed Mar 9 20:48:57 UTC 2011
Modified Files:
src/lib/librumphijack: hijack.c
Log Message:
Make this compile/work on NetBSD 5 once again.
To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 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.80 src/lib/librumphijack/hijack.c:1.81
--- src/lib/librumphijack/hijack.c:1.80 Wed Mar 9 18:45:30 2011
+++ src/lib/librumphijack/hijack.c Wed Mar 9 20:48:57 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: hijack.c,v 1.80 2011/03/09 18:45:30 bouyer Exp $ */
+/* $NetBSD: hijack.c,v 1.81 2011/03/09 20:48:57 pooka Exp $ */
/*-
* Copyright (c) 2011 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: hijack.c,v 1.80 2011/03/09 18:45:30 bouyer Exp $");
+__RCSID("$NetBSD: hijack.c,v 1.81 2011/03/09 20:48:57 pooka Exp $");
#define __ssp_weak_name(fun) _hijack_ ## fun
@@ -58,7 +58,6 @@
#include <string.h>
#include <time.h>
#include <unistd.h>
-#include <sys/quota.h>
#include "hijack.h"
@@ -134,6 +133,7 @@
#define REALMKNOD __mknod50
#define REALFHSTAT __fhstat50
#endif
+
#define REALREAD _sys_read
#define REALPREAD _sys_pread
#define REALPWRITE _sys_pwrite
@@ -173,7 +173,9 @@
enum dualcall scm_callnum;
const char *scm_hostname;
const char *scm_rumpname;
-} syscnames[] = {
+};
+
+struct sysnames sys_mandatory[] = {
{ DUALCALL_SOCKET, "__socket30", RSYS_NAME(SOCKET) },
{ DUALCALL_ACCEPT, "accept", RSYS_NAME(ACCEPT) },
{ DUALCALL_BIND, "bind", RSYS_NAME(BIND) },
@@ -243,13 +245,23 @@
{ 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[] = {
{ DUALCALL_QUOTACTL, S(REALQUOTACTL),RSYS_NAME(QUOTACTL) },
};
#undef S
+static int
+nolibcstub(void)
+{
+
+ return ENOSYS;
+}
+
struct bothsys {
void *bs_host;
void *bs_rump;
@@ -690,6 +702,9 @@
break;
}
}
+
+ if (hijackparse[i].parsefn == NULL)
+ errx(1, "invalid hijack specifier name in %s", p);
}
}
@@ -698,6 +713,8 @@
rcinit(void)
{
char buf[1024];
+ struct sysnames *sysvec;
+ size_t totalsys;
unsigned i, j;
host_fork = dlsym(RTLD_NEXT, "fork");
@@ -710,27 +727,38 @@
* 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 */
- for (j = 0; j < __arraycount(syscnames); j++) {
- if (syscnames[j].scm_callnum == i)
- break;
- }
- if (j == __arraycount(syscnames))
- errx(1, "rumphijack error: syscall pos %d missing", i);
+ 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;
+ }
+ errx(1, "rumphijack error: syscall pos %d missing", i);
+ found:
syscalls[i].bs_host = dlsym(RTLD_NEXT,
- syscnames[j].scm_hostname);
- if (syscalls[i].bs_host == NULL)
- errx(1, "hostcall %s not found!",
- syscnames[j].scm_hostname);
+ 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);
+ }
syscalls[i].bs_rump = dlsym(RTLD_NEXT,
- syscnames[j].scm_rumpname);
+ sysvec[j].scm_rumpname);
if (syscalls[i].bs_rump == NULL)
errx(1, "rumpcall %s not found!",
- syscnames[j].scm_rumpname);
+ sysvec[j].scm_rumpname);
}
if (rumpclient_init() == -1)