kldunload.c (114589) | kldunload.c (132117) |
---|---|
1/*- 2 * Copyright (c) 1997 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1997 Doug Rabson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 11 unchanged lines hidden (view full) --- 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sbin/kldunload/kldunload.c 114589 2003-05-03 18:41:59Z obrien $"); | 28__FBSDID("$FreeBSD: head/sbin/kldunload/kldunload.c 132117 2004-07-13 19:36:59Z phk $"); |
29 30#include <err.h> 31#include <stdio.h> 32#include <stdlib.h> 33#include <unistd.h> 34#include <sys/param.h> 35#include <sys/linker.h> 36 --- 6 unchanged lines hidden (view full) --- 43} 44 45int 46main(int argc, char** argv) 47{ 48 int c; 49 int verbose = 0; 50 int fileid = 0; | 29 30#include <err.h> 31#include <stdio.h> 32#include <stdlib.h> 33#include <unistd.h> 34#include <sys/param.h> 35#include <sys/linker.h> 36 --- 6 unchanged lines hidden (view full) --- 43} 44 45int 46main(int argc, char** argv) 47{ 48 int c; 49 int verbose = 0; 50 int fileid = 0; |
51 int force = LINKER_UNLOAD_NORMAL; |
|
51 char* filename = NULL; 52 | 52 char* filename = NULL; 53 |
53 while ((c = getopt(argc, argv, "i:n:v")) != -1) | 54 while ((c = getopt(argc, argv, "fi:n:v")) != -1) |
54 switch (c) { | 55 switch (c) { |
56 case 'f': 57 force = LINKER_UNLOAD_FORCE; 58 break; |
|
55 case 'i': 56 fileid = atoi(optarg); 57 if (!fileid) 58 errx(1, "Invalid ID %s", optarg); 59 break; 60 case 'n': 61 filename = optarg; 62 break; --- 25 unchanged lines hidden (view full) --- 88 if (verbose) { 89 struct kld_file_stat stat; 90 stat.version = sizeof stat; 91 if (kldstat(fileid, &stat) < 0) 92 err(1, "can't stat file"); 93 printf("Unloading %s, id=%d\n", stat.name, fileid); 94 } 95 | 59 case 'i': 60 fileid = atoi(optarg); 61 if (!fileid) 62 errx(1, "Invalid ID %s", optarg); 63 break; 64 case 'n': 65 filename = optarg; 66 break; --- 25 unchanged lines hidden (view full) --- 92 if (verbose) { 93 struct kld_file_stat stat; 94 stat.version = sizeof stat; 95 if (kldstat(fileid, &stat) < 0) 96 err(1, "can't stat file"); 97 printf("Unloading %s, id=%d\n", stat.name, fileid); 98 } 99 |
96 if (kldunload(fileid) < 0) | 100 if (kldunloadf(fileid, force) < 0) |
97 err(1, "can't unload file"); 98 99 return 0; 100} | 101 err(1, "can't unload file"); 102 103 return 0; 104} |