Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Aug 2001 14:14:08 +0200
From:      Edwin de Jong <mauddib@gmx.net>
To:        freebsd-arch@freebsd.org
Subject:   slight change to kldload(8)/kldunload(8)
Message-ID:  <20010824141407.A3733@gmx.net>

next in thread | raw e-mail | index | archive | help

--IJpNTDwzlM2Ie8A6
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi,

The attached diffs are slight changes to kldload and kldload to support
multiple arguments (so it is possible now to say kldload module1.ko
module2.ko).

Edwin de Jong

(private mail if I did anything wrong, first commit)

-- 
"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

--IJpNTDwzlM2Ie8A6
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="kldload.diff"

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);
>     }

--IJpNTDwzlM2Ie8A6
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="kldunload.diff"

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
< 	    fileid = atoi(optarg);
< 	    if (!fileid)
< 		errx(1, "Invalid ID %s", optarg);
< 	    break;
---
> 	    optfileid = 1;
63d58
< 	    filename = optarg;
74,80c69,70
<     if (!fileid && !filename && (argc == 1)) {
< 	filename = *argv;
< 	argc--;
<     }
<     
<     if (argc != 0 || fileid && filename)
< 	usage();
---
>     if (argc == 0)
>         usage();  
82,83c72,88
<     if (fileid == 0 && filename == 0)
< 	usage();
---
>     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]);
>         }
>            
>         if (verbose) {
>             struct kld_file_stat stat;
>             stat.version = sizeof stat;
>             if (kldstat(fileid, &stat) < 0)
>                 err(1, "can't stat file id: %n", fileid);
>             printf("Unloading %s, id=%d\n", stat.name, fileid);
>         }
85,87c90,91
<     if (filename) {
< 	if ((fileid = kldfind(filename)) < 0)
< 	    err(1, "can't find file %s", filename);
---
>         if (kldunload(fileid) < 0)
>             err(1, "can't unload file id: %n", fileid);
89,99d92
< 
<     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");

--IJpNTDwzlM2Ie8A6--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010824141407.A3733>