wok diff busybox/stuff/busybox-1.12.0-modinfo.u @ rev 1299

Up busybox (1.12.0) with built in module-init-tools
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Aug 21 20:11:27 2008 +0000 (2008-08-21)
parents
children 85fbd04c1fd6
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/busybox/stuff/busybox-1.12.0-modinfo.u	Thu Aug 21 20:11:27 2008 +0000
     1.3 @@ -0,0 +1,153 @@
     1.4 +--- busybox-1.12.0/include/applets.h
     1.5 ++++ busybox-1.12.0/include/applets.h
     1.6 +@@ -251,6 +251,7 @@ USE_MKFS_MINIX(APPLET_ODDNAME(mkfs.minix
     1.7 + USE_MKNOD(APPLET(mknod, _BB_DIR_BIN, _BB_SUID_NEVER))
     1.8 + USE_MKSWAP(APPLET(mkswap, _BB_DIR_SBIN, _BB_SUID_NEVER))
     1.9 + USE_MKTEMP(APPLET(mktemp, _BB_DIR_BIN, _BB_SUID_NEVER))
    1.10 ++USE_MODINFO(APPLET(modinfo, _BB_DIR_SBIN, _BB_SUID_NEVER))
    1.11 + USE_MODPROBE(APPLET(modprobe, _BB_DIR_SBIN, _BB_SUID_NEVER))
    1.12 + USE_MODPROBE_SMALL(APPLET(modprobe, _BB_DIR_SBIN, _BB_SUID_NEVER))
    1.13 + USE_MORE(APPLET(more, _BB_DIR_BIN, _BB_SUID_NEVER))
    1.14 +
    1.15 +--- busybox-1.12.0/include/usage.h
    1.16 ++++ busybox-1.12.0/include/usage.h
    1.17 +@@ -2629,6 +2629,20 @@
    1.18 +        "   which are the default for alias 'tulip2' overridden by the options 'irq=2 io=0x210'\n\n" \
    1.19 +        "   from the command line\n"
    1.20 + 
    1.21 ++#define modinfo_trivial_usage \
    1.22 ++       "[-adlp0] [-F keyword] MODULE"
    1.23 ++#define modinfo_full_usage "\n\n" \
    1.24 ++       "Options:" \
    1.25 ++     "\n	-a		Shortcut for '-F author'" \
    1.26 ++     "\n	-d		Shortcut for '-F description'" \
    1.27 ++     "\n	-l		Shortcut for '-F license'" \
    1.28 ++     "\n	-p		Shortcut for '-F parm'" \
    1.29 ++     "\n	-F keyword	Keyword to look for" \
    1.30 ++     "\n	-0		Use \\0 string separator. Not \\n" \
    1.31 ++
    1.32 ++#define modinfo_example_usage \
    1.33 ++       "$ modinfo -F vermagic loop\n"
    1.34 ++       
    1.35 + #define more_trivial_usage \
    1.36 +        "[FILE...]"
    1.37 + #define more_full_usage "\n\n" \
    1.38 +
    1.39 +--- busybox-1.12.0/modutils/Config.in
    1.40 ++++ busybox-1.12.0/modutils/Config.in
    1.41 +@@ -213,6 +213,12 @@ config FEATURE_MODPROBE_BLACKLIST
    1.42 + 	  hardware autodetection scripts to load modules like evdev, frame
    1.43 + 	  buffer drivers etc.
    1.44 + 
    1.45 ++config MODINFO
    1.46 ++	bool "modinfo"
    1.47 ++	default n
    1.48 ++	help
    1.49 ++	  Show information about a Linux Kernel module
    1.50 ++
    1.51 + comment "Options common to multiple modutils"
    1.52 + 	depends on INSMOD || RMMOD || MODPROBE || LSMOD || DEPMOD
    1.53 + 
    1.54 +
    1.55 +--- busybox-1.12.0/modutils/Kbuild
    1.56 ++++ busybox-1.12.0/modutils/Kbuild
    1.57 +@@ -11,3 +11,4 @@ lib-$(CONFIG_LSMOD)             += lsmod
    1.58 + lib-$(CONFIG_MODPROBE)          += modprobe.o
    1.59 + lib-$(CONFIG_MODPROBE_SMALL)    += modprobe-small.o
    1.60 + lib-$(CONFIG_RMMOD)             += rmmod.o
    1.61 ++lib-$(CONFIG_MODINFO)           += modinfo.o
    1.62 +
    1.63 +--- busybox-1.12.0/modutils/modinfo.c
    1.64 ++++ busybox-1.12.0/modutils/modinfo.c
    1.65 +@@ -0,0 +1,91 @@
    1.66 ++/* vi: set sw=4 ts=4: */
    1.67 ++/*
    1.68 ++ * modinfo - retrieve module info
    1.69 ++ * Copyright (c) 2008 Pascal Bellard
    1.70 ++ *
    1.71 ++ * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
    1.72 ++ */
    1.73 ++
    1.74 ++#undef _GNU_SOURCE
    1.75 ++#define _GNU_SOURCE
    1.76 ++#include <libbb.h>
    1.77 ++#include <sys/utsname.h> /* uname() */
    1.78 ++
    1.79 ++int modinfo_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
    1.80 ++int modinfo_main(int argc UNUSED_PARAM, char **argv)
    1.81 ++{
    1.82 ++	static const char *shortcuts[] = {
    1.83 ++		"author",
    1.84 ++		"description",
    1.85 ++		"license",
    1.86 ++		"parm"
    1.87 ++	};
    1.88 ++	size_t len;
    1.89 ++	int i, length;
    1.90 ++	char *field = NULL;
    1.91 ++	char *ptr, *the_module, *depends, *filename;
    1.92 ++	struct utsname un;
    1.93 ++	enum {
    1.94 ++		ARG_F = (1<<4), /* field name */
    1.95 ++		ARG_0 = (1<<5)  /* \0 as separator */
    1.96 ++	};
    1.97 ++	extern void *xalloc_load_module(const char filename[], size_t *len);
    1.98 ++
    1.99 ++	getopt32(argv, "adlpF:0", &field);
   1.100 ++	argv += optind;
   1.101 ++
   1.102 ++	for (i = 0; i < sizeof(shortcuts)/sizeof(shortcuts[0]); i++)
   1.103 ++		if (option_mask32 & (1 << i))
   1.104 ++			field = (char *) shortcuts[i];
   1.105 ++
   1.106 ++	if (!field || !*argv)
   1.107 ++		bb_show_usage();
   1.108 ++
   1.109 ++	/* get module path from modules.dep */
   1.110 ++	uname(&un); /* never fails */
   1.111 ++	filename = xasprintf(CONFIG_DEFAULT_MODULES_DIR"/%s/"CONFIG_DEFAULT_DEPMOD_FILE, un.release);
   1.112 ++	len = MAXINT(ssize_t);
   1.113 ++	the_module = xalloc_load_module(*argv, &len);
   1.114 ++	if (the_module == NULL) {
   1.115 ++		len = MAXINT(ssize_t);
   1.116 ++		ptr = depends = xmalloc_open_read_close(filename, &len);
   1.117 ++		depends[len-1] = 0;
   1.118 ++		if (ENABLE_FEATURE_CLEAN_UP)
   1.119 ++			free(filename);
   1.120 ++		do {
   1.121 ++			ptr = strstr(ptr,*argv);
   1.122 ++			length = strlen(*argv);
   1.123 ++			if (!ptr)
   1.124 ++				bb_show_usage();
   1.125 ++			if (ptr[length] == '.' && ptr[-1] == '/') {
   1.126 ++				while (ptr[++length] != ':')
   1.127 ++					if (ptr[length] == ' ') goto next;
   1.128 ++				ptr[length] = 0;
   1.129 ++				while (ptr > depends && ptr[-1] != '\n') ptr--;
   1.130 ++				break;
   1.131 ++			}
   1.132 ++		next:
   1.133 ++			ptr++;
   1.134 ++		} while (1);
   1.135 ++		if (ENABLE_FEATURE_CLEAN_UP)
   1.136 ++			free(depends);
   1.137 ++	
   1.138 ++		len = MAXINT(ssize_t);
   1.139 ++		the_module = xalloc_load_module(ptr, &len);
   1.140 ++	}
   1.141 ++	ptr = the_module;
   1.142 ++	length = strlen(field);
   1.143 ++	do {
   1.144 ++		ptr = memchr(ptr, *field, len - (ptr - (char*)the_module));
   1.145 ++		if (ptr == NULL) /* no occurance left, done */
   1.146 ++			break;
   1.147 ++		if (!strncmp(ptr, field, length) && ptr[length] == '=') {
   1.148 ++			ptr += length + 1;
   1.149 ++			ptr += printf("%s%c",ptr,(option_mask32 & ARG_0) ? '\0' : '\n');
   1.150 ++		}
   1.151 ++		++ptr;
   1.152 ++	} while (1);
   1.153 ++	if (ENABLE_FEATURE_CLEAN_UP)
   1.154 ++		free(the_module);
   1.155 ++	return 0;
   1.156 ++}