[arch-commits] Commit in kmod/repos (14 files)

Dave Reisner dreisner at archlinux.org
Tue Jan 31 05:23:46 UTC 2012


    Date: Tuesday, January 31, 2012 @ 00:23:46
  Author: dreisner
Revision: 148396

archrelease: copy trunk to testing-i686, testing-x86_64

Added:
  kmod/repos/testing-i686/
  kmod/repos/testing-i686/0001-partially-fix-parsing-of-alias-with-dots.patch
    (from rev 148395, kmod/trunk/0001-partially-fix-parsing-of-alias-with-dots.patch)
  kmod/repos/testing-i686/0002-libkmod-module-used-shared-code-in-module-creation.patch
    (from rev 148395, kmod/trunk/0002-libkmod-module-used-shared-code-in-module-creation.patch)
  kmod/repos/testing-i686/0003-modprobe-handle-all-error-returns-from-init_module.patch
    (from rev 148395, kmod/trunk/0003-modprobe-handle-all-error-returns-from-init_module.patch)
  kmod/repos/testing-i686/0004-modprobe-remove-0-refcnt-deps.patch
    (from rev 148395, kmod/trunk/0004-modprobe-remove-0-refcnt-deps.patch)
  kmod/repos/testing-i686/PKGBUILD
    (from rev 148395, kmod/trunk/PKGBUILD)
  kmod/repos/testing-i686/depmod-search.conf
    (from rev 148395, kmod/trunk/depmod-search.conf)
  kmod/repos/testing-x86_64/
  kmod/repos/testing-x86_64/0001-partially-fix-parsing-of-alias-with-dots.patch
    (from rev 148395, kmod/trunk/0001-partially-fix-parsing-of-alias-with-dots.patch)
  kmod/repos/testing-x86_64/0002-libkmod-module-used-shared-code-in-module-creation.patch
    (from rev 148395, kmod/trunk/0002-libkmod-module-used-shared-code-in-module-creation.patch)
  kmod/repos/testing-x86_64/0003-modprobe-handle-all-error-returns-from-init_module.patch
    (from rev 148395, kmod/trunk/0003-modprobe-handle-all-error-returns-from-init_module.patch)
  kmod/repos/testing-x86_64/0004-modprobe-remove-0-refcnt-deps.patch
    (from rev 148395, kmod/trunk/0004-modprobe-remove-0-refcnt-deps.patch)
  kmod/repos/testing-x86_64/PKGBUILD
    (from rev 148395, kmod/trunk/PKGBUILD)
  kmod/repos/testing-x86_64/depmod-search.conf
    (from rev 148395, kmod/trunk/depmod-search.conf)

------------------------------------------------------------------------------+
 testing-i686/0001-partially-fix-parsing-of-alias-with-dots.patch             |   34 +
 testing-i686/0002-libkmod-module-used-shared-code-in-module-creation.patch   |  196 ++++++++++
 testing-i686/0003-modprobe-handle-all-error-returns-from-init_module.patch   |   34 +
 testing-i686/0004-modprobe-remove-0-refcnt-deps.patch                        |   52 ++
 testing-i686/PKGBUILD                                                        |   69 +++
 testing-i686/depmod-search.conf                                              |    5 
 testing-x86_64/0001-partially-fix-parsing-of-alias-with-dots.patch           |   34 +
 testing-x86_64/0002-libkmod-module-used-shared-code-in-module-creation.patch |  196 ++++++++++
 testing-x86_64/0003-modprobe-handle-all-error-returns-from-init_module.patch |   34 +
 testing-x86_64/0004-modprobe-remove-0-refcnt-deps.patch                      |   52 ++
 testing-x86_64/PKGBUILD                                                      |   69 +++
 testing-x86_64/depmod-search.conf                                            |    5 
 12 files changed, 780 insertions(+)

Copied: kmod/repos/testing-i686/0001-partially-fix-parsing-of-alias-with-dots.patch (from rev 148395, kmod/trunk/0001-partially-fix-parsing-of-alias-with-dots.patch)
===================================================================
--- testing-i686/0001-partially-fix-parsing-of-alias-with-dots.patch	                        (rev 0)
+++ testing-i686/0001-partially-fix-parsing-of-alias-with-dots.patch	2012-01-31 05:23:46 UTC (rev 148396)
@@ -0,0 +1,34 @@
+From cdaf4b2f3ef60365c6b8006a63410368a7b38f39 Mon Sep 17 00:00:00 2001
+From: Dave Reisner <dreisner at archlinux.org>
+Date: Tue, 31 Jan 2012 00:12:32 -0500
+Subject: [PATCH 1/4] partially fix parsing of alias with dots
+
+---
+ libkmod/libkmod-util.c |    4 +---
+ 1 files changed, 1 insertions(+), 3 deletions(-)
+
+diff --git a/libkmod/libkmod-util.c b/libkmod/libkmod-util.c
+index 7c2611b..6a9f697 100644
+--- a/libkmod/libkmod-util.c
++++ b/libkmod/libkmod-util.c
+@@ -134,8 +134,7 @@ inline int alias_normalize(const char *alias, char buf[PATH_MAX], size_t *len)
+ 		case ']':
+ 			return -EINVAL;
+ 		case '[':
+-			while (alias[s] != ']' &&
+-					alias[s] != '.' && alias[s] != '\0')
++			while (alias[s] != ']' && alias[s] != '\0')
+ 				s++;
+ 
+ 			if (alias[s] != ']')
+@@ -144,7 +143,6 @@ inline int alias_normalize(const char *alias, char buf[PATH_MAX], size_t *len)
+ 			s++;
+ 			break;
+ 		case '\0':
+-		case '.':
+ 			goto finish;
+ 		default:
+ 			buf[s] = c;
+-- 
+1.7.9
+

