summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-03-27 19:57:56 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-03-27 19:57:56 +0000
commit766488bbfe73a2b3e296284ebd18ce4b234164ff (patch)
tree42a05fabb022454cc3f06ffea4a8acdd8cb147db /sbin
parent84c16eda79758ac66d94562ced67a344ca3b2e28 (diff)
fix -u/-p problems reported by mks@msc.edu; but be a bit more careful..
Diffstat (limited to 'sbin')
-rw-r--r--sbin/modload/modload.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/sbin/modload/modload.c b/sbin/modload/modload.c
index f035506e2a5..88a24506a91 100644
--- a/sbin/modload/modload.c
+++ b/sbin/modload/modload.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: modload.c,v 1.11 1997/01/18 15:12:44 mickey Exp $ */
+/* $OpenBSD: modload.c,v 1.12 1997/03/27 19:57:55 deraadt Exp $ */
/* $NetBSD: modload.c,v 1.13 1995/05/28 05:21:58 jtc Exp $ */
/*
@@ -129,8 +129,12 @@ int fileopen = 0;
#define PART_RESRV 0x04
int devfd, modfd;
struct lmc_resrv resrv;
-char modout[80];
+char modout[MAXPATHLEN];
+/*
+ * Must be safe for two calls. One in case of the -p option, and one from
+ * the atexit() call...
+ */
void
cleanup()
{
@@ -140,16 +144,23 @@ cleanup()
*/
if (ioctl(devfd, LMUNRESRV, 0) == -1)
warn("can't release slot 0x%08x memory", resrv.slot);
+ fileopen &= ~PART_RESRV;
}
- if (fileopen & DEV_OPEN)
+ if (fileopen & DEV_OPEN) {
close(devfd);
+ fileopen &= ~DEV_OPEN;
+ }
- if (fileopen & MOD_OPEN)
+ if (fileopen & MOD_OPEN) {
close(modfd);
+ fileopen &= ~MOD_OPEN;
+ }
- if(dounlink && unlink(modout) != 0)
+ if(dounlink && unlink(modout) != 0) {
err(17, "unlink(%s)", modout);
+ dounlink = 0;
+ }
}
int
@@ -496,6 +507,9 @@ main(argc, argv)
* The modload docs say that drivers can install bdevsw &
* cdevsw, but the interface only supports one at a time.
*/
+
+ cleanup();
+
execl(post, post, id, type, offset, 0);
err(16, "can't exec `%s'", post);
}