[arch-commits] Commit in udev/trunk (6 files)

Thomas Baechler thomas at archlinux.org
Thu Sep 18 17:27:42 UTC 2008


    Date: Thursday, September 18, 2008 @ 13:27:41
  Author: thomas
Revision: 12720

udev 128-4:
- Replaced the C++ resolve-modalias by the same C program used in klibc-extras, should gain some speed and removes the gcc-libs dependency
- Added a post_install so that /dev/{console,null,zero} are created again, so we don't break FTP installations when we move to core
- Removed driver loading from 81-arch.rules, this was done in 80-drivers.rules already
- Some minor changes to load-modules.sh

Added:
  udev/trunk/resolve-modalias.c
Modified:
  udev/trunk/81-arch.rules
  udev/trunk/PKGBUILD
  udev/trunk/load-modules.sh
  udev/trunk/udev.install
Deleted:
  udev/trunk/resolve-modalias.cpp

----------------------+
 81-arch.rules        |    1 
 PKGBUILD             |   12 ++++-----
 load-modules.sh      |   12 +++------
 resolve-modalias.c   |   62 +++++++++++++++++++++++++++++++++++++++++++++++++
 resolve-modalias.cpp |   28 ----------------------
 udev.install         |   15 +++++++++++
 6 files changed, 88 insertions(+), 42 deletions(-)

Modified: 81-arch.rules
===================================================================
--- 81-arch.rules	2008-09-18 17:02:04 UTC (rev 12719)
+++ 81-arch.rules	2008-09-18 17:27:41 UTC (rev 12720)
@@ -29,7 +29,6 @@
 #####################################
 # check if the device has already been claimed by a driver
 ACTION!="add", GOTO="drivers_end"
-DRIVER!="?*", ENV{MODALIAS}=="?*", RUN{ignore_error}+="/lib/udev/load-modules.sh $env{MODALIAS}"
 
 # SOUND addon modules
 SUBSYSTEM=="sound", RUN+="/lib/udev/load-modules.sh snd-pcm-oss"

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2008-09-18 17:02:04 UTC (rev 12719)
+++ PKGBUILD	2008-09-18 17:27:41 UTC (rev 12720)
@@ -4,13 +4,13 @@
 # Maintainer: Thomas Bächler <thomas at archlinux.org>
 pkgname=udev
 pkgver=128
-pkgrel=3
+pkgrel=4
 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' 'gcc-libs')
+depends=('glibc' 'coreutils' 'util-linux')
 makedepends=('kernel26') #needed to build framebuffer blacklist
 install=udev.install
 backup=(etc/udev/udev.conf
@@ -23,12 +23,12 @@
 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 resolve-modalias.cpp cdsymlinks.sh root-link.sh
+        81-arch.rules load-modules.sh resolve-modalias.c cdsymlinks.sh root-link.sh
         arch-udev-rules.patch readme-udev-arch.txt)
 md5sums=('a21a954bb1306bc9c6c3f27792c6e508'
-         '610f75f2b05437b14f3bc3418f8e7f65'
+         '3a955ca8e2122a48a223f9d8adf87b70'
          '56177eabff2c418572dfbfbf24a65228'
-         'd3c2eef11cd5bf2453b7b1b5330c95d2'
+         'fca04a608009069beb786e26338a783b'
          '8424b78e9dd772e75b4ef90814807815'
          '2d6dc6842464f107bccc68cd505a6c31'
          'beb8ebffc3652584363804e41445ba17'
@@ -50,7 +50,7 @@
   # 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
+  gcc -Wall $CFLAGS -o $startdir/pkg/bin/resolve-modalias $startdir/src/resolve-modalias.c
   # install cdsymlinks.sh
   install -D -m755 $startdir/src/cdsymlinks.sh $startdir/pkg/lib/udev/cdsymlinks.sh
   # install root-link.sh

Modified: load-modules.sh
===================================================================
--- load-modules.sh	2008-09-18 17:02:04 UTC (rev 12719)
+++ load-modules.sh	2008-09-18 17:27:41 UTC (rev 12720)
@@ -15,16 +15,14 @@
 if [ -f /proc/cmdline ]; then 
     for cmd in $(cat /proc/cmdline); do
         case $cmd in
-            *=*) eval $cmd ;;
+            disablemodules=*) eval $cmd ;;
+            load_modules=off) exit ;;
         esac
     done
     #parse cmdline entries of the form "disablemodules=x,y,z"
     if [ -n "$disablemodules" ]; then
         BLACKLIST="$BLACKLIST $(echo $disablemodules | sed 's|,| |g')"
     fi
