From 162ca8ac83e3643c68d68a47378f5d31eb7179e0 Mon Sep 17 00:00:00 2001 From: pooka Date: Tue, 26 May 2009 16:03:24 +0000 Subject: [PATCH] Add compile mode which executes rump system calls. This is useful when figuring out Where In The Kernel Is Carmen Sandiego's ioctl for an ifconfig command line, since we can simply single-step into the kernel. Activated by "make RUMP_ACTION=1". No changes to normal case. --- sbin/ifconfig/Makefile | 14 +++++++++++++- sbin/ifconfig/env.h | 10 ++++++++++ sbin/ifconfig/ifconfig.c | 7 +++++-- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/sbin/ifconfig/Makefile b/sbin/ifconfig/Makefile index 00ae5d0f8b6e..ff2e36247d71 100644 --- a/sbin/ifconfig/Makefile +++ b/sbin/ifconfig/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.41 2009/04/11 07:58:12 lukem Exp $ +# $NetBSD: Makefile,v 1.42 2009/05/26 16:03:24 pooka Exp $ # @(#)Makefile 8.1 (Berkeley) 6/5/93 # when making a change to this file, please check if the change is @@ -22,4 +22,16 @@ SRCS+= af_inet6.c COPTS.ifconfig.c+= -fno-loop-optimize .endif +# +# Compile-time debug flag. If compiled with "make RUMP_ACTION=1", +# make rump system calls. This allows to single-step ioctl commands +# to figure out where ioctl's go in the kernel. +# +.ifdef RUMP_ACTION +CPPFLAGS+= -DRUMP_SYS_NETWORKING -DRUMP_SYS_IOCTL -DRUMP_ACTION +LDADD+= -lrumpnet_virtif -lrumpnet_netinet -lrumpnet_net -lrumpnet +LDADD+= -lrump -lrumpuser -lpthread +DBG= -g +.endif + .include diff --git a/sbin/ifconfig/env.h b/sbin/ifconfig/env.h index ff200b273a7b..b3a685a4a99f 100644 --- a/sbin/ifconfig/env.h +++ b/sbin/ifconfig/env.h @@ -11,4 +11,14 @@ int getifflags(prop_dictionary_t, prop_dictionary_t, unsigned short *); const char *getifinfo(prop_dictionary_t, prop_dictionary_t, unsigned short *); prop_dictionary_t prop_dictionary_augment(prop_dictionary_t, prop_dictionary_t); +/* + * XXX: this really doesn't belong in here, but env.h is conveniently + * included from all source modules *after* system headers, so it + * allows us to be lazy. See Makefile for more details. + */ +#ifdef RUMP_ACTION +#include +#include +#endif /* RUMP_ACTION */ + #endif /* _IFCONFIG_ENV_H */ diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 52c375850a3c..c36e5b58f9a8 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $NetBSD: ifconfig.c,v 1.218 2009/04/21 22:46:39 dyoung Exp $ */ +/* $NetBSD: ifconfig.c,v 1.219 2009/05/26 16:03:24 pooka Exp $ */ /*- * Copyright (c) 1997, 1998, 2000 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1983, 1993\ The Regents of the University of California. All rights reserved."); -__RCSID("$NetBSD: ifconfig.c,v 1.218 2009/04/21 22:46:39 dyoung Exp $"); +__RCSID("$NetBSD: ifconfig.c,v 1.219 2009/05/26 16:03:24 pooka Exp $"); #endif /* not lint */ #include @@ -540,6 +540,9 @@ main(int argc, char **argv) prop_dictionary_t env, oenv; const char *ifname; +#ifdef RUMP_ACTION + rump_init(); +#endif memset(match, 0, sizeof(match)); init_afs();