Date: Fri, 24 Aug 2001 18:08:41 +0200 From: Edwin de Jong <mauddib@gmx.net> To: arch@freebsd.org Subject: Slight change to kldload(8)/kldunload(8) Message-ID: <20010824180841.A4256@gmx.net>
index | next in thread | raw e-mail
[-- Attachment #1 --]
Hi,
I made a small change to kldload(8) and kldunload(8) so it supports
multiple arguments (eg. kldload module1 module2; kldunload -i 1 2 3).
Diffs are in the attachments,
Regards,
Edwin de Jong
(ps. this is my first commit, any comments about this is highly
appreciated)
--
"I wish there was a knob on the TV to turn up the intelligence.
There's a knob called `brightness', but it doesn't work."
-- Gallagher
[-- Attachment #2 --]
Index: kldload/kldload.8
===================================================================
RCS file: /home/ncvs/src/sbin/kldload/kldload.8,v
retrieving revision 1.15
diff -r1.15 kldload.8
37a38
> \&...
41c42
< loads the file
---
> loads the files
Index: kldload/kldload.c
===================================================================
RCS file: /home/ncvs/src/sbin/kldload/kldload.c,v
retrieving revision 1.7
diff -r1.7 kldload.c
42c42
< fprintf(stderr, "usage: kldload [-v] filename\n");
---
> fprintf(stderr, "usage: kldload [-v] filename...\n");
64,72c64,71
< if (argc != 1)
< usage();
<
< fileid = kldload(argv[0]);
< if (fileid < 0)
< err(1, "can't load %s", argv[0]);
< else
< if (verbose)
< printf("Loaded %s, id=%d\n", argv[0], fileid);
---
> for(argc-- ; argc >= 0 ; argc--) {
> fileid = kldload(argv[argc]);
> if (fileid < 0)
> err(1, "can't load %s", argv[argc]);
> else
> if (verbose)
> printf("Loaded %s, id=%d\n", argv[argc], fileid);
> }
[-- Attachment #3 --]
? kldunload/a.out
Index: kldunload/kldunload.8
===================================================================
RCS file: /home/ncvs/src/sbin/kldunload/kldunload.8,v
retrieving revision 1.11
diff -r1.11 kldunload.8
37a38
> \&...
40d40
< .Op Fl n
41a42
> \&...
45c46
< utility unloads a file which was previously loaded with
---
> utility unloads files which were previously loaded with
52,57c53,54
< .It Fl i Ar id
< Unload the file with this ID.
< .It Fl n Ar name
< Unload the file with this name.
< .It Ar name
< Unload the file with this name.
---
> .It Fl i
> Use ID's instead of names.
Index: kldunload/kldunload.c
===================================================================
RCS file: /home/ncvs/src/sbin/kldunload/kldunload.c,v
retrieving revision 1.10
diff -r1.10 kldunload.c
42,43c42,43
< fprintf(stderr, "usage: kldunload [-v] -i id\n");
< fprintf(stderr, " kldunload [-v] [-n] name\n");
---
> fprintf(stderr, "usage: kldunload [-v] -i id...\n");
> fprintf(stderr, " kldunload [-v] name...\n");
51,53c51,52
< int verbose = 0;
< int fileid = 0;
< char* filename = 0;
---
> unsigned short int verbose = 0, optfileid = 0;
> int fileid;
55c54
< while ((c = getopt(argc, argv, "i:n:v")) != -1)
---
> while ((c = getopt(argc, argv, "inv")) != -1)
58,61c57,58
< fileid = atoi(optarg);
< if (!fileid)
< errx(1, "Invalid ID %s", optarg);
< break;
---
> optfileid = 1;
> break;
63d59
< filename = optarg;
74,83c70,71
< if (!fileid && !filename && (argc == 1)) {
< filename = *argv;
< argc--;
< }
<
< if (argc != 0 || fileid && filename)
< usage();
<
< if (fileid == 0 && filename == 0)
< usage();
---
> if (argc == 0)
> usage();
85,87c73,93
< if (filename) {
< if ((fileid = kldfind(filename)) < 0)
< err(1, "can't find file %s", filename);
---
> for(argc--; argc >= 0; argc--) {
> if (optfileid == 0) {
> if((fileid = kldfind(argv[argc])) < 0)
> err(1, "can't find file %s", argv[argc]);
> }
> else if (!(fileid = atoi(argv[argc]))) {
> err(1, "invalid file id: %s", argv[argc]);
> }
> else {
>
> if (verbose) {
> struct kld_file_stat stat;
> stat.version = sizeof stat;
> if (kldstat(fileid, &stat) < 0)
> err(1, "can't stat file id: %d", fileid);
> printf("Unloading %s, id=%d\n", stat.name, fileid);
> }
>
> if (kldunload(fileid) < 0)
> err(1, "can't unload file id: %d", fileid);
> }
89,99d94
<
< if (verbose) {
< struct kld_file_stat stat;
< stat.version = sizeof stat;
< if (kldstat(fileid, &stat) < 0)
< err(1, "can't stat file");
< printf("Unloading %s, id=%d\n", stat.name, fileid);
< }
<
< if (kldunload(fileid) < 0)
< err(1, "can't unload file");
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010824180841.A4256>
