[arch-commits] Commit in udev/trunk (4 files)
Thomas Baechler
thomas at archlinux.org
Fri Sep 12 15:04:07 UTC 2008
Date: Friday, September 12, 2008 @ 11:04:06
Author: thomas
Revision: 12291
upgpkg: udev 128-2
Added:
udev/trunk/resolve-modalias.cpp
Modified:
udev/trunk/PKGBUILD
udev/trunk/arch-udev-rules.patch
udev/trunk/load-modules.sh
-----------------------+
PKGBUILD | 31 ++++++++++++++-------
arch-udev-rules.patch | 39 ++++++++++++++++++--------
load-modules.sh | 70 +++++++++++++++++++++++++++++++-----------------
resolve-modalias.cpp | 28 +++++++++++++++++++
4 files changed, 122 insertions(+), 46 deletions(-)
Modified: PKGBUILD
===================================================================
--- PKGBUILD 2008-09-12 14:01:57 UTC (rev 12290)
+++ PKGBUILD 2008-09-12 15:04:06 UTC (rev 12291)
@@ -1,15 +1,16 @@
# $Id$
+# Maintainer: Aaron Griffin <aaron at archlinux.org>
# Maintainer: Tobias Powalowski <tpowa at archlinux.org>
# Maintainer: Thomas Bächler <thomas at archlinux.org>
pkgname=udev
pkgver=128
-pkgrel=1
+pkgrel=2
pkgdesc="The userspace dev tools (udev)"
arch=(i686 x86_64)
url="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html"
license=('GPL')
groups=('base')
-depends=('glibc' 'coreutils' 'util-linux')
+depends=('glibc' 'coreutils' 'util-linux' 'gcc-libs')
makedepends=('kernel26') #needed to build framebuffer blacklist
install=udev.install
backup=(etc/udev/udev.conf
@@ -22,11 +23,15 @@
conflicts=('initscripts<2008.02')
options=(!makeflags)
source=(http://www.kernel.org/pub/linux/utils/kernel/hotplug/$pkgname-$pkgver.tar.bz2
- 81-arch.rules load-modules.sh cdsymlinks.sh root-link.sh arch-udev-rules.patch
- readme-udev-arch.txt)
-md5sums=('a21a954bb1306bc9c6c3f27792c6e508' '610f75f2b05437b14f3bc3418f8e7f65'
- '945f6d30ab458189b3c17f8e6722da1f' '8424b78e9dd772e75b4ef90814807815'
- '2d6dc6842464f107bccc68cd505a6c31' 'c17e075cc1806bf94a3678168ddec4e1'
+ 81-arch.rules load-modules.sh resolve-modalias.cpp cdsymlinks.sh root-link.sh
+ arch-udev-rules.patch readme-udev-arch.txt)
+md5sums=('a21a954bb1306bc9c6c3f27792c6e508'
+ '610f75f2b05437b14f3bc3418f8e7f65'
+ '56177eabff2c418572dfbfbf24a65228'
+ 'd3c2eef11cd5bf2453b7b1b5330c95d2'
+ '8424b78e9dd772e75b4ef90814807815'
+ '2d6dc6842464f107bccc68cd505a6c31'
+ 'beb8ebffc3652584363804e41445ba17'
'7fc6d33bb218e752302eef0a80ff0a89')
build() {
@@ -35,11 +40,17 @@
make || return 1
make DESTDIR=$startdir/pkg install
- #Non-stock rules still go in /etc
+ # Fix pkgconfig path
+ install -d -m755 $startdir/pkg/usr/lib
+ mv $startdir/pkg/lib/pkgconfig $startdir/pkg/usr/lib
+
+ # Non-stock rules still go in /etc
install -D -m644 $startdir/src/81-arch.rules $startdir/pkg/etc/udev/rules.d/81-arch.rules
# install our module loading subsystem
install -D -m755 $startdir/src/load-modules.sh $startdir/pkg/lib/udev/load-modules.sh
+ install -d -m755 $startdir/pkg/bin
+ g++ -Wall $CXXFLAGS -o $startdir/pkg/bin/resolve-modalias $startdir/src/resolve-modalias.cpp
# install cdsymlinks.sh
install -D -m755 $startdir/src/cdsymlinks.sh $startdir/pkg/lib/udev/cdsymlinks.sh
# install root-link.sh
@@ -59,7 +70,7 @@
done
# fix standard udev rules to fit to arch
cd $startdir/pkg/lib/udev/rules.d/
- patch -Np0 -i $startdir/src/arch-udev-rules.patch || return 1
+ patch -Np1 -i $startdir/src/arch-udev-rules.patch || return 1
# disable persistent cdromsymlinks and network by default
# and move it to /etc/udev/rules.d
@@ -69,7 +80,7 @@
$startdir/pkg/etc/udev/rules.d/75-cd-aliases-generator.rules.optional
# create framebuffer blacklist
mkdir -p $startdir/pkg/etc/modprobe.d/
- for mod in $(find /lib/modules/ -name '*fb*.ko' -exec basename {} .ko \;); do
+ for mod in $(find /lib/modules/*/kernel/drivers/video -name '*fb.ko' -exec basename {} .ko \;); do
echo "blacklist $mod" >> $startdir/pkg/etc/modprobe.d/framebuffer_blacklist
done
}
Modified: arch-udev-rules.patch
===================================================================
--- arch-udev-rules.patch 2008-09-12 14:01:57 UTC (rev 12290)
+++ arch-udev-rules.patch 2008-09-12 15:04:06 UTC (rev 12291)
@@ -1,5 +1,6 @@
---- 60-persistent-storage.rules 2008-07-31 02:40:37.000000000 -0500
-+++ 60-persistent-storage.rules.arch 2008-08-27 21:09:29.000000000 -0500
+diff -Nur rules.d/60-persistent-storage.rules rules.d.arch/60-persistent-storage.rules
+--- rules.d/60-persistent-storage.rules 2008-09-12 15:59:57.000000000 +0200
++++ rules.d.arch/60-persistent-storage.rules 2008-09-12 16:00:50.000000000 +0200
@@ -10,7 +10,7 @@
SUBSYSTEM!="block", GOTO="persistent_storage_end"
@@ -9,26 +10,40 @@
# never access non-cdrom removable ide devices, the drivers are causing event loops on open()
KERNEL=="hd*[!0-9]", ATTR{removable}=="1", DRIVERS=="ide-cs|ide-floppy", GOTO="persistent_storage_end"
---- 80-drivers.rules 2008-03-15 00:05:02.000000000 +0100
-+++ 80-drivers.rules.arch 2008-03-21 21:44:28.000000000 +0100
-@@ -3,10 +3,11 @@
+diff -Nur rules.d/80-drivers.rules rules.d.arch/80-drivers.rules
+--- rules.d/80-drivers.rules 2008-09-12 15:59:57.000000000 +0200
++++ rules.d.arch/80-drivers.rules 2008-09-12 16:01:56.000000000 +0200
+@@ -2,16 +2,17 @@
+
ACTION!="add", GOTO="drivers_end"
- DRIVER!="?*", ENV{MODALIAS}=="?*", RUN{ignore_error}+="/sbin/modprobe $env{MODALIAS}"
+-DRIVER!="?*", ENV{MODALIAS}=="?*", RUN{ignore_error}+="/sbin/modprobe $env{MODALIAS}"
-SUBSYSTEM=="pnp", DRIVER!="?*", ENV{MODALIAS}!="?*", \
- RUN{ignore_error}+="/bin/sh -c '/sbin/modprobe -a $$(while read id; do echo pnp:d$$id; done < /sys$devpath/id)'"
-SUBSYSTEM=="tifm", RUN+="/sbin/modprobe --all tifm_sd tifm_ms"
-SUBSYSTEM=="memstick", RUN+="/sbin/modprobe --all ms_block mspro_block"
+-SUBSYSTEM=="mmc", RUN+="/sbin/modprobe mmc_block"
+-SUBSYSTEM=="i2o", RUN+="/sbin/modprobe i2o_block"
+-SUBSYSTEM=="ide", ATTR{media}=="tape", RUN+="/sbin/modprobe ide-scsi"
+-SUBSYSTEM=="scsi", ENV{DEVTYPE}=="scsi_device", TEST!="[module/sg]", RUN+="/sbin/modprobe sg"
+-SUBSYSTEM=="module", KERNEL=="parport_pc", RUN+="/sbin/modprobe ppdev"
++DRIVER!="?*", ENV{MODALIAS}=="?*", RUN{ignore_error}+="/lib/udev/load-modules.sh $env{MODALIAS}"
+SUBSYSTEM=="pnp", ENV{MODALIAS}!="?*", DRIVER!="?*", RUN{ignore_error}+="/bin/sh -c 'while read id; do /lib/udev/load-modules.sh pnp:d$$id; /lib/udev/load-modules.sh pnp:c$$id ; done < /sys$devpath/id'"
+SUBSYSTEM=="tifm", RUN+="/lib/udev/load-modules.sh tifm_sd"
+SUBSYSTEM=="tifm", RUN+="/lib/udev/load-modules.sh tifm_ms"
+SUBSYSTEM=="memstick", RUN+="/lib/udev/load-modules.sh ms_block"
+SUBSYSTEM=="memstick", RUN+="/lib/udev/load-modules.sh mspro_block"
- SUBSYSTEM=="mmc", RUN+="/sbin/modprobe mmc_block"
- SUBSYSTEM=="i2o", RUN+="/sbin/modprobe i2o_block"
- SUBSYSTEM=="ide", ATTR{media}=="tape", RUN+="/sbin/modprobe ide-scsi"
---- 50-udev-default.rules 2008-07-30 06:20:21.000000000 -0500
-+++ 50-udev-default.rules.arch 2008-08-29 18:22:41.000000000 -0500
++SUBSYSTEM=="mmc", RUN+="/lib/udev/load-modules.sh mmc_block"
++SUBSYSTEM=="i2o", RUN+="/lib/udev/load-modules.sh i2o_block"
++SUBSYSTEM=="ide", ATTR{media}=="tape", RUN+="/lib/udev/load-modules.sh ide-scsi"
++SUBSYSTEM=="scsi", ENV{DEVTYPE}=="scsi_device", TEST!="[module/sg]", RUN+="/lib/udev/load-modules.sh sg"
++SUBSYSTEM=="module", KERNEL=="parport_pc", RUN+="/lib/udev/load-modules.sh ppdev"
+
+ LABEL="drivers_end"
+
+diff -Nur rules.d/50-udev-default.rules rules.d.arch/50-udev-default.rules
+--- rules.d/50-udev-default.rules 2008-09-12 15:59:57.000000000 +0200
++++ rules.d.arch/50-udev-default.rules 2008-09-12 16:00:50.000000000 +0200
@@ -4,12 +4,17 @@
KERNEL=="tty[pqrstuvwxyzabcdef][0123456789abcdef]", GROUP="tty", MODE="0660", OPTIONS+="last_rule"
KERNEL=="ptmx", GROUP="tty", MODE="0666", OPTIONS+="last_rule"
@@ -50,7 +65,7 @@
KERNEL=="mwave", NAME="modems/mwave", GROUP="uucp"
KERNEL=="hvc*|hvsi*", GROUP="uucp"
@@ -21,6 +26,7 @@
- KERNEL=="mem|kmem|port", GROUP="kmem", MODE="0640"
+ KERNEL=="mem|kmem|port|nvram", GROUP="kmem", MODE="0640"
KERNEL=="ram0", SYMLINK+="ramdisk"
KERNEL=="ram1", SYMLINK+="ram"
+KERNEL=="ram[0-9]*", NAME="rd/%n", SYMLINK+="%k"
Modified: load-modules.sh
===================================================================
--- load-modules.sh 2008-09-12 14:01:57 UTC (rev 12290)
+++ load-modules.sh 2008-09-12 15:04:06 UTC (rev 12291)
@@ -1,4 +1,4 @@
-#! /bin/bash
+#!/bin/bash
# Implement blacklisting for udev-loaded modules
[ $# -ne 1 ] && exit 1
@@ -7,6 +7,10 @@
# grab modules from rc.conf
BLACKLIST="${MOD_BLACKLIST[@]}"
+MODPROBE="/sbin/modprobe"
+LOGGER="/usr/bin/logger"
+RESOLVEALIAS="/bin/resolve-modalias"
+USEBLACKLIST="--use-blacklist"
if [ -f /proc/cmdline ]; then
for cmd in $(cat /proc/cmdline); do
@@ -30,31 +34,49 @@
fi
done
-
if [ "$MOD_AUTOLOAD" = "yes" -o "$MOD_AUTOLOAD" = "YES" ]; then
- if [ -n "$BLACKLIST" ]; then
- depmods="$(/sbin/modprobe -i --show-depends $1)"
- if [ $? -ne 0 ]; then
- /usr/bin/logger -p info "cannot find module $1"
- exit 1
- fi
+ if [ -n "${BLACKLIST}" ]; then
+ # If an alias name is on the blacklist, load no modules for this device
+ if echo "${BLACKLIST}" | /bin/grep -q -e " $1 " -e "^$1 " -e " $1\$"; then
+ $LOGGER -p info -t "$(basename $0)" "Not loading module alias '$1' because it is blacklisted"
+ exit
+ fi
+ # Try to find all aliases for the module
+ mods=$($RESOLVEALIAS /lib/modules/$(uname -r)/modules.alias $1)
+ # If no modules could be found, try if the alias name is a module name
+ # In that case, omit the --use-blacklist parameter to imitate normal modprobe behaviour
+ [ -z "${mods}" ] && $MODPROBE -qni $1 && mods="$1" && USEBLACKLIST=""
+ [ -z "${mods}" ] && $LOGGER -p info -t "$(basename $0)" "'$1' is not a valid module or alias name"
+ for mod in ${mods}; do
+ # Find the module and all its dependencies
+ deps="$($MODPROBE -i --show-depends ${mod})"
+ [ $? -ne 0 ] && continue
- #sanitize our module names
- depmods="$(echo "$depmods" | sed \
- -e "s#^insmod /lib.*/\(.*\)\.ko.*#\1#g" \
- -e 's|-|_|g')"
+ #sanitize the module names
+ deps="$(echo "$deps" | sed \
+ -e "s#^insmod /lib.*/\(.*\)\.ko.*#\1#g" \
+ -e 's|-|_|g')"
+ #sanitize the blacklist
+ BLACKLIST="$(echo "$BLACKLIST" | sed -e 's|-|_|g')"
- for mod in $depmods; do
- if echo $BLACKLIST | /bin/grep "\<$mod\>" 2>&1 >/dev/null; then
- /usr/bin/logger -p info "udev load-modules: $1 is blacklisted"
- exit 1
- fi
- done
- fi
- /sbin/modprobe $1
-else
- #/usr/bin/logger -p info \
- echo \
- "udev load-modules: autoloading is disabled, not loading $1"
+ # If the module or any of its dependencies is blacklisted, don't load it
+ for dep in $deps; do
+ if echo "${BLACKLIST}" | /bin/grep -q -e " ${dep} " -e "^${dep} " -e " ${dep}\$"; then
+ if [ "${dep}" = "${mod}" ]; then
+ $LOGGER -p info -t "$(basename $0)" "Not loading module '${mod}' for alias '$1' because it is blacklisted"
+ else
+ $LOGGER -p info -t "$(basename $0)" "Not loading module '${mod}' for alias '$1' because its dependency '${dep}' is blacklisted"
+ fi
+ continue 2
+ fi
+ done
+ # modprobe usually uses the "blacklist" statements from modprobe.conf only to blacklist all aliases
+ # of a module, but not the module itself. We use --use-blacklist here so that modprobe also blacklists
+ # module names if we resolved alias names manually above
+ $MODPROBE $USEBLACKLIST ${mod}
+ done
+ else
+ $MODPROBE $1
+ fi
fi
# vim: set et ts=4:
Added: resolve-modalias.cpp
===================================================================
--- resolve-modalias.cpp (rev 0)
+++ resolve-modalias.cpp 2008-09-12 15:04:06 UTC (rev 12291)
@@ -0,0 +1,28 @@
+#include <fstream>
+#include <fnmatch.h>
+#include <string>
+#include <iostream>
+
+using std::ifstream;
+using std::string;
+using std::cout;
+using std::endl;
+
+int main(int argc, char *argv[]) {
+ ifstream f(argv[1]);
+ string line, pattern, module;
+ size_t pos1, pos2;
+
+ while(getline(f, line)) {
+ pos1 = line.find(' ');
+ if(line.substr(0,pos1) == "alias") {
+ pos2 = line.find(' ',++pos1);
+ pattern = line.substr(pos1,pos2-pos1);
+ module = line.substr(pos2+1);
+
+ if(!fnmatch(pattern.c_str(), argv[2], 0))
+ cout << module << endl;
+ }
+ }
+ return 0;
+}
More information about the arch-commits
mailing list