Make this compile/work on NetBSD 5 once again.
This commit is contained in:
parent
635fb9c2cc
commit
9d51298cb8
|
@ -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 @@ __RCSID("$NetBSD: hijack.c,v 1.80 2011/03/09 18:45:30 bouyer Exp $");
|
|||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/quota.h>
|
||||
|
||||
#include "hijack.h"
|
||||
|
||||
|
@ -134,6 +133,7 @@ enum dualcall {
|
|||
#define REALMKNOD __mknod50
|
||||
#define REALFHSTAT __fhstat50
|
||||
#endif
|
||||
|
||||
#define REALREAD _sys_read
|
||||
#define REALPREAD _sys_pread
|
||||
#define REALPWRITE _sys_pwrite
|
||||
|
@ -173,7 +173,9 @@ struct sysnames {
|
|||
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 @@ struct sysnames {
|
|||
{ 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 @@ parsehijack(char *hijack)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hijackparse[i].parsefn == NULL)
|
||||
errx(1, "invalid hijack specifier name in %s", p);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -698,6 +713,8 @@ static void __attribute__((constructor))
|
|||
rcinit(void)
|
||||
{
|
||||
char buf[1024];
|
||||
struct sysnames *sysvec;
|
||||
size_t totalsys;
|
||||
unsigned i, j;
|
||||
|
||||
host_fork = dlsym(RTLD_NEXT, "fork");
|
||||
|
@ -710,27 +727,38 @@ rcinit(void)
|
|||
* 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;
|
||||
|
||||
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,
|
||||
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);
|
||||
}
|
||||
|
||||
if (j == __arraycount(syscnames))
|
||||
errx(1, "rumphijack error: syscall pos %d missing", i);
|
||||
|
||||
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);
|
||||
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue