aboutsummaryrefslogtreecommitdiffstats
path: root/main/busybox
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2015-08-20 12:00:59 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2015-08-20 12:00:59 +0200
commit66fcb5bf4a0bce5b0e6d1e8235b549c6b8a31002 (patch)
tree82f09083320b75ace065eaf66603c4b0be26cedb /main/busybox
parentc13f68bf98143f4f346da0e8bff63c4988580739 (diff)
downloadaports-66fcb5bf4a0bce5b0e6d1e8235b549c6b8a31002.tar.bz2
aports-66fcb5bf4a0bce5b0e6d1e8235b549c6b8a31002.tar.xz
Revert "main/busybox: backport libkmod compatible depmod"
Diffstat (limited to 'main/busybox')
-rw-r--r--main/busybox/2001-depmod-simple-memory-optimization.patch93
-rw-r--r--main/busybox/2002-modutils-merge-module_entry-and-module_info-to-commo.patch445
-rw-r--r--main/busybox/2003-depmod-support-generating-kmod-binary-index-files.patch441
-rw-r--r--main/busybox/APKBUILD21
-rw-r--r--main/busybox/busyboxconfig3
5 files changed, 5 insertions, 998 deletions
diff --git a/main/busybox/2001-depmod-simple-memory-optimization.patch b/main/busybox/2001-depmod-simple-memory-optimization.patch
deleted file mode 100644
index 0d8487560e..0000000000
--- a/main/busybox/2001-depmod-simple-memory-optimization.patch
+++ /dev/null
@@ -1,93 +0,0 @@
-From 57d0eee1e1ec8ee02dd45b77ab3b6921b884855d Mon Sep 17 00:00:00 2001
-From: Denys Vlasenko <vda.linux@googlemail.com>
-Date: Sat, 24 Jan 2015 22:30:30 +0100
-Subject: [PATCH 2001/2003] depmod: simple memory optimization
-
-function old new delta
-filename2modname 67 86 +19
-parse_module 374 351 -23
-
-Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
----
- modutils/depmod.c | 19 +++++++++----------
- modutils/modutils.c | 6 +++++-
- 2 files changed, 14 insertions(+), 11 deletions(-)
-
-diff --git a/modutils/depmod.c b/modutils/depmod.c
-index a41b3e4..37a8482 100644
---- a/modutils/depmod.c
-+++ b/modutils/depmod.c
-@@ -33,7 +33,6 @@ typedef struct module_info {
- static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARAM,
- void *data, int depth UNUSED_PARAM)
- {
-- char modname[MODULE_NAME_LEN];
- module_info **first = (module_info **) data;
- char *image, *ptr;
- module_info *info;
-@@ -51,11 +50,10 @@ static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARA
-
- info->dnext = info->dprev = info;
- info->name = xstrdup(fname + 2); /* skip "./" */
-- info->modname = xstrdup(
-- filename2modname(
-+ info->modname = filename2modname(
- bb_get_last_path_component_nostrip(fname),
-- modname
-- ));
-+ NULL
-+ );
- for (ptr = image; ptr < image + len - 10; ptr++) {
- if (strncmp(ptr, "depends=", 8) == 0) {
- char *u;
-@@ -250,11 +248,12 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
- const char *fname = bb_basename(m->name);
- filename2modname(fname, modname);
- while (m->aliases) {
-- /* Last word can well be m->modname instead,
-- * but depmod from module-init-tools 3.4
-- * uses module basename, i.e., no s/-/_/g.
-- * (pathname and .ko.* are still stripped)
-- * Mimicking that... */
-+ /*
-+ * Last word used to be a basename
-+ * (filename with path and .ko.* stripped)
-+ * at the time of module-init-tools 3.4.
-+ * kmod v.12 uses module name, i.e., s/-/_/g.
-+ */
- printf("alias %s %s\n",
- (char*)llist_pop(&m->aliases),
- modname);
-diff --git a/modutils/modutils.c b/modutils/modutils.c
-index ff79d3f..84300d9 100644
---- a/modutils/modutils.c
-+++ b/modutils/modutils.c
-@@ -47,13 +47,14 @@ int FAST_FUNC string_to_llist(char *string, llist_t **llist, const char *delim)
-
- char* FAST_FUNC filename2modname(const char *filename, char *modname)
- {
-+ char local_modname[MODULE_NAME_LEN];
- int i;
- const char *from;
-
- if (filename == NULL)
- return NULL;
- if (modname == NULL)
-- modname = xmalloc(MODULE_NAME_LEN);
-+ modname = local_modname;
- // Disabled since otherwise "modprobe dir/name" would work
- // as if it is "modprobe name". It is unclear why
- // 'basenamization' was here in the first place.
-@@ -63,6 +64,9 @@ char* FAST_FUNC filename2modname(const char *filename, char *modname)
- modname[i] = (from[i] == '-') ? '_' : from[i];
- modname[i] = '\0';
-
-+ if (modname == local_modname)
-+ return xstrdup(modname);
-+
- return modname;
- }
-
---
-2.5.0
-
diff --git a/main/busybox/2002-modutils-merge-module_entry-and-module_info-to-commo.patch b/main/busybox/2002-modutils-merge-module_entry-and-module_info-to-commo.patch
deleted file mode 100644
index f7dc826750..0000000000
--- a/main/busybox/2002-modutils-merge-module_entry-and-module_info-to-commo.patch
+++ /dev/null
@@ -1,445 +0,0 @@
-From 2fedbe5b8bd40933a35606d5478396dbc212ddf1 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
-Date: Wed, 22 Jul 2015 15:15:15 +0300
-Subject: [PATCH 2002/2003] modutils: merge module_entry and module_info to
- common code
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-This merges the in-memory module info structures of modprobe
-and depmod. This allows sharing hashing by modulename code
-improving depmod runtime with almost factor of 2x.
-
-Signed-off-by: Timo Teräs <timo.teras@iki.fi>
----
- modutils/depmod.c | 99 +++++++++++++++++++----------------------------------
- modutils/modprobe.c | 66 ++++-------------------------------
- modutils/modutils.c | 43 +++++++++++++++++++++++
- modutils/modutils.h | 29 ++++++++++++++++
- 4 files changed, 114 insertions(+), 123 deletions(-)
-
-diff --git a/modutils/depmod.c b/modutils/depmod.c
-index 37a8482..4d83429 100644
---- a/modutils/depmod.c
-+++ b/modutils/depmod.c
-@@ -14,6 +14,14 @@
- #include "modutils.h"
- #include <sys/utsname.h> /* uname() */
-
-+struct globals {
-+ module_db db;
-+} FIX_ALIASING;
-+#define G (*ptr_to_globals)
-+#define INIT_G() do { \
-+ SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
-+} while (0)
-+
- /*
- * Theory of operation:
- * - iterate over all modules and record their full path
-@@ -21,21 +29,12 @@
- * for each depends, look through our list of full paths and emit if found
- */
-
--typedef struct module_info {
-- struct module_info *next;
-- char *name, *modname;
-- llist_t *dependencies;
-- llist_t *aliases;
-- llist_t *symbols;
-- struct module_info *dnext, *dprev;
--} module_info;
--
- static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARAM,
-- void *data, int depth UNUSED_PARAM)
-+ void *data UNUSED_PARAM, int depth UNUSED_PARAM)
- {
-- module_info **first = (module_info **) data;
- char *image, *ptr;
-- module_info *info;
-+ module_entry *e;
-+
- /* Arbitrary. Was sb->st_size, but that breaks .gz etc */
- size_t len = (64*1024*1024 - 4096);
-
-@@ -43,17 +42,10 @@ static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARA
- return TRUE;
-
- image = xmalloc_open_zipped_read_close(fname, &len);
-- info = xzalloc(sizeof(*info));
-
-- info->next = *first;
-- *first = info;
-+ e = moddb_get(&G.db, bb_get_last_path_component_nostrip(fname), 1);
-+ e->name = xstrdup(fname + 2); /* skip "./" */
-
-- info->dnext = info->dprev = info;
-- info->name = xstrdup(fname + 2); /* skip "./" */
-- info->modname = filename2modname(
-- bb_get_last_path_component_nostrip(fname),
-- NULL
-- );
- for (ptr = image; ptr < image + len - 10; ptr++) {
- if (strncmp(ptr, "depends=", 8) == 0) {
- char *u;
-@@ -62,11 +54,11 @@ static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARA
- for (u = ptr; *u; u++)
- if (*u == '-')
- *u = '_';
-- ptr += string_to_llist(ptr, &info->dependencies, ",");
-+ ptr += string_to_llist(ptr, &e->deps, ",");
- } else if (ENABLE_FEATURE_MODUTILS_ALIAS
- && strncmp(ptr, "alias=", 6) == 0
- ) {
-- llist_add_to(&info->aliases, xstrdup(ptr + 6));
-+ llist_add_to(&e->aliases, xstrdup(ptr + 6));
- ptr += strlen(ptr);
- } else if (ENABLE_FEATURE_MODUTILS_SYMBOLS
- && strncmp(ptr, "__ksymtab_", 10) == 0
-@@ -77,7 +69,7 @@ static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARA
- ) {
- continue;
- }
-- llist_add_to(&info->symbols, xstrdup(ptr));
-+ llist_add_to(&e->symbols, xstrdup(ptr));
- ptr += strlen(ptr);
- }
- }
-@@ -86,24 +78,13 @@ static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARA
- return TRUE;
- }
-
--static module_info *find_module(module_info *modules, const char *modname)
--{
-- module_info *m;
--
-- for (m = modules; m != NULL; m = m->next)
-- if (strcmp(m->modname, modname) == 0)
-- return m;
-- return NULL;
--}
--
--static void order_dep_list(module_info *modules, module_info *start,
-- llist_t *add)
-+static void order_dep_list(module_entry *start, llist_t *add)
- {
-- module_info *m;
-+ module_entry *m;
- llist_t *n;
-
- for (n = add; n != NULL; n = n->link) {
-- m = find_module(modules, n->data);
-+ m = moddb_get(&G.db, n->data, 0);
- if (m == NULL)
- continue;
-
-@@ -118,7 +99,7 @@ static void order_dep_list(module_info *modules, module_info *start,
- start->dprev = m;
-
- /* recurse */
-- order_dep_list(modules, start, m->dependencies);
-+ order_dep_list(start, m->deps);
- }
- }
-
-@@ -184,12 +165,15 @@ enum {
- int depmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
- int depmod_main(int argc UNUSED_PARAM, char **argv)
- {
-- module_info *modules, *m, *dep;
-+ module_entry *m, *dep;
- const char *moddir_base = "/";
- char *moddir, *version;
- struct utsname uts;
-+ unsigned i;
- int tmp;
-
-+ INIT_G();
-+
- getopt32(argv, "aAb:eF:nruqC:", &moddir_base, NULL, NULL);
- argv += optind;
-
-@@ -211,23 +195,23 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
- free(moddir);
-
- /* Scan modules */
-- modules = NULL;
- if (*argv) {
- do {
-- parse_module(*argv, /*sb (unused):*/ NULL, &modules, 0);
-+ parse_module(*argv, /*sb (unused):*/ NULL, NULL, 0);
- } while (*++argv);
- } else {
- recursive_action(".", ACTION_RECURSE,
-- parse_module, NULL, &modules, 0);
-+ parse_module, NULL, NULL, 0);
- }
-
- /* Generate dependency and alias files */
- if (!(option_mask32 & OPT_n))
- xfreopen_write(CONFIG_DEFAULT_DEPMOD_FILE, stdout);
-- for (m = modules; m != NULL; m = m->next) {
-+
-+ moddb_foreach_module(&G.db, m, i) {
- printf("%s:", m->name);
-
-- order_dep_list(modules, m, m->dependencies);
-+ order_dep_list(m, m->deps);
- while (m->dnext != m) {
- dep = m->dnext;
- printf(" %s", dep->name);
-@@ -243,10 +227,7 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
- #if ENABLE_FEATURE_MODUTILS_ALIAS
- if (!(option_mask32 & OPT_n))
- xfreopen_write("modules.alias", stdout);
-- for (m = modules; m != NULL; m = m->next) {
-- char modname[MODULE_NAME_LEN];
-- const char *fname = bb_basename(m->name);
-- filename2modname(fname, modname);
-+ moddb_foreach_module(&G.db, m, i) {
- while (m->aliases) {
- /*
- * Last word used to be a basename
-@@ -256,34 +237,24 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
- */
- printf("alias %s %s\n",
- (char*)llist_pop(&m->aliases),
-- modname);
-+ m->modname);
- }
- }
- #endif
- #if ENABLE_FEATURE_MODUTILS_SYMBOLS
- if (!(option_mask32 & OPT_n))
- xfreopen_write("modules.symbols", stdout);
-- for (m = modules; m != NULL; m = m->next) {
-- char modname[MODULE_NAME_LEN];
-- const char *fname = bb_basename(m->name);
-- filename2modname(fname, modname);
-+ moddb_foreach_module(&G.db, m, i) {
- while (m->symbols) {
- printf("alias symbol:%s %s\n",
- (char*)llist_pop(&m->symbols),
-- modname);
-+ m->modname);
- }
- }
- #endif
-
-- if (ENABLE_FEATURE_CLEAN_UP) {
-- while (modules) {
-- module_info *old = modules;
-- modules = modules->next;
-- free(old->name);
-- free(old->modname);
-- free(old);
-- }
-- }
-+ if (ENABLE_FEATURE_CLEAN_UP)
-+ moddb_free(&G.db);
-
- return EXIT_SUCCESS;
- }
-diff --git a/modutils/modprobe.c b/modutils/modprobe.c
-index aedde5c..1e67807 100644
---- a/modutils/modprobe.c
-+++ b/modutils/modprobe.c
-@@ -147,19 +147,6 @@ static const char modprobe_longopts[] ALIGN1 =
- #define MODULE_FLAG_FOUND_IN_MODDEP 0x0004
- #define MODULE_FLAG_BLACKLISTED 0x0008
-
--struct module_entry { /* I'll call it ME. */
-- unsigned flags;
-- char *modname; /* stripped of /path/, .ext and s/-/_/g */
-- const char *probed_name; /* verbatim as seen on cmdline */
-- char *options; /* options from config files */
-- llist_t *realnames; /* strings. if this module is an alias, */
-- /* real module name is one of these. */
--//Can there really be more than one? Example from real kernel?
-- llist_t *deps; /* strings. modules we depend on */
--};
--
--#define DB_HASH_SIZE 256
--
- struct globals {
- llist_t *probes; /* MEs of module(s) requested on cmdline */
- char *cmdline_mopts; /* module options from cmdline */
-@@ -167,7 +154,7 @@ struct globals {
- /* bool. "Did we have 'symbol:FOO' requested on cmdline?" */
- smallint need_symbols;
- struct utsname uts;
-- llist_t *db[DB_HASH_SIZE]; /* MEs of all modules ever seen (caching for speed) */
-+ module_db db;
- } FIX_ALIASING;
- #define G (*ptr_to_globals)
- #define INIT_G() do { \
-@@ -192,51 +179,9 @@ static char *gather_options_str(char *opts, const char *append)
- return opts;
- }
-
--/* These three functions called many times, optimizing for speed.
-- * Users reported minute-long delays when they runn iptables repeatedly
-- * (iptables use modprobe to install needed kernel modules).
-- */
--static struct module_entry *helper_get_module(const char *module, int create)
-+static struct module_entry *get_or_add_modentry(const char *module)
- {
-- char modname[MODULE_NAME_LEN];
-- struct module_entry *e;
-- llist_t *l;
-- unsigned i;
-- unsigned hash;
--
-- filename2modname(module, modname);
--
-- hash = 0;
-- for (i = 0; modname[i]; i++)
-- hash = ((hash << 5) + hash) + modname[i];
-- hash %= DB_HASH_SIZE;
--
-- for (l = G.db[hash]; l; l = l->link) {
-- e = (struct module_entry *) l->data;
-- if (strcmp(e->modname, modname) == 0)
-- return e;
-- }
-- if (!create)
-- return NULL;
--
-- e = xzalloc(sizeof(*e));
-- e->modname = xstrdup(modname);
-- llist_add_to(&G.db[hash], e);
--
-- return e;
--}
--static ALWAYS_INLINE struct module_entry *get_or_add_modentry(const char *module)
--{
-- return helper_get_module(module, 1);
--}
--/* So far this function always gets a module pathname, never an alias name.
-- * The crucial difference is that pathname needs dirname stripping,
-- * while alias name must NOT do it!
-- * Testcase where dirname stripping is likely to go wrong: "modprobe devname:snd/timer"
-- */
--static ALWAYS_INLINE struct module_entry *get_modentry(const char *pathname)
--{
-- return helper_get_module(bb_get_last_path_component_nostrip(pathname), 0);
-+ return moddb_get(&G.db, module, 1);
- }
-
- static void add_probe(const char *name)
-@@ -506,7 +451,7 @@ static void load_modules_dep(void)
- continue;
- *colon = '\0';
-
-- m = get_modentry(tokens[0]);
-+ m = moddb_get(&G.db, bb_get_last_path_component_nostrip(tokens[0]), 0);
- if (m == NULL)
- continue;
-
-@@ -667,5 +612,8 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
- } while (me->realnames != NULL);
- }
-
-+ if (ENABLE_FEATURE_CLEAN_UP)
-+ moddb_free(&G.db);
-+
- return (rc != 0);
- }
-diff --git a/modutils/modutils.c b/modutils/modutils.c
-index 84300d9..ed26697 100644
---- a/modutils/modutils.c
-+++ b/modutils/modutils.c
-@@ -16,6 +16,49 @@ extern int delete_module(const char *module, unsigned int flags);
- # define delete_module(mod, flags) syscall(__NR_delete_module, mod, flags)
- #endif
-
-+module_entry * FAST_FUNC moddb_get(module_db *db, const char *module, int create)
-+{
-+ char modname[MODULE_NAME_LEN];
-+ struct module_entry *e;
-+ unsigned i, hash;
-+
-+ filename2modname(module, modname);
-+
-+ hash = 0;
-+ for (i = 0; modname[i]; i++)
-+ hash = ((hash << 5) + hash) + modname[i];
-+ hash %= MODULE_HASH_SIZE;
-+
-+ for (e = db->buckets[hash]; e; e = e->next)
-+ if (strcmp(e->modname, modname) == 0)
-+ return e;
-+ if (!create)
-+ return NULL;
-+
-+ e = xzalloc(sizeof(*e));
-+ e->modname = xstrdup(modname);
-+ e->next = db->buckets[hash];
-+ db->buckets[hash] = e;
-+ e->dnext = e->dprev = e;
-+
-+ return e;
-+}
-+
-+void FAST_FUNC moddb_free(module_db *db)
-+{
-+ module_entry *e, *n;
-+ unsigned i;
-+
-+ for (i = 0; i < MODULE_HASH_SIZE; i++) {
-+ for (e = db->buckets[i]; e; e = n) {
-+ n = e->next;
-+ free(e->name);
-+ free(e->modname);
-+ free(e);
-+ }
-+ }
-+}
-+
- void FAST_FUNC replace(char *s, char what, char with)
- {
- while (*s) {
-diff --git a/modutils/modutils.h b/modutils/modutils.h
-index 5f059c7..0c0cb46 100644
---- a/modutils/modutils.h
-+++ b/modutils/modutils.h
-@@ -16,6 +16,35 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
- /* linux/include/linux/module.h has 64, but this is also used
- * internally for the maximum alias name length, which can be quite long */
- #define MODULE_NAME_LEN 256
-+#define MODULE_HASH_SIZE 256
-+
-+typedef struct module_entry {
-+ struct module_entry *next;
-+ char *name, *modname;
-+ llist_t *deps;
-+ IF_MODPROBE(
-+ llist_t *realnames;
-+ unsigned flags;
-+ const char *probed_name; /* verbatim as seen on cmdline */
-+ char *options; /* options from config files */
-+ )
-+ IF_DEPMOD(
-+ llist_t *aliases;
-+ llist_t *symbols;
-+ struct module_entry *dnext, *dprev;
-+ )
-+} module_entry;
-+
-+typedef struct module_db {
-+ module_entry *buckets[MODULE_HASH_SIZE];
-+} module_db;
-+
-+#define moddb_foreach_module(db, module, index) \
-+ for ((index) = 0; (index) < MODULE_HASH_SIZE; (index)++) \
-+ for (module = (db)->buckets[index]; module; module = module->next)
-+
-+module_entry *moddb_get(module_db *db, const char *s, int create) FAST_FUNC;
-+void moddb_free(module_db *db) FAST_FUNC;
-
- void replace(char *s, char what, char with) FAST_FUNC;
- char *replace_underscores(char *s) FAST_FUNC;
---
-2.5.0
-
diff --git a/main/busybox/2003-depmod-support-generating-kmod-binary-index-files.patch b/main/busybox/2003-depmod-support-generating-kmod-binary-index-files.patch
deleted file mode 100644
index 0751cec576..0000000000
--- a/main/busybox/2003-depmod-support-generating-kmod-binary-index-files.patch
+++ /dev/null
@@ -1,441 +0,0 @@
-From 5f8123e0611b0bbf46229f6cb9682dd5a2af9820 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
-Date: Wed, 22 Jul 2015 15:15:16 +0300
-Subject: [PATCH 2003/2003] depmod: support generating kmod binary index files
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-This allows to use busybox depmod, and run daemons
-using libkmod (or even kmod modprobe if needed).
-
-About +1500 bytes when enabled. This patch merges some
-depmod code paths, so when this is disabled it shrinks
-the code size a little bit.
-
-Signed-off-by: Timo Teräs <timo.teras@iki.fi>
----
- modutils/Config.src | 10 +++
- modutils/depmod.c | 253 +++++++++++++++++++++++++++++++++++++++++++---------
- modutils/modprobe.c | 15 ----
- modutils/modutils.c | 15 ++++
- modutils/modutils.h | 15 ++++
- 5 files changed, 253 insertions(+), 55 deletions(-)
-
-diff --git a/modutils/Config.src b/modutils/Config.src
-index 449ac65..4acefca 100644
---- a/modutils/Config.src
-+++ b/modutils/Config.src
-@@ -232,6 +232,16 @@ config FEATURE_MODUTILS_ALIAS
-
- Say Y if unsure.
-
-+config FEATURE_MODUTILS_BIN
-+ bool "Support for the kmod .bin file format"
-+ default n
-+ depends on DEPMOD && !MODPROBE_SMALL
-+ select PLATFORM_LINUX
-+ help
-+ Generate kmod compatible binary index files for .dep, .alias,
-+ .symbols and .builtin files. Allows mixing use of busybox
-+ modutils and kmod (binaries and library).
-+
- config FEATURE_MODUTILS_SYMBOLS
- bool "Support for module.symbols file"
- default y
-diff --git a/modutils/depmod.c b/modutils/depmod.c
-index 4d83429..d399518 100644
---- a/modutils/depmod.c
-+++ b/modutils/depmod.c
-@@ -2,7 +2,7 @@
- /*
- * depmod - generate modules.dep
- * Copyright (c) 2008 Bernhard Reutner-Fischer
-- * Copyrihgt (c) 2008 Timo Teras <timo.teras@iki.fi>
-+ * Copyrihgt (c) 2008-2015 Timo Teras <timo.teras@iki.fi>
- * Copyright (c) 2008 Vladimir Dronnikov
- *
- * Licensed under GPLv2 or later, see file LICENSE in this source tree.
-@@ -14,8 +14,18 @@
- #include "modutils.h"
- #include <sys/utsname.h> /* uname() */
-
-+#define INDEX_MINCHAR 32
-+#define INDEX_MAXCHAR 128
-+
-+typedef struct index_node {
-+ char *prefix;
-+ llist_t *values;
-+ struct index_node *children[INDEX_MAXCHAR-INDEX_MINCHAR];
-+} index_node;
-+
- struct globals {
- module_db db;
-+ index_node *root_node;
- } FIX_ALIASING;
- #define G (*ptr_to_globals)
- #define INIT_G() do { \
-@@ -103,12 +113,6 @@ static void order_dep_list(module_entry *start, llist_t *add)
- }
- }
-
--static void xfreopen_write(const char *file, FILE *f)
--{
-- if (freopen(file, "w", f) == NULL)
-- bb_perror_msg_and_die("can't open '%s'", file);
--}
--
- //usage:#if !ENABLE_MODPROBE_SMALL
- //usage:#define depmod_trivial_usage "[-n] [-b BASE] [VERSION] [MODFILES]..."
- //usage:#define depmod_full_usage "\n\n"
-@@ -162,6 +166,169 @@ enum {
- OPT_C = (1 << 9), /* -C,--config etc_modules_conf: ignored */
- };
-
-+/* Support for the mod binary index generation */
-+
-+static void index_init(const char *filename)
-+{
-+ if (ENABLE_FEATURE_MODUTILS_BIN) {
-+ index_node *n;
-+
-+ n = xzalloc(sizeof(index_node));
-+ n->prefix = xstrdup("");
-+ G.root_node = n;
-+ }
-+
-+ if (filename && !(option_mask32 & OPT_n)) {
-+ if (freopen(filename, "w", stdout) == NULL)
-+ bb_perror_msg_and_die("can't open '%s'", filename);
-+ }
-+}
-+
-+static void index_add(const char *key, char *value, const char *prefix)
-+{
-+ if (prefix && *prefix)
-+ printf("%s%s %s\n", prefix, key, value);
-+ else if (prefix)
-+ printf("%s\n", value);
-+
-+ if (ENABLE_FEATURE_MODUTILS_BIN) {
-+ index_node *cur = G.root_node, *n;
-+ unsigned i = 0, j, ch;
-+
-+ while (1) {
-+ /* Ensure node->prefix is a prefix of &str[i].
-+ * If it is not already, then we must split node. */
-+ for (j = 0; cur->prefix[j]; j++) {
-+ ch = cur->prefix[j];
-+ if (ch != key[i+j]) {
-+ /* New child is copy of node with prefix[j+1..N] */
-+ n = xzalloc(sizeof(index_node));
-+ n->prefix = xstrdup(&cur->prefix[j+1]);
-+ n->values = cur->values;
-+ memcpy(n->children, cur->children, sizeof(n->children));
-+
-+ /* Parent has prefix[0..j], child at prefix[j] */
-+ cur->prefix[j] = '\0';
-+ cur->values = NULL;
-+ memset(cur->children, 0, sizeof(cur->children));
-+ cur->children[ch-INDEX_MINCHAR] = n;
-+ break;
-+ }
-+ }
-+ i += j;
-+
-+ ch = key[i];
-+ if (ch == 0)
-+ break;
-+
-+ if (ch < INDEX_MINCHAR || ch >= INDEX_MAXCHAR)
-+ bb_error_msg_and_die("bad module name");
-+
-+ ch -= INDEX_MINCHAR;
-+ if (!cur->children[ch]) {
-+ n = xzalloc(sizeof(index_node));
-+ cur->children[ch] = n;
-+ n->prefix = xstrdup(&key[i+1]);
-+ cur = n;
-+ break;
-+ }
-+
-+ /* Descend into child node and continue */
-+ cur = cur->children[ch];
-+ i++;
-+ }
-+
-+ llist_add_to(&cur->values, value);
-+ }
-+}
-+
-+static uint32_t index_write_node(FILE *out, index_node *n, void (*freeit)(void *data))
-+{
-+ uint32_t child_offs[INDEX_MAXCHAR-INDEX_MINCHAR];
-+ uint32_t offset;
-+ uint8_t first = 255, last = 0;
-+ unsigned i;
-+
-+ for (i = 0; i < INDEX_MAXCHAR-INDEX_MINCHAR; i++) {
-+ child_offs[i] = 0;
-+ if (!n->children[i])
-+ continue;
-+ child_offs[i] = index_write_node(out, n->children[i], freeit);
-+ if (first > INDEX_MAXCHAR)
-+ first = i;
-+ last = i;
-+ }
-+
-+ offset = ftell(out);
-+
-+ if (n->prefix[0]) {
-+ fputs(n->prefix, out);
-+ fputc('\0', out);
-+ offset |= INDEX_NODE_PREFIX;
-+ }
-+
-+ if (first < INDEX_MAXCHAR) {
-+ fputc(first + INDEX_MINCHAR, out);
-+ fputc(last + INDEX_MINCHAR, out);
-+ fwrite(child_offs + first, sizeof(uint32_t), last - first + 1, out);
-+ offset |= INDEX_NODE_CHILDS;
-+ }
-+
-+ if (n->values) {
-+ const llist_t *v;
-+ unsigned int cnt;
-+ uint32_t u;
-+
-+ n->values = llist_rev(n->values);
-+ for (v = n->values, cnt = 0; v != NULL; v = v->link, cnt++);
-+ u = htonl(cnt);
-+ fwrite(&u, sizeof(u), 1, out);
-+ for (v = n->values, cnt = 0; v != NULL; v = v->link, cnt++) {
-+ u = htonl(cnt);
-+ fwrite(&u, sizeof(u), 1, out);
-+ fputs(v->data, out);
-+ fputc('\0', out);
-+ }
-+ offset |= INDEX_NODE_VALUES;
-+ }
-+
-+ llist_free(n->values, freeit);
-+ free(n->prefix);
-+ free(n);
-+
-+ return htonl(offset);
-+}
-+
-+static void index_dump(const char *filename, int deps_file)
-+{
-+ if (ENABLE_FEATURE_MODUTILS_BIN) {
-+ FILE *out;
-+ uint32_t header[3] = {
-+ htonl(INDEX_MAGIC),
-+ htonl(INDEX_VERSION),
-+ };
-+
-+ if (option_mask32 & OPT_n)
-+ filename = "/dev/null";
-+ else
-+ filename = xasprintf("tmp.%s.bin", filename);
-+
-+ out = xfopen_for_write(filename);
-+ fwrite(header, sizeof(uint32_t), 3, out);
-+ header[2] = index_write_node(out, G.root_node, deps_file ? free : 0);
-+ rewind(out);
-+ G.root_node = NULL;
-+ fwrite(header, sizeof(uint32_t), 3, out);
-+ if (fclose(out)) {
-+ remove(filename);
-+ bb_error_msg_and_die(bb_msg_write_error);
-+ }
-+ /* .bin files are mmap'ed; not renaming it may crash
-+ * long standing daemon using libkmod */
-+ rename_or_warn(filename, filename + 4);
-+ }
-+}
-+
- int depmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
- int depmod_main(int argc UNUSED_PARAM, char **argv)
- {
-@@ -205,53 +372,59 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
- }
-
- /* Generate dependency and alias files */
-- if (!(option_mask32 & OPT_n))
-- xfreopen_write(CONFIG_DEFAULT_DEPMOD_FILE, stdout);
--
-+ index_init(CONFIG_DEFAULT_DEPMOD_FILE);
- moddb_foreach_module(&G.db, m, i) {
-- printf("%s:", m->name);
--
-+ char *buf = xasprintf("%s:", m->name);
- order_dep_list(m, m->deps);
- while (m->dnext != m) {
- dep = m->dnext;
-- printf(" %s", dep->name);
--
-+ buf = gather_options_str(buf, dep->name);
- /* unlink current entry */
- dep->dnext->dprev = dep->dprev;
- dep->dprev->dnext = dep->dnext;
- dep->dnext = dep->dprev = dep;
- }
-- bb_putchar('\n');
-+ index_add(m->modname, buf, "");
- }
--
--#if ENABLE_FEATURE_MODUTILS_ALIAS
-- if (!(option_mask32 & OPT_n))
-- xfreopen_write("modules.alias", stdout);
-- moddb_foreach_module(&G.db, m, i) {
-- while (m->aliases) {
-- /*
-- * Last word used to be a basename
-- * (filename with path and .ko.* stripped)
-- * at the time of module-init-tools 3.4.
-- * kmod v.12 uses module name, i.e., s/-/_/g.
-- */
-- printf("alias %s %s\n",
-- (char*)llist_pop(&m->aliases),
-- m->modname);
-+ index_dump(CONFIG_DEFAULT_DEPMOD_FILE, 1);
-+
-+ if (ENABLE_FEATURE_MODUTILS_ALIAS) {
-+ index_init("modules.alias");
-+ moddb_foreach_module(&G.db, m, i) {
-+ while (m->aliases) {
-+ /*
-+ * Last word used to be a basename
-+ * (filename with path and .ko.* stripped)
-+ * at the time of module-init-tools 3.4.
-+ * kmod v.12 uses module name, i.e., s/-/_/g.
-+ */
-+ index_add((char*)llist_pop(&m->aliases), m->modname, "alias ");
-+ }
- }
-+ index_dump("modules.alias", 0);
- }
--#endif
--#if ENABLE_FEATURE_MODUTILS_SYMBOLS
-- if (!(option_mask32 & OPT_n))
-- xfreopen_write("modules.symbols", stdout);
-- moddb_foreach_module(&G.db, m, i) {
-- while (m->symbols) {
-- printf("alias symbol:%s %s\n",
-- (char*)llist_pop(&m->symbols),
-- m->modname);
-+ if (ENABLE_FEATURE_MODUTILS_SYMBOLS) {
-+ index_init("modules.symbols");
-+ moddb_foreach_module(&G.db, m, i) {
-+ while (m->symbols) {
-+ index_add((char*)llist_pop(&m->symbols), m->modname, "alias symbol:");
-+ }
-+ }
-+ index_dump("modules.symbols", 0);
-+ }
-+ if (ENABLE_FEATURE_MODUTILS_BIN) {
-+ char line[PATH_MAX], modname[MODULE_NAME_LEN];
-+ FILE *in;
-+
-+ index_init(NULL);
-+ in = xfopen_for_read("modules.builtin");
-+ while (fgets(line, sizeof(line), in) != NULL) {
-+ filename2modname(line, modname);
-+ index_add(modname, (char *) "", 0);
- }
-+ fclose(in);
-+ index_dump("modules.builtin", 0);
- }
--#endif
-
- if (ENABLE_FEATURE_CLEAN_UP)
- moddb_free(&G.db);
-diff --git a/modutils/modprobe.c b/modutils/modprobe.c
-index 1e67807..ea961f9 100644
---- a/modutils/modprobe.c
-+++ b/modutils/modprobe.c
-@@ -164,21 +164,6 @@ struct globals {
-
- static int read_config(const char *path);
-
--static char *gather_options_str(char *opts, const char *append)
--{
-- /* Speed-optimized. We call gather_options_str many times. */
-- if (append) {
-- if (opts == NULL) {
-- opts = xstrdup(append);
-- } else {
-- int optlen = strlen(opts);
-- opts = xrealloc(opts, optlen + strlen(append) + 2);
-- sprintf(opts + optlen, " %s", append);
-- }
-- }
-- return opts;
--}
--
- static struct module_entry *get_or_add_modentry(const char *module)
- {
- return moddb_get(&G.db, module, 1);
-diff --git a/modutils/modutils.c b/modutils/modutils.c
-index ed26697..c87b3e4 100644
---- a/modutils/modutils.c
-+++ b/modutils/modutils.c
-@@ -59,6 +59,21 @@ void FAST_FUNC moddb_free(module_db *db)
- }
- }
-
-+char * FAST_FUNC gather_options_str(char *opts, const char *append)
-+{
-+ /* Speed-optimized. We call gather_options_str many times. */
-+ if (append) {
-+ if (opts == NULL) {
-+ opts = xstrdup(append);
-+ } else {
-+ int optlen = strlen(opts);
-+ opts = xrealloc(opts, optlen + strlen(append) + 2);
-+ sprintf(opts + optlen, " %s", append);
-+ }
-+ }
-+ return opts;
-+}
-+
- void FAST_FUNC replace(char *s, char what, char with)
- {
- while (*s) {
-diff --git a/modutils/modutils.h b/modutils/modutils.h
-index 0c0cb46..30a13e6 100644
---- a/modutils/modutils.h
-+++ b/modutils/modutils.h
-@@ -18,6 +18,20 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
- #define MODULE_NAME_LEN 256
- #define MODULE_HASH_SIZE 256
-
-+/* .bin index format definitions */
-+#define INDEX_MAGIC 0xB007F457
-+#define INDEX_VERSION_MAJOR 0x0002
-+#define INDEX_VERSION_MINOR 0x0001
-+#define INDEX_VERSION ((INDEX_VERSION_MAJOR<<16)|INDEX_VERSION_MINOR)
-+
-+enum node_offset {
-+ INDEX_NODE_FLAGS = 0xF0000000, /* Flags in high nibble */
-+ INDEX_NODE_PREFIX = 0x80000000,
-+ INDEX_NODE_VALUES = 0x40000000,
-+ INDEX_NODE_CHILDS = 0x20000000,
-+ INDEX_NODE_MASK = 0x0FFFFFFF, /* Offset value */
-+};
-+
- typedef struct module_entry {
- struct module_entry *next;
- char *name, *modname;
-@@ -46,6 +60,7 @@ typedef struct module_db {
- module_entry *moddb_get(module_db *db, const char *s, int create) FAST_FUNC;
- void moddb_free(module_db *db) FAST_FUNC;
-
-+char *gather_options_str(char *opts, const char *append) FAST_FUNC;
- void replace(char *s, char what, char with) FAST_FUNC;
- char *replace_underscores(char *s) FAST_FUNC;
- int string_to_llist(char *string, llist_t **llist, const char *delim) FAST_FUNC;
---
-2.5.0
-
diff --git a/main/busybox/APKBUILD b/main/busybox/APKBUILD
index 1f1feaa278..b52707a11d 100644
--- a/main/busybox/APKBUILD
+++ b/main/busybox/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=busybox
pkgver=1.23.2
-pkgrel=7
+pkgrel=6
pkgdesc="Size optimized toolbox of many common UNIX utilities"
url=http://busybox.net
arch="all"
@@ -33,10 +33,6 @@ source="http://busybox.net/downloads/$pkgname-$pkgver.tar.bz2
1001-fbsplash-support-console-switching.patch
1002-fbsplash-support-image-and-bar-alignment-and-positio.patch
- 2001-depmod-simple-memory-optimization.patch
- 2002-modutils-merge-module_entry-and-module_info-to-commo.patch
- 2003-depmod-support-generating-kmod-binary-index-files.patch
-
acpid.logrotate
busyboxconfig
glibc.patch"
@@ -136,11 +132,8 @@ e1c183cbe1ca18a0fa0d9597314076c9 0001-ifupdown-use-x-hostname-NAME-with-udhcpc.
699ce5aa1095ba4419cd595cec8a8f75 1000-fbsplash-use-virtual-y-size-in-mmap-size-calculation.patch
b56d306ccba574da78dff060b7330806 1001-fbsplash-support-console-switching.patch
4fe5f9e973674c7db3d07f295c363a7c 1002-fbsplash-support-image-and-bar-alignment-and-positio.patch
-5bd6ea4535b45f9bede4cf64d74a7095 2001-depmod-simple-memory-optimization.patch
-e27a05f41b57b0188fc10ee4b6e30c46 2002-modutils-merge-module_entry-and-module_info-to-commo.patch
-04addd68d738b0168db3d4699a6bbfb4 2003-depmod-support-generating-kmod-binary-index-files.patch
4046b78ee6a25259954797d73b94f4bd acpid.logrotate
-33e9131128df33a54dc3aa54a0ff964d busyboxconfig
+961e07aac55e31c1b535d44a771b486c busyboxconfig
befaac2c59c380e36a452b3f1c1d4a3a glibc.patch"
sha256sums="05a6f9e21aad8c098e388ae77de7b2361941afa7157ef74216703395b14e319a busybox-1.23.2.tar.bz2
81957f1fe0c386120dad1c8174ccc1fcfeed98c14d229db7d164d4fb4c938b3d bbsuid.c
@@ -157,11 +150,8 @@ ac2cd5fed91bfaec22ed1f2766396d0feb29b9b96f20b2c12d5d8ac8769afae9 0001-linedit-d
043963183cad556bdae5d5608180f0cb76cf7eede175cd97aa002a787780500f 1000-fbsplash-use-virtual-y-size-in-mmap-size-calculation.patch
b8b0b16ed67b0159256193b1d2108b8ef9aa8a334ab81e463bb970c71257da9a 1001-fbsplash-support-console-switching.patch
e1f3fad8e21dfd72cfcae7ab3ba31d7938e964e0f9ec08b2da0b14d462435424 1002-fbsplash-support-image-and-bar-alignment-and-positio.patch
-e7ddd2638508993ea1af12f62019059fdbbe58c9d2b90828aeb29940d0dbec40 2001-depmod-simple-memory-optimization.patch
-6b036423ce658c4dd0245790e897c16ee381404ede98a140dd30862ce015f8fe 2002-modutils-merge-module_entry-and-module_info-to-commo.patch
-7b0ce57084e7ae08442df97b5bcd2dcf590468230b01b7bccc171a39cb2422d4 2003-depmod-support-generating-kmod-binary-index-files.patch
f7cbeb5a5a47395ad30454ce8262abcd3e91c33ef803c2ae31a9258d7142dd48 acpid.logrotate
-b96d55f2bf8b516b52a9ef0633901adb346b372f757455a3feaa9126ecb611e8 busyboxconfig
+41e65ccc2994877a5efc05ff7a9f18f1a582cc32b6a6e0278b6a24d4fde47eea busyboxconfig
c604ef791c31d35a8c5ee4558d21428a46f37a6d762c4a7e29864f4037fc44a0 glibc.patch"
sha512sums="209c8ef26e40ccb81510f6b663202b080f9bbecac7faf386bbabf7e36a43d63b15dd6ce9f7a84c1ccc5345c524999812251da1e113ef9faadc6af1fedd24c7c9 busybox-1.23.2.tar.bz2
16b3dd6a8b76b062d51458351fcb44f84b49eb4bf898584c933df90fb2cb3966f9547865a4d7447589bb20b7c203beb04ff7512f76f85d29138d2cff4eb9ee81 bbsuid.c
@@ -178,9 +168,6 @@ a35b66cd28b79ccc14b47315ac94677fdf8c14d8a6e8956707e71fb50d453dfc5b4b822832cd1fae
2a8e9360e1cedd26bdb70d8cc036ef0abc7588bf2eee147c1c7436d7a40763f8e31d346b980145a36649130a2f811d299e4f46f7e1b60a8165a60ae9e79727d5 1000-fbsplash-use-virtual-y-size-in-mmap-size-calculation.patch
a181dd54e8e11cf1199edb1b1fcd4b7402bbf142593b6014f32c6815bb7093b56899ad0fcc9f73c382f56203ac5274fb3d51fa070feb541436f23c31680f1a69 1001-fbsplash-support-console-switching.patch
c33073416f7da2805a20f3f456f869217171c8fbfdef85f4ae481307aeb1e1b5717084bbbc619010fa5500c3f3f49b6468d5c122024fcc49d637c82427a3f553 1002-fbsplash-support-image-and-bar-alignment-and-positio.patch
-53fec99360626e7029dc6c9cf12331144d099daa2b832415d656f9dad9a6124bbc3ef5df92e8b8e6e6c654bc32ed579689a83a0657b6b3106556ae3ba0973a27 2001-depmod-simple-memory-optimization.patch
-885e8692c1bc3de5c09fb28a888e4e9273b0be2c4fe15d9acb1efaad479ad8321df443651a92915fb82fa30d2737b8909862acafe909a6629639325358cc13b7 2002-modutils-merge-module_entry-and-module_info-to-commo.patch
-2c4403f2eaa372e0818dc5a4e246cf93aca1405ed1625a51b92251a5ddca45c75e8648205a9ae68e83dcead19071e76288e824fb2eaa086996a7e6d1d6960279 2003-depmod-support-generating-kmod-binary-index-files.patch
dadb4c953ebc755b88ee95c1489feb0c2d352f6e44abc716166024e6eea11ab9d10c84fad62c081775834d205cb04aa1be3c994676c88f4284495c54b9188e8b acpid.logrotate
-46bb6954e3ceac8ae9181292d3d4cb7dce84011fe0575cbc355ec0bcf7993a531fbe8223c99a26531bce551c29b5e72fdf75638f31b733e33404ec2ecdc53e4e busyboxconfig
+5f372010a75cda82bf27f218fe2131c0a707386b7eb85ecbb4ebd15cddd2706f853cac6bdc878c46be5effbe3d497f2582076ba744cf0b4123a698a11e901455 busyboxconfig
1d2739379dab1deb3eae7cffd4845300eb7d30f7343b4a1209b21a5680860d55080ad45fdefe098b249ce3040c01951fa7f0a79cd447b2d7b260eb000099d9dc glibc.patch"
diff --git a/main/busybox/busyboxconfig b/main/busybox/busyboxconfig
index 59aee42eaf..9449833599 100644
--- a/main/busybox/busyboxconfig
+++ b/main/busybox/busyboxconfig
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
# Busybox version: 1.23.2
-# Tue Aug 18 09:32:09 2015
+# Tue Aug 4 22:52:01 2015
#
CONFIG_HAVE_DOT_CONFIG=y
@@ -538,7 +538,6 @@ CONFIG_DEPMOD=y
# CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
CONFIG_FEATURE_CHECK_TAINTED_MODULE=y
CONFIG_FEATURE_MODUTILS_ALIAS=y
-CONFIG_FEATURE_MODUTILS_BIN=y
CONFIG_FEATURE_MODUTILS_SYMBOLS=y
CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"