module.c (321232) | module.c (328889) |
---|---|
1/*- 2 * Copyright (c) 1998 Michael Smith <msmith@freebsd.org> 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) 1998 Michael Smith <msmith@freebsd.org> 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: stable/11/sys/boot/common/module.c 321232 2017-07-19 19:06:19Z ngie $"); | 28__FBSDID("$FreeBSD: stable/11/sys/boot/common/module.c 328889 2018-02-05 17:01:18Z kevans $"); |
29 30/* 31 * file/module function dispatcher, support, etc. 32 */ 33 34#include <stand.h> 35#include <string.h> 36#include <sys/param.h> --- 210 unchanged lines hidden (view full) --- 247 248static int 249command_lsmod(int argc, char *argv[]) 250{ 251 struct preloaded_file *fp; 252 struct kernel_module *mp; 253 struct file_metadata *md; 254 char lbuf[80]; | 29 30/* 31 * file/module function dispatcher, support, etc. 32 */ 33 34#include <stand.h> 35#include <string.h> 36#include <sys/param.h> --- 210 unchanged lines hidden (view full) --- 247 248static int 249command_lsmod(int argc, char *argv[]) 250{ 251 struct preloaded_file *fp; 252 struct kernel_module *mp; 253 struct file_metadata *md; 254 char lbuf[80]; |
255 int ch, verbose; | 255 int ch, verbose, ret = 0; |
256 257 verbose = 0; 258 optind = 1; 259 optreset = 1; 260 while ((ch = getopt(argc, argv, "v")) != -1) { 261 switch(ch) { 262 case 'v': 263 verbose = 1; 264 break; 265 case '?': 266 default: 267 /* getopt has already reported an error */ 268 return(CMD_OK); 269 } 270 } 271 272 pager_open(); 273 for (fp = preloaded_files; fp; fp = fp->f_next) { | 256 257 verbose = 0; 258 optind = 1; 259 optreset = 1; 260 while ((ch = getopt(argc, argv, "v")) != -1) { 261 switch(ch) { 262 case 'v': 263 verbose = 1; 264 break; 265 case '?': 266 default: 267 /* getopt has already reported an error */ 268 return(CMD_OK); 269 } 270 } 271 272 pager_open(); 273 for (fp = preloaded_files; fp; fp = fp->f_next) { |
274 sprintf(lbuf, " %p: ", (void *) fp->f_addr); | 274 snprintf(lbuf, sizeof(lbuf), " %p: ", (void *) fp->f_addr); |
275 pager_output(lbuf); 276 pager_output(fp->f_name); | 275 pager_output(lbuf); 276 pager_output(fp->f_name); |
277 sprintf(lbuf, " (%s, 0x%lx)\n", fp->f_type, (long)fp->f_size); 278 pager_output(lbuf); | 277 snprintf(lbuf, sizeof(lbuf), " (%s, 0x%lx)\n", fp->f_type, 278 (long)fp->f_size); 279 if (pager_output(lbuf)) 280 break; |
279 if (fp->f_args != NULL) { 280 pager_output(" args: "); 281 pager_output(fp->f_args); 282 if (pager_output("\n")) 283 break; 284 } 285 if (fp->f_modules) { 286 pager_output(" modules: "); 287 for (mp = fp->f_modules; mp; mp = mp->m_next) { | 281 if (fp->f_args != NULL) { 282 pager_output(" args: "); 283 pager_output(fp->f_args); 284 if (pager_output("\n")) 285 break; 286 } 287 if (fp->f_modules) { 288 pager_output(" modules: "); 289 for (mp = fp->f_modules; mp; mp = mp->m_next) { |
288 sprintf(lbuf, "%s.%d ", mp->m_name, mp->m_version); | 290 snprintf(lbuf, sizeof(lbuf), "%s.%d ", mp->m_name, 291 mp->m_version); |
289 pager_output(lbuf); 290 } 291 if (pager_output("\n")) 292 break; 293 } 294 if (verbose) { 295 /* XXX could add some formatting smarts here to display some better */ 296 for (md = fp->f_metadata; md != NULL; md = md->md_next) { | 292 pager_output(lbuf); 293 } 294 if (pager_output("\n")) 295 break; 296 } 297 if (verbose) { 298 /* XXX could add some formatting smarts here to display some better */ 299 for (md = fp->f_metadata; md != NULL; md = md->md_next) { |
297 sprintf(lbuf, " 0x%04x, 0x%lx\n", md->md_type, (long) md->md_size); | 300 snprintf(lbuf, sizeof(lbuf), " 0x%04x, 0x%lx\n", 301 md->md_type, (long) md->md_size); |
298 if (pager_output(lbuf)) 299 break; 300 } 301 } | 302 if (pager_output(lbuf)) 303 break; 304 } 305 } |
306 if (ret) 307 break; |
|
302 } 303 pager_close(); 304 return(CMD_OK); 305} 306 307/* 308 * File level interface, functions file_* 309 */ --- 767 unchanged lines hidden --- | 308 } 309 pager_close(); 310 return(CMD_OK); 311} 312 313/* 314 * File level interface, functions file_* 315 */ --- 767 unchanged lines hidden --- |