Date: Mon, 3 Mar 1997 17:53:14 -0600 (CST) From: mks@msc.edu To: FreeBSD-gnats-submit@freebsd.org Subject: bin/2864: Using modload with -p option Message-ID: <199703032353.RAA00607@salo.msci.magic.net> Resent-Message-ID: <199703040000.QAA07556@freefall.freebsd.org>
index | next in thread | raw e-mail
>Number: 2864
>Category: bin
>Synopsis: Using modload with -p option broken
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: freebsd-bugs
>State: open
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Mon Mar 3 16:00:01 PST 1997
>Last-Modified:
>Originator: Mike Spengler
>Organization:
Minnesota Supercomputer Center, Inc.
>Release: FreeBSD 2.1-STABLE i386
>Environment:
>Description:
There are two problems when using modload -p <post-install>:
1. If the -u option is also specified, the loaded output file is
never deleted;
2. The /dev/lkm device isn't closed before calling the post-install
program, thus modload still holds the exclusive lock on /dev/lkm.
If the post-install program then tries to use modstat (to figure
out name of loaded module) it will hang on its open(/dev/lkm) and
thus the modload itself will hang waiting for the install program
to complete.
>How-To-Repeat:
o create the following shell script (call it mod_loaded)
#!/bin/sh
#
PATH=/bin:/sbin:/usr/bin:/usr/sbin; export PATH
MODID=$1
MOD=`modstat -i ${MODID} | awk '
$2 == modid {
print $NF;
exit;
}' modid=${MODID}`
echo "module loaded was ${MOD}"
exit 0
o pick your favorite loadable module (mymod) and,
modload -u -e <whatever> -o /tmp/mymod -p mod_loaded mymod.o
o this should hang the modload and its invocation of mod_loaded and
will also not delete /tmp/mymod.
>Fix:
--- modload.c.orig Tue May 30 01:09:20 1995
+++ modload.c Mon Mar 3 17:03:40 1997
@@ -358,6 +358,12 @@
fileopen &= ~PART_RESRV; /* loaded */
if(!quiet) printf("Module loaded as ID %d\n", resrv.slot);
+ if(dounlink) {
+ if(unlink(out)) {
+ err(17, "unlink(%s)", out);
+ }
+ }
+
if (post) {
struct lmc_stat sbuf;
char id[16], type[16], offset[16];
@@ -370,14 +376,12 @@
sprintf(offset, "%d", sbuf.offset);
/* XXX the modload docs say that drivers can install bdevsw &
cdevsw, but the interface only supports one at a time. sigh. */
+
+ /* Free resources before calling post-install program */
+ cleanup();
+
execl(post, post, id, type, offset, 0);
err(16, "can't exec '%s'", post);
- }
-
- if(dounlink) {
- if(unlink(out)) {
- err(17, "unlink(%s)", out);
- }
}
return 0;
>Audit-Trail:
>Unformatted:
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199703032353.RAA00607>