Copied: kmod/repos/testing-i686/0002-libkmod-module-used-shared-code-in-module-creation.patch (from rev 148395, kmod/trunk/0002-libkmod-module-used-shared-code-in-module-creation.patch)
===================================================================
--- testing-i686/0002-libkmod-module-used-shared-code-in-module-creation.patch	                        (rev 0)
+++ testing-i686/0002-libkmod-module-used-shared-code-in-module-creation.patch	2012-01-31 05:23:46 UTC (rev 148396)
@@ -0,0 +1,196 @@
+From 1d2f64689b2456ade81d6d489c4f5bfb5fdb92fd Mon Sep 17 00:00:00 2001
+From: Dave Reisner <dreisner at archlinux.org>
+Date: Tue, 31 Jan 2012 00:13:43 -0500
+Subject: [PATCH 2/4] libkmod-module: used shared code in module creation
+
+---
+ libkmod/libkmod-module.c |  135 ++++++++++++++++++++++++++-------------------
+ 1 files changed, 78 insertions(+), 57 deletions(-)
+
+diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
+index 47b1709..48e4aa1 100644
+--- a/libkmod/libkmod-module.c
++++ b/libkmod/libkmod-module.c
+@@ -162,6 +162,76 @@ fail:
+ 	return err;
+ }
+ 
++/*
++ * Memory layout with alias:
++ *
++ * struct kmod_module {
++ *        hashkey -----.
++ *        alias -----. |
++ *        name ----. | |
++ * }               | | |
++ * name <----------' | |
++ * alias <-----------' |
++ * name\alias <--------'
++ *
++ * Memory layout without alias:
++ *
++ * struct kmod_module {
++ *        hashkey ---.
++ *        alias -----|----> NULL
++ *        name ----. |
++ * }               | |
++ * name <----------'-'
++ *
++ * @key is "name\alias" or "name" (in which case alias == NULL)
++ */
++static int kmod_module_new(struct kmod_ctx *ctx, const char *key,
++				const char *name, size_t namelen,
++				const char *alias, size_t aliaslen,
++				struct kmod_module **mod)
++{
++	struct kmod_module *m;
++	size_t keylen;
++
++	m = kmod_pool_get_module(ctx, key);
++	if (m != NULL) {
++		*mod = kmod_module_ref(m);
++		return 0;
++	}
++
++	if (alias == NULL)
++		keylen = namelen;
++	else
++		keylen = namelen + aliaslen + 1;
++
++	m = malloc(sizeof(*m) + (alias == NULL ? 1 : 2) * (keylen + 1));
++	if (m == NULL) {
++		free(m);
++		return -ENOMEM;
++	}
++
++	memset(m, 0, sizeof(*m));
++
++	m->ctx = kmod_ref(ctx);
++	m->name = (char *)m + sizeof(*m);
++	memcpy(m->name, key, keylen + 1);
++	if (alias == NULL) {
++		m->hashkey = m->name;
++		m->alias = NULL;
++	} else {
++		m->name[namelen] = '\0';
++		m->alias = m->name + namelen + 1;
++		m->hashkey = m->name + keylen + 1;
++		memcpy(m->hashkey, key, keylen + 1);
++	}
++
++	m->refcount = 1;
++	kmod_pool_add_module(ctx, m, m->hashkey);
++	*mod = m;
++
++	return 0;
++}
++
+ /**
+  * kmod_module_new_from_name:
+  * @ctx: kmod library context
+@@ -188,54 +258,15 @@ KMOD_EXPORT int kmod_module_new_from_name(struct kmod_ctx *ctx,
+ 						const char *name,
+ 						struct kmod_module **mod)
+ {
+-	struct kmod_module *m;
+ 	size_t namelen;
+ 	char name_norm[PATH_MAX];
+-	char *namesep;
+ 
+ 	if (ctx == NULL || name == NULL || mod == NULL)
+ 		return -ENOENT;
+ 
+-	if (alias_normalize(name, name_norm, &namelen) < 0) {
+-		DBG(ctx, "invalid alias: %s\n", name);
+-		return -EINVAL;
+-	}
++	modname_normalize(name, name_norm, &namelen);
+ 
+-	m = kmod_pool_get_module(ctx, name_norm);
+-	if (m != NULL) {
+-		*mod = kmod_module_ref(m);
+-		return 0;
+-	}
+-
+-	namesep = strchr(name_norm, '/');
+-	m = malloc(sizeof(*m) + (namesep == NULL ? 1 : 2) * namelen + 2);
+-	if (m == NULL) {
+-		free(m);
+-		return -ENOMEM;
+-	}
+-
+-	memset(m, 0, sizeof(*m));
+-
+-	m->ctx = kmod_ref(ctx);
+-	m->name = (char *)m + sizeof(*m);
+-	memcpy(m->name, name_norm, namelen + 1);
+-
+-	if (namesep) {
+-		size_t len = namesep - name_norm;
+-
+-		m->name[len] = '\0';
+-		m->alias = m->name + len + 1;
+-		m->hashkey = m->name + namelen + 1;
+-		memcpy(m->hashkey, name_norm, namelen + 1);
+-	} else {
+-		m->hashkey = m->name;
+-	}
+-
+-	m->refcount = 1;
+-	kmod_pool_add_module(ctx, m, m->hashkey);
+-	*mod = m;
+-
+-	return 0;
++	return kmod_module_new(ctx, name_norm, name_norm, namelen, NULL, 0, mod);
+ }
+ 
+ int kmod_module_new_from_alias(struct kmod_ctx *ctx, const char *alias,
+@@ -251,9 +282,9 @@ int kmod_module_new_from_alias(struct kmod_ctx *ctx, const char *alias,
+ 
+ 	memcpy(key, name, namelen);
+ 	memcpy(key + namelen + 1, alias, aliaslen + 1);
+-	key[namelen] = '/';
++	key[namelen] = '\\';
+ 
+-	err = kmod_module_new_from_name(ctx, key, mod);
++	err = kmod_module_new(ctx, key, name, namelen, alias, aliaslen, mod);
+ 	if (err < 0)
+ 		return err;
+ 
+@@ -323,7 +354,7 @@ KMOD_EXPORT int kmod_module_new_from_path(struct kmod_ctx *ctx,
+ 			free(abspath);
+ 		else {
+ 			ERR(ctx, "kmod_module '%s' already exists with different path: new-path='%s' old-path='%s'\n",
+-									name, abspath, m->path);
++							name, abspath, m->path);
+ 			free(abspath);
+ 			return -EEXIST;
+ 		}
+@@ -332,21 +363,11 @@ KMOD_EXPORT int kmod_module_new_from_path(struct kmod_ctx *ctx,
+ 		return 0;
+ 	}
+ 
+-	m = malloc(sizeof(*m) + namelen + 1);
+-	if (m == NULL)
+-		return -errno;
+-
+-	memset(m, 0, sizeof(*m));
++	err = kmod_module_new(ctx, name, name, namelen, NULL, 0, &m);
++	if (err < 0)
++		return err;
+ 
+-	m->ctx = kmod_ref(ctx);
+-	m->name = (char *)m + sizeof(*m);
+-	memcpy(m->name, name, namelen + 1);
+ 	m->path = abspath;
+-	m->hashkey = m->name;
+-	m->refcount = 1;
+-
+-	kmod_pool_add_module(ctx, m, m->hashkey);
+-
+ 	*mod = m;
+ 
+ 	return 0;
+-- 
+1.7.9
+

Copied: kmod/repos/testing-i686/0003-modprobe-handle-all-error-returns-from-init_module.patch (from rev 148395, kmod/trunk/0003-modprobe-handle-all-error-returns-from-init_module.patch)
===================================================================
--- testing-i686/0003-modprobe-handle-all-error-returns-from-init_module.patch	                        (rev 0)
+++ testing-i686/0003-modprobe-handle-all-error-returns-from-init_module.patch	2012-01-31 05:23:46 UTC (rev 148396)
@@ -0,0 +1,34 @@
+From fdf78d80d298353c29e1fe8c00602669dd9662bb Mon Sep 17 00:00:00 2001
+From: Dave Reisner <dreisner at archlinux.org>
+Date: Mon, 30 Jan 2012 23:05:26 -0500
+Subject: [PATCH 3/4] modprobe: handle all error returns from init_module
+
+---
+ tools/kmod-modprobe.c |    4 +++-
+ 1 files changed, 3 insertions(+), 1 deletions(-)
+
+diff --git a/tools/kmod-modprobe.c b/tools/kmod-modprobe.c
+index 3e51506..c882856 100644
+--- a/tools/kmod-modprobe.c
++++ b/tools/kmod-modprobe.c
+@@ -551,6 +551,8 @@ static int insmod_do_insert_module(struct kmod_module *mod, const char *opts)
+ 
+ 	err = kmod_module_insert_module(mod, flags, opts);
+ 	switch (err) {
++	case 0:
++		break;
+ 	case -EEXIST:
+ 		/*
+ 		 * We checked for EEXIST with an earlier call to
+@@ -564,7 +566,7 @@ static int insmod_do_insert_module(struct kmod_module *mod, const char *opts)
+ 			ERR("Module %s already in kernel.\n",
+ 					kmod_module_get_name(mod));
+ 		break;
+-	case -EPERM:
++	default:
+ 		ERR("could not insert '%s': %s\n", kmod_module_get_name(mod),
+ 				strerror(-err));
+ 		break;
+-- 
+1.7.9
+

Copied: kmod/repos/testing-i686/0004-modprobe-remove-0-refcnt-deps.patch (from rev 148395, kmod/trunk/0004-modprobe-remove-0-refcnt-deps.patch)
===================================================================
--- testing-i686/0004-modprobe-remove-0-refcnt-deps.patch	                        (rev 0)
+++ testing-i686/0004-modprobe-remove-0-refcnt-deps.patch	2012-01-31 05:23:46 UTC (rev 148396)
@@ -0,0 +1,52 @@
+From 4e3dd21aff55b5bbaa08b037fc2a5625bfffc0a5 Mon Sep 17 00:00:00 2001
+From: Dave Reisner <dreisner at archlinux.org>
+Date: Mon, 30 Jan 2012 23:39:30 -0500
+Subject: [PATCH 4/4] modprobe: remove 0 refcnt deps
+
+---
+ tools/kmod-modprobe.c |   15 +++++++++++++--
+ 1 files changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/tools/kmod-modprobe.c b/tools/kmod-modprobe.c
+index c882856..bd991a5 100644
+--- a/tools/kmod-modprobe.c
++++ b/tools/kmod-modprobe.c
+@@ -381,7 +381,7 @@ static int rmmod_do_deps_list(struct kmod_list *list, bool stop_on_errors)
+ static int rmmod_do_module(struct kmod_module *mod, bool do_dependencies)
+ {
+ 	const char *modname = kmod_module_get_name(mod);
+-	struct kmod_list *pre = NULL, *post = NULL;
++	struct kmod_list *pre = NULL, *post = NULL, *deps, *itr;
+ 	const char *cmd = NULL;
+ 	int err;
+ 
+@@ -422,7 +422,7 @@ static int rmmod_do_module(struct kmod_module *mod, bool do_dependencies)
+ 	rmmod_do_deps_list(post, false);
+ 
+ 	if (do_dependencies && remove_dependencies) {
+-		struct kmod_list *deps = kmod_module_get_dependencies(mod);
++		deps = kmod_module_get_dependencies(mod);
+ 
+ 		err = rmmod_do_deps_list(deps, true);
+ 		if (err < 0)
+@@ -451,6 +451,17 @@ static int rmmod_do_module(struct kmod_module *mod, bool do_dependencies)
+ 
+ 	rmmod_do_deps_list(pre, false);
+ 
++	deps = kmod_module_get_dependencies(mod);
++	if (deps != NULL) {
++		kmod_list_foreach_reverse(itr, deps) {
++			struct kmod_module *dep = kmod_module_get_module(itr);
++			if (kmod_module_get_refcnt(dep) == 0)
++				rmmod_do_remove_module(dep);
++			kmod_module_unref(dep);
++		}
++		kmod_module_unref_list(deps);
++	}
++
+ error:
+ 	kmod_module_unref_list(pre);
+ 	kmod_module_unref_list(post);
+-- 
+1.7.9
+

Copied: kmod/repos/testing-i686/PKGBUILD (from rev 148395, kmod/trunk/PKGBUILD)
===================================================================
--- testing-i686/PKGBUILD	                        (rev 0)
+++ testing-i686/PKGBUILD	2012-01-31 05:23:46 UTC (rev 148396)
@@ -0,0 +1,69 @@
+# $Id$
+# Maintainer: Dave Reisner <dreisner at archlinux.org>
+
+pkgname=kmod
+pkgver=4
+pkgrel=2
+pkgdesc="Linux kernel module handling"
+arch=('i686' 'x86_64')
+url="http://git.profusion.mobi/cgit.cgi/kmod.git"
+license=('GPL2')
+depends=('glibc' 'zlib')
+makedepends=('docbook2x')
+options=('!libtool')
+provides=('module-init-tools=3.16')
+conflicts=('module-init-tools')
+replaces=('module-init-tools')
+source=("http://packages.profusion.mobi/$pkgname/$pkgname-$pkgver.tar.xz"
+        0001-partially-fix-parsing-of-alias-with-dots.patch
+        0002-libkmod-module-used-shared-code-in-module-creation.patch
+        0003-modprobe-handle-all-error-returns-from-init_module.patch
+        0004-modprobe-remove-0-refcnt-deps.patch
+        "depmod-search.conf")
+md5sums=('e14450a066a48accd0af1995b3c0232d'
+         '5f497ab3466ee1a616b6e6c97b330706'
+         '23a9257a152862753ce4c4ee7287761a'
+         '3a57671b0f37b1203b207f35a4442ae3'
+         '1fe88eee9302104b179124ce6bfc55d2'
+         '4b8cbcbc54b9029c99fd730e257d4436')
+
+build() {
+  cd "$pkgname-$pkgver"
+
+  patch -Np1 <"$srcdir/0001-partially-fix-parsing-of-alias-with-dots.patch"
+  patch -Np1 <"$srcdir/0002-libkmod-module-used-shared-code-in-module-creation.patch"
+  patch -Np1 <"$srcdir/0003-modprobe-handle-all-error-returns-from-init_module.patch"
+  patch -Np1 <"$srcdir/0004-modprobe-remove-0-refcnt-deps.patch"
+
+  ./configure \
+    --sysconfdir=/etc \
+    --with-rootprefix= \
+    --with-zlib
+
+  make
+}
+
+check() {
+  make -C "$pkgname-$pkgver" check
+}
+
+package() {
+  make -C "$pkgname-$pkgver" DESTDIR="$pkgdir" install
+
+  # binary directories
+  install -dm755 "$pkgdir"/{,s}bin
+
+  # configuration directories
+  install -dm755 "$pkgdir"/{etc,lib}/{depmod,modprobe}.d
+
+  # add symlinks to kmod
+  ln -s /usr/bin/kmod "$pkgdir/bin/lsmod"
+  for tool in {ins,rm,dep}mod mod{info,probe}; do
+    ln -s ../usr/bin/kmod "$pkgdir/sbin/$tool"
+  done
+
+  # install depmod.d file for search/ dir
+  install -Dm644 "$srcdir/depmod-search.conf" "$pkgdir/lib/depmod.d/search.conf"
+}
+
+# vim: ft=sh syn=sh et

Copied: kmod/repos/testing-i686/depmod-search.conf (from rev 148395, kmod/trunk/depmod-search.conf)
===================================================================
--- testing-i686/depmod-search.conf	                        (rev 0)
+++ testing-i686/depmod-search.conf	2012-01-31 05:23:46 UTC (rev 148396)
@@ -0,0 +1,5 @@
+#
+# /etc/depmod.d/depmod.conf
+#
+
+search updates extramodules built-in

Copied: kmod/repos/testing-x86_64/0001-partially-fix-parsing-of-alias-with-dots.patch (from rev 148395, kmod/trunk/0001-partially-fix-parsing-of-alias-with-dots.patch)
===================================================================
--- testing-x86_64/0001-partially-fix-parsing-of-alias-with-dots.patch	                        (rev 0)
+++ testing-x86_64/0001-partially-fix-parsing-of-alias-with-dots.patch	2012-01-31 05:23:46 UTC (rev 148396)
@@ -0,0 +1,34 @@
+From cdaf4b2f3ef60365c6b8006a63410368a7b38f39 Mon Sep 17 00:00:00 2001
+From: Dave Reisner <dreisner at archlinux.org>
+Date: Tue, 31 Jan 2012 00:12:32 -0500
+Subject: [PATCH 1/4] partially fix parsing of alias with dots
+
+---
+ libkmod/libkmod-util.c |    4 +---
+ 1 files changed, 1 insertions(+), 3 deletions(-)
+
+diff --git a/libkmod/libkmod-util.c b/libkmod/libkmod-util.c
+index 7c2611b..6a9f697 100644
+--- a/libkmod/libkmod-util.c
++++ b/libkmod/libkmod-util.c
+@@ -134,8 +134,7 @@ inline int alias_normalize(const char *alias, char buf[PATH_MAX], size_t *len)
+ 		case ']':
+ 			return -EINVAL;
+ 		case '[':
+-			while (alias[s] != ']' &&
+-					alias[s] != '.' && alias[s] != '\0')
++			while (alias[s] != ']' && alias[s] != '\0')
+ 				s++;
+ 
+ 			if (alias[s] != ']')
+@@ -144,7 +143,6 @@ inline int alias_normalize(const char *alias, char buf[PATH_MAX], size_t *len)
+ 			s++;
+ 			break;
+ 		case '\0':
+-		case '.':
+ 			goto finish;
+ 		default:
+ 			buf[s] = c;
+-- 
+1.7.9
+

Copied: kmod/repos/testing-x86_64/0002-libkmod-module-used-shared-code-in-module-creation.patch (from rev 148395, kmod/trunk/0002-libkmod-module-used-shared-code-in-module-creation.patch)
===================================================================
--- testing-x86_64/0002-libkmod-module-used-shared-code-in-module-creation.patch	                        (rev 0)
+++ testing-x86_64/0002-libkmod-module-used-shared-code-in-module-creation.patch	2012-01-31 05:23:46 UTC (rev 148396)
@@ -0,0 +1,196 @@
+From 1d2f64689b2456ade81d6d489c4f5bfb5fdb92fd Mon Sep 17 00:00:00 2001
+From: Dave Reisner <dreisner at archlinux.org>
+Date: Tue, 31 Jan 2012 00:13:43 -0500
+Subject: [PATCH 2/4] libkmod-module: used shared code in module creation
+
+---
+ libkmod/libkmod-module.c |  135 ++++++++++++++++++++++++++-------------------
+ 1 files changed, 78 insertions(+), 57 deletions(-)
+
+diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
+index 47b1709..48e4aa1 100644
+--- a/libkmod/libkmod-module.c
++++ b/libkmod/libkmod-module.c
+@@ -162,6 +162,76 @@ fail:
+ 	return err;
+ }
+ 
++/*
++ * Memory layout with alias:
++ *
++ * struct kmod_module {
++ *        hashkey -----.
++ *        alias -----. |
++ *        name ----. | |
++ * }               | | |
++ * name <----------' | |
++ * alias <-----------' |
++ * name\alias <--------'
++ *
++ * Memory layout without alias:
++ *
++ * struct kmod_module {
++ *        hashkey ---.
++ *        alias -----|----> NULL
++ *        name ----. |
++ * }               | |
++ * name <----------'-'
++ *
++ * @key is "name\alias" or "name" (in which case alias == NULL)
++ */
++static int kmod_module_new(struct kmod_ctx *ctx, const char *key,
++				const char *name, size_t namelen,
++				const char *alias, size_t aliaslen,
++				struct kmod_module **mod)
++{
++	struct kmod_module *m;
++	size_t keylen;
++
++	m = kmod_pool_get_module(ctx, key);
++	if (m != NULL) {
++		*mod = kmod_module_ref(m);
++		return 0;
++	}
++
++	if (alias == NULL)
++		keylen = namelen;
++	else
++		keylen = namelen + aliaslen + 1;
++
++	m = malloc(sizeof(*m) + (alias == NULL ? 1 : 2) * (keylen + 1));
++	if (m == NULL) {
++		free(m);
++		return -ENOMEM;
++	}
++
++	memset(m, 0, sizeof(*m));
++
++	m->ctx = kmod_ref(ctx);
++	m->name = (char *)m + sizeof(*m);
++	memcpy(m->name, key, keylen + 1);
++	if (alias == NULL) {
++		m->hashkey = m->name;
++		m->alias = NULL;
++	} else {
++		m->name[namelen] = '\0';
++		m->alias = m->name + namelen + 1;
++		m->hashkey = m->name + keylen + 1;
++		memcpy(m->hashkey, key, keylen + 1);
++	}
++
++	m->refcount = 1;
++	kmod_pool_add_module(ctx, m, m->hashkey);
++	*mod = m;
++
++	return 0;
++}
++
+ /**
+  * kmod_module_new_from_name:
+  * @ctx: kmod library context
+@@ -188,54 +258,15 @@ KMOD_EXPORT int kmod_module_new_from_name(struct kmod_ctx *ctx,
+ 						const char *name,
+ 						struct kmod_module **mod)
+ {
+-	struct kmod_module *m;
+ 	size_t namelen;
+ 	char name_norm[PATH_MAX];
+-	char *namesep;
+ 
+ 	if (ctx == NULL || name == NULL || mod == NULL)
+ 		return -ENOENT;
+ 
+-	if (alias_normalize(name, name_norm, &namelen) < 0) {
+-		DBG(ctx, "invalid alias: %s\n", name);
+-		return -EINVAL;
+-	}
++	modname_normalize(name, name_norm, &namelen);
+ 
+-	m = kmod_pool_get_module(ctx, name_norm);
+-	if (m != NULL) {
+-		*mod = kmod_module_ref(m);
+-		return 0;
+-	}
+-
+-	namesep = strchr(name_norm, '/');
+-	m = malloc(sizeof(*m) + (namesep == NULL ? 1 : 2) * namelen + 2);
+-	if (m == NULL) {
+-		free(m);
+-		return -ENOMEM;
+-	}
+-
+-	memset(m, 0, sizeof(*m));
+-
+-	m->ctx = kmod_ref(ctx);
+-	m->name = (char *)m + sizeof(*m);
+-	memcpy(m->name, name_norm, namelen + 1);
+-
+-	if (namesep) {
+-		size_t len = namesep - name_norm;
+-
+-		m->name[len] = '\0';
+-		m->alias = m->name + len + 1;
+-		m->hashkey = m->name + namelen + 1;
+-		memcpy(m->hashkey, name_norm, namelen + 1);
+-	} else {
+-		m->hashkey = m->name;
+-	}
+-
+-	m->refcount = 1;
+-	kmod_pool_add_module(ctx, m, m->hashkey);
+-	*mod = m;
+-
+-	return 0;
++	return kmod_module_new(ctx, name_norm, name_norm, namelen, NULL, 0, mod);
+ }
+ 
+ int kmod_module_new_from_alias(struct kmod_ctx *ctx, const char *alias,
+@@ -251,9 +282,9 @@ int kmod_module_new_from_alias(struct kmod_ctx *ctx, const char *alias,
+ 
+ 	memcpy(key, name, namelen);
+ 	memcpy(key + namelen + 1, alias, aliaslen + 1);
+-	key[namelen] = '/';
++	key[namelen] = '\\';
+ 
+-	err = kmod_module_new_from_name(ctx, key, mod);
++	err = kmod_module_new(ctx, key, name, namelen, alias, aliaslen, mod);
+ 	if (err < 0)
+ 		return err;
+ 
+@@ -323,7 +354,7 @@ KMOD_EXPORT int kmod_module_new_from_path(struct kmod_ctx *ctx,
+ 			free(abspath);
+ 		else {
+ 			ERR(ctx, "kmod_module '%s' already exists with different path: new-path='%s' old-path='%s'\n",
+-									name, abspath, m->path);
++							name, abspath, m->path);
+ 			free(abspath);
+ 			return -EEXIST;
+ 		}
+@@ -332,21 +363,11 @@ KMOD_EXPORT int kmod_module_new_from_path(struct kmod_ctx *ctx,
+ 		return 0;
+ 	}
+ 
+-	m = malloc(sizeof(*m) + namelen + 1);
+-	if (m == NULL)
+-		return -errno;
+-
+-	memset(m, 0, sizeof(*m));
++	err = kmod_module_new(ctx, name, name, namelen, NULL, 0, &m);
++	if (err < 0)
++		return err;
+ 
+-	m->ctx = kmod_ref(ctx);
+-	m->name = (char *)m + sizeof(*m);
+-	memcpy(m->name, name, namelen + 1);
+ 	m->path = abspath;
+-	m->hashkey = m->name;
+-	m->refcount = 1;
+-
+-	kmod_pool_add_module(ctx, m, m->hashkey);
+-
+ 	*mod = m;
+ 
+ 	return 0;
+-- 
+1.7.9
+

Copied: kmod/repos/testing-x86_64/0003-modprobe-handle-all-error-returns-from-init_module.patch (from rev 148395, kmod/trunk/0003-modprobe-handle-all-error-returns-from-init_module.patch)
===================================================================
--- testing-x86_64/0003-modprobe-handle-all-error-returns-from-init_module.patch	                        (rev 0)
+++ testing-x86_64/0003-modprobe-handle-all-error-returns-from-init_module.patch	2012-01-31 05:23:46 UTC (rev 148396)
@@ -0,0 +1,34 @@
+From fdf78d80d298353c29e1fe8c00602669dd9662bb Mon Sep 17 00:00:00 2001
+From: Dave Reisner <dreisner at archlinux.org>
+Date: Mon, 30 Jan 2012 23:05:26 -0500
+Subject: [PATCH 3/4] modprobe: handle all error returns from init_module
+
+---
+ tools/kmod-modprobe.c |    4 +++-
+ 1 files changed, 3 insertions(+), 1 deletions(-)
+
+diff --git a/tools/kmod-modprobe.c b/tools/kmod-modprobe.c
+index 3e51506..c882856 100644
+--- a/tools/kmod-modprobe.c
++++ b/tools/kmod-modprobe.c
+@@ -551,6 +551,8 @@ static int insmod_do_insert_module(struct kmod_module *mod, const char *opts)
+ 
+ 	err = kmod_module_insert_module(mod, flags, opts);
+ 	switch (err) {
++	case 0:
++		break;
+ 	case -EEXIST:
+ 		/*
+ 		 * We checked for EEXIST with an earlier call to
+@@ -564,7 +566,7 @@ static int insmod_do_insert_module(struct kmod_module *mod, const char *opts)
+ 			ERR("Module %s already in kernel.\n",
+ 					kmod_module_get_name(mod));
+ 		break;
+-	case -EPERM:
++	default:
+ 		ERR("could not insert '%s': %s\n", kmod_module_get_name(mod),
+ 				strerror(-err));
+ 		break;
+-- 
+1.7.9
+

Copied: kmod/repos/testing-x86_64/0004-modprobe-remove-0-refcnt-deps.patch (from rev 148395, kmod/trunk/0004-modprobe-remove-0-refcnt-deps.patch)
===================================================================
--- testing-x86_64/0004-modprobe-remove-0-refcnt-deps.patch	                        (rev 0)
+++ testing-x86_64/0004-modprobe-remove-0-refcnt-deps.patch	2012-01-31 05:23:46 UTC (rev 148396)
@@ -0,0 +1,52 @@
+From 4e3dd21aff55b5bbaa08b037fc2a5625bfffc0a5 Mon Sep 17 00:00:00 2001
+From: Dave Reisner <dreisner at archlinux.org>
+Date: Mon, 30 Jan 2012 23:39:30 -0500
+Subject: [PATCH 4/4] modprobe: remove 0 refcnt deps
+
+---
+ tools/kmod-modprobe.c |   15 +++++++++++++--
+ 1 files changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/tools/kmod-modprobe.c b/tools/kmod-modprobe.c
+index c882856..bd991a5 100644
+--- a/tools/kmod-modprobe.c
++++ b/tools/kmod-modprobe.c
+@@ -381,7 +381,7 @@ static int rmmod_do_deps_list(struct kmod_list *list, bool stop_on_errors)
+ static int rmmod_do_module(struct kmod_module *mod, bool do_dependencies)
+ {
+ 	const char *modname = kmod_module_get_name(mod);
+-	struct kmod_list *pre = NULL, *post = NULL;
++	struct kmod_list *pre = NULL, *post = NULL, *deps, *itr;
+ 	const char *cmd = NULL;
+ 	int err;
+ 
+@@ -422,7 +422,7 @@ static int rmmod_do_module(struct kmod_module *mod, bool do_dependencies)
+ 	rmmod_do_deps_list(post, false);
+ 
+ 	if (do_dependencies && remove_dependencies) {
+-		struct kmod_list *deps = kmod_module_get_dependencies(mod);
++		deps = kmod_module_get_dependencies(mod);
+ 
+ 		err = rmmod_do_deps_list(deps, true);
+ 		if (err < 0)
+@@ -451,6 +451,17 @@ static int rmmod_do_module(struct kmod_module *mod, bool do_dependencies)
+ 
+ 	rmmod_do_deps_list(pre, false);
+ 
++	deps = kmod_module_get_dependencies(mod);
++	if (deps != NULL) {
++		kmod_list_foreach_reverse(itr, deps) {
++			struct kmod_module *dep = kmod_module_get_module(itr);
++			if (kmod_module_get_refcnt(dep) == 0)
++				rmmod_do_remove_module(dep);
++			kmod_module_unref(dep);
++		}
++		kmod_module_unref_list(deps);
++	}
++
+ error:
+ 	kmod_module_unref_list(pre);
+ 	kmod_module_unref_list(post);
+-- 
+1.7.9
+

Copied: kmod/repos/testing-x86_64/PKGBUILD (from rev 148395, kmod/trunk/PKGBUILD)
===================================================================
--- testing-x86_64/PKGBUILD	                        (rev 0)
+++ testing-x86_64/PKGBUILD	2012-01-31 05:23:46 UTC (rev 148396)
@@ -0,0 +1,69 @@
+# $Id$
+# Maintainer: Dave Reisner <dreisner at archlinux.org>
+
+pkgname=kmod
+pkgver=4
+pkgrel=2
+pkgdesc="Linux kernel module handling"
+arch=('i686' 'x86_64')
+url="http://git.profusion.mobi/cgit.cgi/kmod.git"
+license=('GPL2')
+depends=('glibc' 'zlib')
+makedepends=('docbook2x')
+options=('!libtool')
+provides=('module-init-tools=3.16')
+conflicts=('module-init-tools')
+replaces=('module-init-tools')
+source=("http://packages.profusion.mobi/$pkgname/$pkgname-$pkgver.tar.xz"
+        0001-partially-fix-parsing-of-alias-with-dots.patch
+        0002-libkmod-module-used-shared-code-in-module-creation.patch
+        0003-modprobe-handle-all-error-returns-from-init_module.patch
+        0004-modprobe-remove-0-refcnt-deps.patch
+        "depmod-search.conf")
+md5sums=('e14450a066a48accd0af1995b3c0232d'
+         '5f497ab3466ee1a616b6e6c97b330706'
+         '23a9257a152862753ce4c4ee7287761a'
+         '3a57671b0f37b1203b207f35a4442ae3'
+         '1fe88eee9302104b179124ce6bfc55d2'
+         '4b8cbcbc54b9029c99fd730e257d4436')
+
+build() {
+  cd "$pkgname-$pkgver"
+
+  patch -Np1 <"$srcdir/0001-partially-fix-parsing-of-alias-with-dots.patch"
+  patch -Np1 <"$srcdir/0002-libkmod-module-used-shared-code-in-module-creation.patch"
+  patch -Np1 <"$srcdir/0003-modprobe-handle-all-error-returns-from-init_module.patch"
+  patch -Np1 <"$srcdir/0004-modprobe-remove-0-refcnt-deps.patch"
+
+  ./configure \
+    --sysconfdir=/etc \
+    --with-rootprefix= \
+    --with-zlib
+
+  make
+}
+
+check() {
+  make -C "$pkgname-$pkgver" check
+}
+
+package() {
+  make -C "$pkgname-$pkgver" DESTDIR="$pkgdir" install
+
+  # binary directories
+  install -dm755 "$pkgdir"/{,s}bin
+
+  # configuration directories
+  install -dm755 "$pkgdir"/{etc,lib}/{depmod,modprobe}.d
+
+  # add symlinks to kmod
+  ln -s /usr/bin/kmod "$pkgdir/bin/lsmod"
+  for tool in {ins,rm,dep}mod mod{info,probe}; do
+    ln -s ../usr/bin/kmod "$pkgdir/sbin/$tool"
+  done
+
+  # install depmod.d file for search/ dir
+  install -Dm644 "$srcdir/depmod-search.conf" "$pkgdir/lib/depmod.d/search.conf"
+}
+
+# vim: ft=sh syn=sh et

Copied: kmod/repos/testing-x86_64/depmod-search.conf (from rev 148395, kmod/trunk/depmod-search.conf)
===================================================================
--- testing-x86_64/depmod-search.conf	                        (rev 0)
+++ testing-x86_64/depmod-search.conf	2012-01-31 05:23:46 UTC (rev 148396)
@@ -0,0 +1,5 @@
+#
+# /etc/depmod.d/depmod.conf
+#
+
+search updates extramodules built-in




More information about the arch-commits mailing list