udhcpc: fix a problem with binary-encoded options #2
[oweals/busybox.git] / modutils / depmod.c
index 6a43aa110217e64b60aac71668d737b0b13fc34e..aa228ec8561fec402ee445570bf36e29199e1190 100644 (file)
@@ -8,7 +8,7 @@
  * Licensed under GPLv2 or later, see file LICENSE in this source tree.
  */
 
-//applet:IF_DEPMOD(APPLET(depmod, _BB_DIR_SBIN, _BB_SUID_DROP))
+//applet:IF_DEPMOD(APPLET(depmod, BB_DIR_SBIN, BB_SUID_DROP))
 
 #include "libbb.h"
 #include "modutils.h"
@@ -31,7 +31,7 @@ typedef struct module_info {
 } module_info;
 
 static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARAM,
-                                 void *data, int depth UNUSED_PARAM)
+                               void *data, int depth UNUSED_PARAM)
 {
        char modname[MODULE_NAME_LEN];
        module_info **first = (module_info **) data;
@@ -95,7 +95,7 @@ static module_info *find_module(module_info *modules, const char *modname)
 }
 
 static void order_dep_list(module_info *modules, module_info *start,
-                          llist_t *add)
+                       llist_t *add)
 {
        module_info *m;
        llist_t *n;
@@ -126,7 +126,16 @@ static void xfreopen_write(const char *file, FILE *f)
                bb_perror_msg_and_die("can't open '%s'", file);
 }
 
-/* Usage:
+//usage:#if !ENABLE_MODPROBE_SMALL
+//usage:#define depmod_trivial_usage "[-n] [-b BASE] [VERSION] [MODFILES]..."
+//usage:#define depmod_full_usage "\n\n"
+//usage:       "Generate modules.dep, alias, and symbols files"
+//usage:     "\n"
+//usage:     "\n       -b BASE Use BASE/lib/modules/VERSION"
+//usage:     "\n       -n      Dry run: print files to stdout"
+//usage:#endif
+
+/* Upstream usage:
  * [-aAenv] [-C FILE or DIR] [-b BASE] [-F System.map] [VERSION] [MODFILES]...
  *     -a --all
  *             Probe all modules. Default if no MODFILES.
@@ -137,7 +146,7 @@ static void xfreopen_write(const char *file, FILE *f)
  *     -C --config FILE or DIR
  *             Path to /etc/depmod.conf or /etc/depmod.d/
  *     -e --errsyms
- *             When combined with the -F option, this reports any symbols which
+ *             When combined with the -F option, this reports any symbols
  *             which are not supplied by other modules or kernel.
  *     -F --filesyms System.map
  *     -n --dry-run
@@ -146,9 +155,16 @@ static void xfreopen_write(const char *file, FILE *f)
  *             Print to stdout all the symbols each module depends on
  *             and the module's file name which provides that symbol.
  *     -r      No-op
+ *     -u      No-op
+ *     -q      No-op
+ *
+ * So far we only support: [-n] [-b BASE] [VERSION] [MODFILES]...
+ * Accepted but ignored:
+ * -aAe
+ * -F System.map
+ * -C FILE/DIR
  *
- * So far we only support: [-rn] [-b BASE] [VERSION] [MODFILES]...
- * -aAeF are accepted but ignored. -vC are not accepted.
+ * Not accepted: -v
  */
 enum {
        //OPT_a = (1 << 0), /* All modules, ignore mods in argv */
@@ -157,7 +173,10 @@ enum {
        //OPT_e = (1 << 3), /* with -F, print unresolved symbols */
        //OPT_F = (1 << 4), /* System.map that contains the symbols */
        OPT_n = (1 << 5), /* dry-run, print to stdout only */
-       OPT_r = (1 << 6)  /* Compat dummy. Linux Makefile uses it */
+       OPT_r = (1 << 6), /* Compat dummy. Linux Makefile uses it */
+       OPT_u = (1 << 7), /* -u,--unresolved-error: ignored */
+       OPT_q = (1 << 8), /* -q,--quiet: ignored */
+       OPT_C = (1 << 9), /* -C,--config etc_modules_conf: ignored */
 };
 
 int depmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
@@ -169,7 +188,7 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
        struct utsname uts;
        int tmp;
 
-       getopt32(argv, "aAb:eF:nr", &moddir_base, NULL);
+       getopt32(argv, "aAb:eF:nruqC:", &moddir_base, NULL, NULL);
        argv += optind;
 
        /* goto modules location */
@@ -197,7 +216,7 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
                } while (*++argv);
        } else {
                recursive_action(".", ACTION_RECURSE,
-                                parse_module, NULL, &modules, 0);
+                               parse_module, NULL, &modules, 0);
        }
 
        /* Generate dependency and alias files */