Add rump_wmd, a utility to resolve rump kernel component dependencies.
This commit is contained in:
parent
5344ef6679
commit
b5108f448c
@ -1,4 +1,4 @@
|
||||
# $NetBSD: mi,v 1.1058 2014/01/14 18:52:19 christos Exp $
|
||||
# $NetBSD: mi,v 1.1059 2014/01/16 01:54:47 pooka Exp $
|
||||
#
|
||||
# Note: Don't delete entries from here - mark them as "obsolete" instead,
|
||||
# unless otherwise stated below.
|
||||
@ -672,6 +672,7 @@
|
||||
./usr/bin/rump.sockstat base-util-bin rump
|
||||
./usr/bin/rump_allserver base-util-bin rump
|
||||
./usr/bin/rump_server base-util-bin rump
|
||||
./usr/bin/rump_wmd base-util-bin rump
|
||||
./usr/bin/rup base-netutil-bin
|
||||
./usr/bin/ruptime base-netutil-bin
|
||||
./usr/bin/rusers base-netutil-bin
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: mi,v 1.1456 2013/12/28 03:27:01 christos Exp $
|
||||
# $NetBSD: mi,v 1.1457 2014/01/16 01:54:47 pooka Exp $
|
||||
#
|
||||
# Note: don't delete entries from here - mark them as "obsolete" instead.
|
||||
#
|
||||
@ -484,6 +484,7 @@
|
||||
./usr/share/man/cat1/rump.halt.0 man-netutil-catman .cat,rump
|
||||
./usr/share/man/cat1/rump_allserver.0 man-netutil-catman .cat,rump
|
||||
./usr/share/man/cat1/rump_server.0 man-netutil-catman .cat,rump
|
||||
./usr/share/man/cat1/rump_wmd.0 man-netutil-catman .cat,rump
|
||||
./usr/share/man/cat1/rup.0 man-netutil-catman .cat
|
||||
./usr/share/man/cat1/ruptime.0 man-netutil-catman .cat
|
||||
./usr/share/man/cat1/rusers.0 man-netutil-catman .cat
|
||||
@ -3550,6 +3551,7 @@
|
||||
./usr/share/man/html1/rump.halt.html man-netutil-htmlman html,rump
|
||||
./usr/share/man/html1/rump_allserver.html man-netutil-htmlman html,rump
|
||||
./usr/share/man/html1/rump_server.html man-netutil-htmlman html,rump
|
||||
./usr/share/man/html1/rump_wmd.html man-netutil-htmlman html,rump
|
||||
./usr/share/man/html1/rup.html man-netutil-htmlman html
|
||||
./usr/share/man/html1/ruptime.html man-netutil-htmlman html
|
||||
./usr/share/man/html1/rusers.html man-netutil-htmlman html
|
||||
@ -6266,6 +6268,7 @@
|
||||
./usr/share/man/man1/rump.halt.1 man-netutil-man .man,rump
|
||||
./usr/share/man/man1/rump_allserver.1 man-netutil-man .man,rump
|
||||
./usr/share/man/man1/rump_server.1 man-netutil-man .man,rump
|
||||
./usr/share/man/man1/rump_wmd.1 man-netutil-man .man,rump
|
||||
./usr/share/man/man1/rup.1 man-netutil-man .man
|
||||
./usr/share/man/man1/ruptime.1 man-netutil-man .man
|
||||
./usr/share/man/man1/rusers.1 man-netutil-man .man
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.215 2013/12/28 02:32:01 rjs Exp $
|
||||
# $NetBSD: Makefile,v 1.216 2014/01/16 01:54:47 pooka Exp $
|
||||
# from: @(#)Makefile 8.3 (Berkeley) 1/7/94
|
||||
|
||||
.include <bsd.own.mk>
|
||||
@ -44,7 +44,8 @@ SUBDIR+= apropos whatis
|
||||
.endif
|
||||
|
||||
.if (${MKRUMP} != "no")
|
||||
SUBDIR+= rump_allserver rump_dhcpclient rump_halt rump_server shmif_dumpbus
|
||||
SUBDIR+= rump_allserver rump_dhcpclient rump_halt rump_server shmif_dumpbus \
|
||||
rump_wmd
|
||||
.endif
|
||||
|
||||
.if (${MKBSDGREP} != "no")
|
||||
|
7
usr.bin/rump_wmd/Makefile
Normal file
7
usr.bin/rump_wmd/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
# $NetBSD: Makefile,v 1.1 2014/01/16 01:54:47 pooka Exp $
|
||||
#
|
||||
|
||||
MAN= rump_wmd.1
|
||||
SCRIPTS=rump_wmd.sh
|
||||
|
||||
.include <bsd.prog.mk>
|
94
usr.bin/rump_wmd/rump_wmd.1
Normal file
94
usr.bin/rump_wmd/rump_wmd.1
Normal file
@ -0,0 +1,94 @@
|
||||
.\" $NetBSD: rump_wmd.1,v 1.1 2014/01/16 01:54:47 pooka Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2014 Antti Kantee. All rights reserved.
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
.\" are met:
|
||||
.\" 1. Redistributions of source code must retain the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer.
|
||||
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||||
.\" notice, this list of conditions and the following disclaimer in the
|
||||
.\" documentation and/or other materials provided with the distribution.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
|
||||
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd January 16, 2014
|
||||
.Dt RUMP_WMD 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm rump_wmd
|
||||
.Nd Resolve rump kernel component dependencies
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl L Ar libdir
|
||||
.Op Fl v
|
||||
.Fl l Ar component
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
utility can be used to resolve the link dependencies of rump kernel
|
||||
components.
|
||||
This functionality is useful when desiring to run a rump kernel with
|
||||
a given set of drivers, but not being sure what the dependencies of
|
||||
those drivers are.
|
||||
The output of
|
||||
.Nm
|
||||
is accepted as command line input by
|
||||
.Xr rump_server 1 .
|
||||
.Pp
|
||||
The command line options are:
|
||||
.Bl -tag -width indent
|
||||
.It Fl L Ar libdir
|
||||
By default, rump kernel components in
|
||||
.Pa /usr/lib
|
||||
are examined.
|
||||
If this option is supplied, components in
|
||||
.Ar libdir
|
||||
are examined instead.
|
||||
.It Fl v
|
||||
Increase debug output from the utility.
|
||||
This option may be given multiple times.
|
||||
.It Fl l Ar component
|
||||
Resolve dependencies for the given component.
|
||||
This option may be given multiple time.
|
||||
.El
|
||||
.Sh EXAMPLES
|
||||
Resolve dependencies for FFS:
|
||||
.Bd -literal -offset indent
|
||||
$ rump_wmd -lrumpfs_ffs
|
||||
DEBUG0: Searching component combinations. This may take a while ...
|
||||
DEBUG0: Found a set
|
||||
-lrumpdev -lrumpdev_disk -lrumpvfs -lrumpfs_ffs
|
||||
.Ed
|
||||
.Pp
|
||||
Resolve dependencies for NFS, use IPv6 networking and the virtif
|
||||
network interface:
|
||||
.Bd -literal -offset indent
|
||||
$ rump_wmd -lrumpfs_nfs -lrumpnet_netinet6 -lrumpnet_virtif
|
||||
DEBUG0: Searching component combinations. This may take a while ...
|
||||
DEBUG0: Found a set
|
||||
-lrumpnet -lrumpnet_net -lrumpvfs -lrumpfs_nfs -lrumpnet_netinet6 -lrumpnet_virtif
|
||||
.Ed
|
||||
.Sh CAVEATS
|
||||
Since
|
||||
.Nm
|
||||
uses trial-and-error brute force resolution, it runs somewhat slow.
|
||||
If several seconds are spent for dependency resolution, the benefit of
|
||||
a rump kernel booting in 10ms is somewhat lost.
|
||||
Caching the output is highly recommended.
|
||||
.Sh FUNFACTS
|
||||
.Nm
|
||||
is short for "rump, where's my dependency".
|
||||
.Sh SEE ALSO
|
||||
.Xr rump_server 1
|
158
usr.bin/rump_wmd/rump_wmd.sh
Executable file
158
usr.bin/rump_wmd/rump_wmd.sh
Executable file
@ -0,0 +1,158 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) 2014 Antti Kantee <pooka@iki.fi>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
#
|
||||
|
||||
: ${CC:=cc}
|
||||
DEBUGLEVEL=0
|
||||
LIBDIR=/usr/lib
|
||||
|
||||
die ()
|
||||
{
|
||||
|
||||
echo $* >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
usage ()
|
||||
{
|
||||
|
||||
die "Usage: $0 [-v] [-L libdir] -lrump_component [...]"
|
||||
}
|
||||
|
||||
unset FIRSTLIB
|
||||
while getopts 'l:L:v' opt; do
|
||||
case "${opt}" in
|
||||
l)
|
||||
: ${FIRSTLIB:=${OPTIND}}
|
||||
;;
|
||||
L)
|
||||
[ -z "${FIRSTLIB}" ] || usage
|
||||
LIBDIR=${OPTARG}
|
||||
;;
|
||||
v)
|
||||
[ -z "${FIRSTLIB}" ] || usage
|
||||
DEBUGLEVEL=$((DEBUGLEVEL + 1))
|
||||
;;
|
||||
-h|*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((${FIRSTLIB} - 2))
|
||||
[ $# -eq 0 ] && usage
|
||||
|
||||
debug ()
|
||||
{
|
||||
|
||||
[ ${DEBUGLEVEL} -ge ${1} ] && \
|
||||
{ lvl=$1; shift; echo DEBUG${lvl}: $* >&2; }
|
||||
}
|
||||
|
||||
# filters from list
|
||||
filter ()
|
||||
{
|
||||
|
||||
filtee=$1
|
||||
vname=$2
|
||||
tmplist=''
|
||||
found=false
|
||||
for x in $(eval echo \${${vname}}); do
|
||||
if [ "${filtee}" = "${x}" ]; then
|
||||
found=true
|
||||
else
|
||||
tmplist="${tmplist} ${x}"
|
||||
fi
|
||||
done
|
||||
${found} || die \"${1}\" not found in \$${2}
|
||||
|
||||
eval ${vname}="\${tmplist}"
|
||||
}
|
||||
|
||||
SEEDPROG='int rump_init(void); int main() { rump_init(); }'
|
||||
CCPARAMS='-Wl,--no-as-needed -o /dev/null -x c -'
|
||||
|
||||
# sanity-check
|
||||
for lib in $* ; do
|
||||
[ "${lib#-l}" = "${lib}" -o -z "${lib#-l}" ] \
|
||||
&& die Param \"${lib}\" is not of format -llib
|
||||
done
|
||||
|
||||
# starting set and available components
|
||||
WANTEDCOMP="$*"
|
||||
RUMPBASE='-lrump -lrumpuser'
|
||||
CURCOMP="${WANTEDCOMP}"
|
||||
NEEDEDCOMP=''
|
||||
ALLCOMP=$(ls ${LIBDIR} 2>/dev/null \
|
||||
| sed -n '/^librump.*.so$/{s/lib/-l/;s/\.so//p;}')
|
||||
[ -z "${ALLCOMP}" ] && die No rump kernel components in \"${LIBDIR}\"
|
||||
|
||||
# filter out ones we'll definitely not use
|
||||
for f in ${CURCOMP} -lrumphijack -lrumpclient; do
|
||||
filter ${f} ALLCOMP
|
||||
done
|
||||
|
||||
# put the factions first so that they'll be tried first.
|
||||
# this is an optimization to minimize link attempts.
|
||||
FACTIONS='-lrumpvfs -lrumpnet -lrumpdev'
|
||||
for f in ${FACTIONS}; do
|
||||
filter ${f} ALLCOMP
|
||||
done
|
||||
ALLCOMP="${FACTIONS} ${ALLCOMP}"
|
||||
|
||||
debug 0 Searching component combinations. This may take a while ...
|
||||
while :; do
|
||||
debug 1 Current components: ${CURCOMP}
|
||||
|
||||
IFS=' '
|
||||
out=$(echo ${SEEDPROG} \
|
||||
| ${CC} -L${LIBDIR} ${CCPARAMS} ${CURCOMP} ${RUMPBASE} 2>&1)
|
||||
[ -z "${out}" ] && break
|
||||
undef=$(echo ${out} \
|
||||
| sed -n '/undefined reference to/{s/.*`//;s/.$//p;q;}')
|
||||
[ -z "${undef}" ] && break
|
||||
|
||||
debug 1 Trying to find ${undef}
|
||||
for attempt in ${ALLCOMP}; do
|
||||
debug 2 Component attempt: ${attempt}
|
||||
unset IFS
|
||||
nowundef=$(echo ${SEEDPROG} \
|
||||
| ${CC} -L${LIBDIR} ${CCPARAMS} \
|
||||
${attempt} ${CURCOMP} ${RUMPBASE} 2>&1 \
|
||||
| sed -n '/undefined reference to/{s/.*`//;s/.$//p;}')
|
||||
for one in ${nowundef}; do
|
||||
[ "${one}" = "${undef}" ] && continue 2
|
||||
done
|
||||
CURCOMP="${attempt} ${CURCOMP}"
|
||||
filter ${attempt} ALLCOMP
|
||||
debug 1 Found ${undef} from ${attempt}
|
||||
continue 2
|
||||
done
|
||||
die Internal error: unreachable statement
|
||||
done
|
||||
|
||||
[ ! -z "${out}" ] && { echo 'ERROR:' >&2 ; echo ${out} >&2 ; exit 1 ; }
|
||||
debug 0 Found a set
|
||||
echo ${CURCOMP}
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user