-    if [ "$load_modules" == "off" ]; then
-        MOD_AUTOLOAD="no"
-    fi
 fi
 
 #MODULES entries in rc.conf that begin with ! are blacklisted
@@ -41,7 +39,9 @@
       $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
+    #sanitize the blacklist
+    BLACKLIST="$(echo "$BLACKLIST" | sed -e 's|-|_|g')"
+    # Try to find all modules for the alias
     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
@@ -56,8 +56,6 @@
       deps="$(echo "$deps" | sed \
               -e "s#^insmod /lib.*/\(.*\)\.ko.*#\1#g" \
               -e 's|-|_|g')"
-      #sanitize the blacklist
-      BLACKLIST="$(echo "$BLACKLIST" | sed -e 's|-|_|g')"
 
       # If the module or any of its dependencies is blacklisted, don't load it
       for dep in $deps; do

Added: resolve-modalias.c
===================================================================
--- resolve-modalias.c	                        (rev 0)
+++ resolve-modalias.c	2008-09-18 17:27:41 UTC (rev 12720)
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <fnmatch.h>
+#include <string.h>
+#include <malloc.h>
+
+static char *getline(FILE *file) {
+  static size_t size = 1024;
+  static char *buf = NULL;
+  static unsigned int i = 0, r = 0;;
+
+  if(buf == NULL)
+    buf = (char*)malloc(size);
+
+  if(i) {
+    memmove(buf, buf+i, size-i);
+    r -= i;
+    i = 0;
+  }
+
+  while(1) {
+    if(i == size) {
+      size *= 2;
+      buf = (char*)realloc(buf, size);
+    }
+
+    if(i==r)
+      r += fread(buf+i, 1, size-i, file);
+
+    if(i==r && i == 0) {
+      free(buf);
+      buf = NULL;
+      r = 0;
+      return NULL;
+    }
+
+    if(i==r || buf[i] == '\n') {
+      buf[i++] = '\0';
+      return buf;
+    }
+    i++;
+  }
+}
+
+int main(int argc, char *argv[]) {
+  FILE *f=fopen(argv[1], "r");
+  char *line, *pattern, *module;
+  char *pos1, *pos2;
+
+  while((line=getline(f))!=NULL) {
+    if(!strncmp(line, "alias", strlen("alias"))) {
+      pos1 = index(line, ' ');
+      pos2 = index(pos1+1, ' ');
+      pattern = pos1+1;
+      *pos2 = '\0';
+      module = pos2+1;
+
+      if(!fnmatch(pattern, argv[2], 0))
+        printf("%s\n", module);
+    }
+  }
+  return 0;
+}

Deleted: resolve-modalias.cpp
===================================================================
--- resolve-modalias.cpp	2008-09-18 17:02:04 UTC (rev 12719)
+++ resolve-modalias.cpp	2008-09-18 17:27:41 UTC (rev 12720)
@@ -1,28 +0,0 @@
-#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;
-}

Modified: udev.install
===================================================================
--- udev.install	2008-09-18 17:02:04 UTC (rev 12719)
+++ udev.install	2008-09-18 17:27:41 UTC (rev 12720)
@@ -12,6 +12,21 @@
 fi
 }
 
+post_install() {
+  # If a ramfs is mounted, we still need to make sure that /dev/{console,null,zero} exist
+  # The Archlinux installer bind-mounts /dev to /mnt/dev, thus making the real /dev invisible
+  DEVDIR="/dev"
+  [ "$(stat -c %D /)" != "$(stat -c %D /dev)" ] && DEVDIR=$(mktemp -d /tmp/udevinstall.XXXXXX)
+  [ "${DEVDIR}" != "/dev" ] && mount --bind /dev ${DEVDIR}
+  [ -c ${DEVDIR}/console ] || mknod -m600 ${DEVDIR}/console c 5 1
+  [ -c ${DEVDIR}/null ]    || mknod -m644 ${DEVDIR}/null c 1 3
+  [ -c ${DEVDIR}/zero ]    || mknod -m644 ${DEVDIR}/zero c 1 5
+  if [ "${DEVDIR}" != "/dev" ]; then
+    umount ${DEVDIR}
+    rmdir ${DEVDIR}
+  fi
+}
+
 op=$1
 shift
 $op $*




More information about the arch-commits mailing list