kldstat.c (129866) | kldstat.c (145861) |
---|---|
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/kldstat/kldstat.c 129866 2004-05-30 10:10:41Z dwmalone $"); | 28__FBSDID("$FreeBSD: head/sbin/kldstat/kldstat.c 145861 2005-05-04 12:46:43Z fjoe $"); |
29 30#include <err.h> 31#include <stdint.h> 32#include <stdio.h> 33#include <stdlib.h> 34#include <unistd.h> 35#include <sys/types.h> 36#include <sys/param.h> --- 34 unchanged lines hidden (view full) --- 71 modid = modfnext(modid)) 72 printmod(modid); 73 } 74} 75 76static void 77usage(void) 78{ | 29 30#include <err.h> 31#include <stdint.h> 32#include <stdio.h> 33#include <stdlib.h> 34#include <unistd.h> 35#include <sys/types.h> 36#include <sys/param.h> --- 34 unchanged lines hidden (view full) --- 71 modid = modfnext(modid)) 72 printmod(modid); 73 } 74} 75 76static void 77usage(void) 78{ |
79 fprintf(stderr, "usage: kldstat [-v] [-i id] [-n name]\n"); | 79 fprintf(stderr, "usage: kldstat [-v] [-i id] [-n name] [-m name]\n"); |
80 exit(1); 81} 82 83int 84main(int argc, char** argv) 85{ 86 int c; 87 int verbose = 0; 88 int fileid = 0; 89 char* filename = NULL; | 80 exit(1); 81} 82 83int 84main(int argc, char** argv) 85{ 86 int c; 87 int verbose = 0; 88 int fileid = 0; 89 char* filename = NULL; |
90 char* modname = NULL; |
|
90 char* p; 91 | 91 char* p; 92 |
92 while ((c = getopt(argc, argv, "i:n:v")) != -1) | 93 while ((c = getopt(argc, argv, "i:m:n:v")) != -1) |
93 switch (c) { 94 case 'i': 95 fileid = (int)strtoul(optarg, &p, 10); 96 if (*p != '\0') 97 usage(); 98 break; | 94 switch (c) { 95 case 'i': 96 fileid = (int)strtoul(optarg, &p, 10); 97 if (*p != '\0') 98 usage(); 99 break; |
100 case 'm': 101 modname = optarg; 102 break; |
|
99 case 'n': 100 filename = optarg; 101 break; 102 case 'v': 103 verbose = 1; 104 break; 105 default: 106 usage(); 107 } 108 argc -= optind; 109 argv += optind; 110 111 if (argc != 0) 112 usage(); 113 | 103 case 'n': 104 filename = optarg; 105 break; 106 case 'v': 107 verbose = 1; 108 break; 109 default: 110 usage(); 111 } 112 argc -= optind; 113 argv += optind; 114 115 if (argc != 0) 116 usage(); 117 |
118 if (modname != NULL) { 119 int modid; 120 struct module_stat stat; 121 122 if ((modid = modfind(modname)) < 0) 123 err(1, "can't find module %s", modname); 124 125 stat.version = sizeof(struct module_stat); 126 if (modstat(modid, &stat) < 0) 127 warn("can't stat module id %d", modid); 128 else { 129 printf("Id Refs Name\n"); 130 printf("%3d %4d %s\n", stat.id, stat.refs, stat.name); 131 } 132 133 return 0; 134 } 135 |
|
114 if (filename != NULL) { 115 if ((fileid = kldfind(filename)) < 0) 116 err(1, "can't find file %s", filename); 117 } 118 119 printf("Id Refs Address%*c Size Name\n", POINTER_WIDTH - 7, ' '); 120 if (fileid != 0) 121 printfile(fileid, verbose); 122 else 123 for (fileid = kldnext(0); fileid > 0; fileid = kldnext(fileid)) 124 printfile(fileid, verbose); 125 126 return 0; 127} | 136 if (filename != NULL) { 137 if ((fileid = kldfind(filename)) < 0) 138 err(1, "can't find file %s", filename); 139 } 140 141 printf("Id Refs Address%*c Size Name\n", POINTER_WIDTH - 7, ' '); 142 if (fileid != 0) 143 printfile(fileid, verbose); 144 else 145 for (fileid = kldnext(0); fileid > 0; fileid = kldnext(fileid)) 146 printfile(fileid, verbose); 147 148 return 0; 149} |