Add two new flags:

-q just shut up, will you?!
	-u unlink output file after successful load
This commit is contained in:
Garrett Wollman 1994-09-22 22:35:53 +00:00
parent d599144d24
commit 9d1275ccf4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=3000
2 changed files with 29 additions and 9 deletions

View File

@ -23,9 +23,9 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\" .\"
.\" $Id: modload.8,v 1.3 1994/08/19 13:39:20 davidg Exp $ .\" $Id: modload.8,v 1.4 1994/09/18 04:12:12 davidg Exp $
.\" .\"
.Dd June 7, 1993 .Dd September 22, 1994
.Dt MODLOAD 8 .Dt MODLOAD 8
.Os .Os
.Sh NAME .Sh NAME
@ -33,7 +33,7 @@
.Nd load a kernel module .Nd load a kernel module
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm modload .Nm modload
.Op Fl dv .Op Fl dquv
.Op Fl A Ar kernel .Op Fl A Ar kernel
.Op Fl e Ar entry .Op Fl e Ar entry
.Op Fl p Ar postinstall .Op Fl p Ar postinstall
@ -53,6 +53,12 @@ are as follows:
Debug. Used to debug Debug. Used to debug
.Nm .Nm
itself. itself.
.It Fl q
Be very quiet.
.It Fl u
Delete the loaded module
.Pq Ar output_file
after loading.
.It Fl v .It Fl v
Print comments about the loading process. Print comments about the loading process.
.It Fl A Ar kernel .It Fl A Ar kernel
@ -111,6 +117,5 @@ to the corresponding command in
Terrence R. Lambert, terry@cs.weber.edu Terrence R. Lambert, terry@cs.weber.edu
.El .El
.Sh BUGS .Sh BUGS
Loadable streams modules and loadable execution interpreters The loadable device driver framework can
are not currently supported. The loadable device driver framework can
only reserve either a character or block device entry, not both. only reserve either a character or block device entry, not both.

View File

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: modload.c,v 1.2 1994/08/19 13:28:21 davidg Exp $ * $Id: modload.c,v 1.3 1994/09/18 04:12:13 davidg Exp $
*/ */
#include <stdio.h> #include <stdio.h>
@ -65,6 +65,8 @@
int debug = 0; int debug = 0;
int verbose = 0; int verbose = 0;
int quiet = 0;
int dounlink = 0;
int int
linkcmd(kernel, entry, outfile, address, object) linkcmd(kernel, entry, outfile, address, object)
@ -108,7 +110,7 @@ usage()
{ {
fprintf(stderr, "usage:\n"); fprintf(stderr, "usage:\n");
fprintf(stderr, "modload [-d] [-v] [-A <kernel>] [-e <entry]\n"); fprintf(stderr, "modload [-d] [-v] [-q] [-u] [-A <kernel>] [-e <entry]\n");
fprintf(stderr, fprintf(stderr,
"[-p <postinstall>] [-o <output file>] <input file>\n"); "[-p <postinstall>] [-o <output file>] <input file>\n");
exit(1); exit(1);
@ -159,7 +161,7 @@ main(argc, argv)
int sz, bytesleft; int sz, bytesleft;
char buf[MODIOBUF]; char buf[MODIOBUF];
while ((c = getopt(argc, argv, "dvA:e:p:o:")) != EOF) { while ((c = getopt(argc, argv, "dvquA:e:p:o:")) != EOF) {
switch (c) { switch (c) {
case 'd': case 'd':
debug = 1; debug = 1;
@ -167,6 +169,12 @@ main(argc, argv)
case 'v': case 'v':
verbose = 1; verbose = 1;
break; /* verbose */ break; /* verbose */
case 'u':
dounlink = 1;
break;
case 'q':
quiet = 1;
break;
case 'A': case 'A':
kname = optarg; kname = optarg;
break; /* kernel */ break; /* kernel */
@ -329,7 +337,7 @@ main(argc, argv)
* Success! * Success!
*/ */
fileopen &= ~PART_RESRV; /* loaded */ fileopen &= ~PART_RESRV; /* loaded */
printf("Module loaded as ID %d\n", resrv.slot); if(!quiet) printf("Module loaded as ID %d\n", resrv.slot);
if (post) { if (post) {
struct lmc_stat sbuf; struct lmc_stat sbuf;
@ -346,5 +354,12 @@ main(argc, argv)
execl(post, post, id, type, offset, 0); execl(post, post, id, type, offset, 0);
err(16, "can't exec '%s'", post); err(16, "can't exec '%s'", post);
} }
if(dounlink) {
if(unlink(out)) {
err(17, "unlink(%s)", out);
}
}
return 0; return 0;
} }