make sysctl(8) work as a rump client

This commit is contained in:
pooka 2010-11-05 15:55:23 +00:00
parent 91fab46405
commit 08fc937c06
3 changed files with 33 additions and 5 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysctlgetmibinfo.c,v 1.7 2009/02/12 04:13:08 lukem Exp $ */
/* $NetBSD: sysctlgetmibinfo.c,v 1.8 2010/11/05 15:55:23 pooka Exp $ */
/*-
* Copyright (c) 2003,2004 The NetBSD Foundation, Inc.
@ -31,13 +31,15 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: sysctlgetmibinfo.c,v 1.7 2009/02/12 04:13:08 lukem Exp $");
__RCSID("$NetBSD: sysctlgetmibinfo.c,v 1.8 2010/11/05 15:55:23 pooka Exp $");
#endif /* LIBC_SCCS and not lint */
#ifndef RUMP_ACTION
#include "namespace.h"
#ifdef _REENTRANT
#include "reentrant.h"
#endif /* _REENTRANT */
#endif /* RUMP_ACTION */
#include <sys/param.h>
#include <sys/sysctl.h>
@ -51,6 +53,11 @@ __weak_alias(__learn_tree,___learn_tree)
__weak_alias(sysctlgetmibinfo,_sysctlgetmibinfo)
#endif
#ifdef RUMP_ACTION
#include <rump/rump_syscalls.h>
#define sysctl(a,b,c,d,e,f) rump_sys___sysctl(a,b,c,d,e,f)
#endif
/*
* the place where we attach stuff we learn on the fly, not
* necessarily used.

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.18 2009/02/13 16:02:05 uebayasi Exp $
# $NetBSD: Makefile,v 1.19 2010/11/05 15:55:23 pooka Exp $
# @(#)Makefile 8.1 (Berkeley) 6/6/93
.include <bsd.own.mk>
@ -7,4 +7,13 @@
PROG= sysctl
MAN= sysctl.8
SRCS= sysctl.c
.ifdef RUMP_ACTION
.PATH: ${.CURDIR}/../../lib/libc/gen
CPPFLAGS+= -DRUMP_ACTION
LDADD+= -lrumpclient
SRCS+= sysctlgetmibinfo.c
.endif
.include <bsd.prog.mk>

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysctl.c,v 1.131 2010/04/11 01:52:10 mrg Exp $ */
/* $NetBSD: sysctl.c,v 1.132 2010/11/05 15:55:23 pooka Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993\
#if 0
static char sccsid[] = "@(#)sysctl.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: sysctl.c,v 1.131 2010/04/11 01:52:10 mrg Exp $");
__RCSID("$NetBSD: sysctl.c,v 1.132 2010/11/05 15:55:23 pooka Exp $");
#endif
#endif /* not lint */
@ -105,6 +105,13 @@ __RCSID("$NetBSD: sysctl.c,v 1.131 2010/04/11 01:52:10 mrg Exp $");
#include <time.h>
#include <unistd.h>
#ifdef RUMP_ACTION
#include <rump/rumpclient.h>
#include <rump/rump_syscalls.h>
#define sysctl(a,b,c,d,e,f) rump_sys___sysctl(a,b,c,d,e,f)
#endif
/*
* this needs to be able to do the printing and the setting
*/
@ -269,6 +276,11 @@ main(int argc, char *argv[])
int name[CTL_MAXNAME];
int ch;
#ifdef RUMP_ACTION
if (rumpclient_init() == -1)
err(1, "rumpclient init failed");
#endif
while ((ch = getopt(argc, argv, "Aabdef:Mnqrwx")) != -1) {
switch (ch) {
case 'A':