summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--meta/recipes-core/udev/files/fix-alignment.patch26
-rwxr-xr-xmeta/recipes-core/udev/files/init212
-rw-r--r--meta/recipes-core/udev/files/local.rules22
-rw-r--r--meta/recipes-core/udev/files/noasmlinkage.patch39
-rw-r--r--meta/recipes-core/udev/files/permissions.rules81
-rw-r--r--meta/recipes-core/udev/files/tmpfs.patch17
-rw-r--r--meta/recipes-core/udev/files/udev.rules98
-rw-r--r--meta/recipes-core/udev/files/udev_network_queue.sh35
-rw-r--r--meta/recipes-core/udev/files/udevsynthesize.patch778
-rw-r--r--meta/recipes-core/udev/files/udevsynthesize.sh51
-rw-r--r--meta/recipes-core/udev/udev-145/enable-gudev.patch50
-rw-r--r--meta/recipes-core/udev/udev-145/init59
-rw-r--r--meta/recipes-core/udev/udev-145/local.rules33
-rw-r--r--meta/recipes-core/udev/udev-145/noasmlinkage.patch50
-rw-r--r--meta/recipes-core/udev/udev-145/permissions.rules131
-rw-r--r--meta/recipes-core/udev/udev-145/run.rules14
-rw-r--r--meta/recipes-core/udev/udev-145/udev.rules116
-rw-r--r--meta/recipes-core/udev/udev-145/unbreak.patch26
-rw-r--r--meta/recipes-core/udev/udev.inc72
-rw-r--r--meta/recipes-core/udev/udev_145.bb55
20 files changed, 0 insertions, 1965 deletions
diff --git a/meta/recipes-core/udev/files/fix-alignment.patch b/meta/recipes-core/udev/files/fix-alignment.patch
deleted file mode 100644
index dfe21b6e96..0000000000
--- a/meta/recipes-core/udev/files/fix-alignment.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-Upstream-Status: Pending
-
-diff --git a/udev_rules_parse.c b/udev_rules_parse.c
---- a/udev_rules_parse.c
-+++ b/udev_rules_parse.c
-@@ -241,6 +241,7 @@ static int add_to_rules(struct udev_rule
- int valid;
- char *linepos;
- char *attr;
-+ size_t padding;
- int retval;
-
- /* get all the keys */
-@@ -506,6 +507,11 @@ static int add_to_rules(struct udev_rule
-
- /* grow buffer and add rule */
- rule_size = sizeof(struct udev_rule) + rule->bufsize;
-+ padding = (sizeof(size_t) - rule_size % sizeof(size_t)) % sizeof(size_t);
-+ dbg("add %zi padding bytes", padding);
-+ rule_size += padding;
-+ rule->bufsize += padding;
-+
- rules->buf = realloc(rules->buf, rules->bufsize + rule_size);
- if (!rules->buf) {
- err("realloc failed");
-
diff --git a/meta/recipes-core/udev/files/init b/meta/recipes-core/udev/files/init
deleted file mode 100755
index 8cbab188f0..0000000000
--- a/meta/recipes-core/udev/files/init
+++ /dev/null
@@ -1,212 +0,0 @@
-#!/bin/sh -e
-
-UDEVSTART=/sbin/udevstart
-
-# defaults
-tmpfs_size="10M"
-udev_root="/dev"
-
-[ -x $UDEVSTART ] || exit 0
-
-. /etc/udev/udev.conf
-
-##############################################################################
-
-# we need to unmount /dev/pts/ and remount it later over the tmpfs
-unmount_devpts() {
- if mountpoint -q /dev/pts/; then
- umount -l /dev/pts/
- fi
-
- if mountpoint -q /dev/shm/; then
- umount -l /dev/shm/
- fi
-}
-
-# mount a tmpfs over /dev, if somebody did not already do it
-mount_tmpfs() {
- if grep -E -q "^[^[:space:]]+ /dev tmpfs" /proc/mounts; then
- return 0
- fi
-
- # /dev/.static/dev/ is used by MAKEDEV to access the real /dev/ directory.
- # /etc/udev/ is recycled as a temporary mount point because it's the only
- # directory which is guaranteed to be available.
- mount -n -o bind /dev /etc/udev
-
- if ! mount -n -o size=$tmpfs_size,mode=0755 -t tmpfs tmpfs /dev; then
- umount /etc/udev
- echo "udev requires tmpfs support, not started."
- exit 1
- fi
-
- # using ln to test if /dev works, because touch is in /usr/bin/
- if ln -s test /dev/test-file; then
- rm /dev/test-file
- else
- echo "udev requires tmpfs support, not started."
- umount /etc/udev
- umount /dev
- exit 1
- fi
-
- mkdir -p /dev/.static/dev
- chmod 700 /dev/.static/
- # The mount options in busybox are non-standard...
- if test -x /bin/mount.util-linux
- then
- /bin/mount.util-linux --move /etc/udev /dev/.static/dev
- elif test -x /bin/busybox
- then
- busybox mount -n -o move /etc/udev /dev/.static/dev
- else
- echo "udev requires an identifiable mount command, not started."
- umount /etc/udev
- umount /dev
- exit 1
- fi
-}
-
-# I hate this hack. -- Md
-make_extra_nodes() {
- [ -e /etc/udev/links.conf ] || return 0
- grep '^[^#]' /etc/udev/links.conf | \
- while read type name arg1; do
- [ "$type" -a "$name" -a ! -e "/dev/$name" -a ! -L "/dev/$name" ] ||continue
- case "$type" in
- L) ln -s $arg1 /dev/$name ;;
- D) mkdir -p /dev/$name ;;
- M) mknod -m 600 /dev/$name $arg1 ;;
- *) echo "links.conf: unparseable line ($type $name $arg1)" ;;
- esac
- done
-}
-
-# this function is duplicated in preinst, postinst and d-i
-supported_kernel() {
- case "$(uname -r)" in
- 2.[012345].*|2.6.[0-9]|2.6.[0-9][!0-9]*) return 1 ;;
- 2.6.1[01]|2.6.1[01][!0-9]*) return 1 ;;
- esac
- return 0
-}
-
-# shell version of /usr/bin/tty
-my_tty() {
- [ -x /bin/readlink ] || return 0
- [ -e /proc/self/fd/0 ] || return 0
- readlink --silent /proc/self/fd/0 || true
-}
-
-warn_if_interactive() {
- if [ "$RUNLEVEL" = "S" -a "$PREVLEVEL" = "N" ]; then
- return 0
- fi
-
- TTY=$(my_tty)
- if [ -z "$TTY" -o "$TTY" = "/dev/console" ]; then
- return 0
- fi
-
- printf "\n\n\nIt has been detected that the command\n\n\t$0 $*\n\n"
- printf "has been run from an interactive shell.\n"
- printf "It will probably not do what you expect, so this script will wait\n"
- printf "60 seconds before continuing. Press ^C to stop it.\n"
- printf "RUNNING THIS COMMAND IS HIGHLY DISCOURAGED!\n\n\n\n"
- sleep 60
-}
-
-##############################################################################
-
-if ! supported_kernel; then
- echo "udev requires a kernel >= 2.6.12, not started."
- exit 1
-fi
-
-if [ ! -e /proc/filesystems ]; then
- echo "udev requires a mounted procfs, not started."
- exit 1
-fi
-
-if ! grep -q '[[:space:]]tmpfs$' /proc/filesystems; then
- echo "udev requires tmpfs support, not started."
- exit 1
-fi
-
-if [ ! -d /sys/class/ ]; then
- echo "udev requires a mounted sysfs, not started."
- exit 1
-fi
-
-if [ ! -e /proc/sys/kernel/hotplug ] && [ ! -e /sys/kernel/uevent_helper ]; then
- echo "udev requires hotplug support, not started."
- exit 1
-fi
-
-##############################################################################
-
-# When modifying this script, do not forget that between the time that
-# the new /dev has been mounted and udevstart has been run there will be
-# no /dev/null. This also means that you cannot use the "&" shell command.
-
-case "$1" in
- start)
- if [ -e "$udev_root/.udevdb" ]; then
- if mountpoint -q /dev/; then
- TMPFS_MOUNTED=1
- else
- echo ".udevdb already exists on the old $udev_root!"
- fi
- fi
- warn_if_interactive
-
- #echo /sbin/udevsend > /proc/sys/kernel/hotplug
- if [ -e /sys/kernel/uevent_helper ] ; then
- echo "" > /sys/kernel/uevent_helper
- else
- echo "" > /proc/sys/kernel/hotplug
- fi
- udevsend
- if [ "$UDEV_DISABLED" = "yes" ]; then
- echo "udev disabled on the kernel command line, not started."
- exit 0
- fi
-
- if [ ! "$TMPFS_MOUNTED" ]; then
- unmount_devpts
- mount_tmpfs
- [ -d /proc/1 ] || mount -n /proc
- # if this directory is not present /dev will not be updated by udev
- mkdir /dev/.udevdb/
- echo "Creating initial device nodes..."
- udevstart
- fi
- make_extra_nodes
- ;;
- stop)
- warn_if_interactive
- start-stop-daemon --stop --exec /sbin/udevd --quiet
- unmount_devpts
- if [ -d /dev/.static/dev/ ]; then
- umount -l /dev/.static/dev/ || true
- fi
- echo "Unmounting /dev..."
- # unmounting with -l should never fail
- if ! umount -l /dev; then
- exit 1
- fi
- ;;
- restart|force-reload)
- start-stop-daemon --stop --exec /sbin/udevd --quiet
- log_begin_msg "Recreating device nodes..."
- udevstart
- make_extra_nodes
- log_end_msg 0
- ;;
- *)
- echo "Usage: /etc/init.d/udev {start|stop|restart|force-reload}"
- exit 1
- ;;
-esac
-
-exit 0
diff --git a/meta/recipes-core/udev/files/local.rules b/meta/recipes-core/udev/files/local.rules
deleted file mode 100644
index 5f2efbeb0c..0000000000
--- a/meta/recipes-core/udev/files/local.rules
+++ /dev/null
@@ -1,22 +0,0 @@
-# There are a number of modifiers that are allowed to be used in some
-# of the different fields. They provide the following subsitutions:
-#
-# %n the "kernel number" of the device.
-# For example, 'sda3' has a "kernel number" of '3'
-# %e the smallest number for that name which does not matches an existing node
-# %k the kernel name for the device
-# %M the kernel major number for the device
-# %m the kernel minor number for the device
-# %b the bus id for the device
-# %c the string returned by the PROGRAM
-# %s{filename} the content of a sysfs attribute
-# %% the '%' char itself
-#
-
-# Media automounting
-SUBSYSTEM=="block", ACTION=="add" RUN+="/etc/udev/scripts/mount.sh"
-SUBSYSTEM=="block", ACTION=="remove" RUN+="/etc/udev/scripts/mount.sh"
-
-# Handle network interface setup
-SUBSYSTEM=="net", ACTION=="add" RUN+="/etc/udev/scripts/network.sh"
-SUBSYSTEM=="net", ACTION=="remove" RUN+="/etc/udev/scripts/network.sh"
diff --git a/meta/recipes-core/udev/files/noasmlinkage.patch b/meta/recipes-core/udev/files/noasmlinkage.patch
deleted file mode 100644
index 4173fc5c2b..0000000000
--- a/meta/recipes-core/udev/files/noasmlinkage.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-Upstream-Status: Inappropriate [embedded]
-
-#
-# Patch managed by http://www.holgerschurig.de/patcher.html
-#
-
---- udev-062/udev.c~noasmlinkage.patch
-+++ udev-062/udev.c
-@@ -54,7 +54,7 @@
- }
- #endif
-
--static void asmlinkage sig_handler(int signum)
-+static void sig_handler(int signum)
- {
- switch (signum) {
- case SIGALRM:
---- udev-062/udevd.c~noasmlinkage.patch
-+++ udev-062/udevd.c
-@@ -639,7 +639,7 @@
- return msg;
- }
-
--static void asmlinkage sig_handler(int signum)
-+static void sig_handler(int signum)
- {
- int rc;
-
---- udev-062/udevstart.c~noasmlinkage.patch
-+++ udev-062/udevstart.c
-@@ -323,7 +323,7 @@
- exec_list(&device_list);
- }
-
--static void asmlinkage sig_handler(int signum)
-+static void sig_handler(int signum)
- {
- switch (signum) {
- case SIGALRM:
diff --git a/meta/recipes-core/udev/files/permissions.rules b/meta/recipes-core/udev/files/permissions.rules
deleted file mode 100644
index 86d771276b..0000000000
--- a/meta/recipes-core/udev/files/permissions.rules
+++ /dev/null
@@ -1,81 +0,0 @@
-# default permissions for block devices
-SUBSYSTEM=="block", GROUP="disk"
-SUBSYSTEM=="block", SYSFS{removable}=="1", GROUP="floppy"
-
-# IDE devices
-BUS=="ide", KERNEL=="hd[a-z]", SYSFS{removable}="1", \
- PROGRAM="/bin/cat /proc/ide/%k/media", RESULT=="cdrom*", GROUP="cdrom"
-BUS=="ide", KERNEL=="ht[0-9]*", GROUP="tape"
-BUS=="ide", KERNEL=="nht[0-9]*", GROUP="tape"
-
-# SCSI devices
-BUS=="scsi", SYSFS{type}=="1", GROUP="tape"
-BUS=="scsi", SYSFS{type}=="5", GROUP="cdrom"
-BUS=="scsi", SYSFS{type}=="6", GROUP="scanner"
-
-# USB devices
-BUS=="usb", KERNEL=="legousbtower*", MODE="0666"
-BUS=="usb", KERNEL=="lp[0-9]*", GROUP="lp"
-
-# serial devices
-SUBSYSTEM=="tty", GROUP="dialout"
-SUBSYSTEM=="capi", GROUP="dialout"
-SUBSYSTEM=="slamr", GROUP="dialout"
-
-# vc devices (all members of the tty subsystem)
-KERNEL=="ptmx", MODE="0666", GROUP="root"
-KERNEL=="console", MODE="0600", GROUP="root"
-KERNEL=="tty", MODE="0666", GROUP="root"
-KERNEL=="tty[0-9]*", GROUP="root"
-KERNEL=="pty*", MODE="0666", GROUP="tty"
-
-# video devices
-SUBSYSTEM=="video4linux", GROUP="video"
-SUBSYSTEM=="drm", GROUP="video"
-SUBSYSTEM=="dvb", GROUP="video"
-SUBSYSTEM=="em8300", GROUP="video"
-SUBSYSTEM=="graphics", GROUP="video"
-SUBSYSTEM=="nvidia", GROUP="video"
-
-# misc devices
-KERNEL=="random", MODE="0666"
-KERNEL=="urandom", MODE="0444"
-KERNEL=="mem", MODE="0640", GROUP="kmem"
-KERNEL=="kmem", MODE="0640", GROUP="kmem"
-KERNEL=="port", MODE="0640", GROUP="kmem"
-KERNEL=="full", MODE="0666"
-KERNEL=="null", MODE="0666"
-KERNEL=="zero", MODE="0666"
-KERNEL=="inotify", MODE="0666"
-KERNEL=="sgi_fetchop", MODE="0666"
-KERNEL=="sonypi", MODE="0666"
-KERNEL=="agpgart", GROUP="video"
-KERNEL=="nvram", GROUP="nvram"
-KERNEL=="rtc", MODE="0660", GROUP="audio"
-
-KERNEL=="cdemu[0-9]*", GROUP="cdrom"
-KERNEL=="pktcdvd[0-9]*", GROUP="cdrom"
-KERNEL=="pktcdvd", MODE="0644"
-
-# printers and parallel devices
-SUBSYSTEM=="printer", GROUP="lp"
-SUBSYSTEM=="ppdev", GROUP="lp"
-KERNEL=="pt[0-9]*", GROUP="tape"
-KERNEL=="pht[0-9]*", GROUP="tape"
-
-# sound devices
-SUBSYSTEM=="sound", GROUP="audio"
-
-# ieee1394 devices
-KERNEL=="raw1394", GROUP="disk"
-KERNEL=="dv1394*", GROUP="video"
-KERNEL=="video1394*", GROUP="video"
-
-# input devices
-KERNEL=="event[0-9]*", MODE="0664"
-KERNEL=="js[0-9]*", MODE="0664"
-
-# AOE character devices
-SUBSYSTEM=="aoe", MODE="0220", GROUP="disk"
-SUBSYSTEM=="aoe", KERNEL=="err", MODE="0440"
-
diff --git a/meta/recipes-core/udev/files/tmpfs.patch b/meta/recipes-core/udev/files/tmpfs.patch
deleted file mode 100644
index aa4a4f6c9b..0000000000
--- a/meta/recipes-core/udev/files/tmpfs.patch
+++ /dev/null
@@ -1,17 +0,0 @@
-Upstream-Status: Inappropriate [embedded]
-
-#
-# Patch managed by http://www.mn-logistik.de/unsupported/pxa250/patcher
-#
-
---- udev-031/extras/start_udev~tmpfs 2004-09-10 17:10:03.000000000 -0400
-+++ udev-031/extras/start_udev 2004-09-11 15:18:15.560789160 -0400
-@@ -85,7 +85,7 @@
- fi
-
- echo "mounting... ramfs at $udev_root"
--mount -n -t ramfs none $udev_root
-+mount -n -t ramfs none $udev_root || mount -n -t tmpfs none $udev_root
-
- # propogate /udev from /sys
- echo "Creating initial udev device nodes:"
diff --git a/meta/recipes-core/udev/files/udev.rules b/meta/recipes-core/udev/files/udev.rules
deleted file mode 100644
index 5c566f6cef..0000000000
--- a/meta/recipes-core/udev/files/udev.rules
+++ /dev/null
@@ -1,98 +0,0 @@
-# There are a number of modifiers that are allowed to be used in some
-# of the different fields. They provide the following subsitutions:
-#
-# %n the "kernel number" of the device.
-# For example, 'sda3' has a "kernel number" of '3'
-# %e the smallest number for that name which does not matches an existing node
-# %k the kernel name for the device
-# %M the kernel major number for the device
-# %m the kernel minor number for the device
-# %b the bus id for the device
-# %c the string returned by the PROGRAM
-# %s{filename} the content of a sysfs attribute
-# %% the '%' char itself
-#
-
-# SCSI devices
-BUS=="scsi", KERNEL=="sr[0-9]*", NAME="scd%n", SYMLINK+="sr%n"
-
-# USB devices
-BUS=="usb", KERNEL=="auer[0-9]*", NAME="usb/%k"
-BUS=="usb", KERNEL=="cpad[0-9]*", NAME="usb/%k"
-BUS=="usb", KERNEL=="dabusb*", NAME="usb/%k"
-BUS=="usb", KERNEL=="hiddev*", NAME="usb/%k"
-BUS=="usb", KERNEL=="legousbtower*", NAME="usb/%k"
-BUS=="usb", KERNEL=="lp[0-9]*", NAME="usb/%k"
-BUS=="usb", KERNEL=="ttyUSB*", SYSFS{product}=="Palm Handheld*", \
- SYMLINK+="pilot"
-
-# usbfs-like devices
-SUBSYSTEM=="usb_device", \
- PROGRAM="/bin/sh -c 'export X=%k; export X=$${X#usbdev}; export B=$${X%%%%.*}; export D=$${X#*.}; echo bus/usb/$$B/$$D'", SYMLINK+="%c"
-
-# serial devices
-KERNEL=="capi", NAME="capi20", SYMLINK+="isdn/capi20"
-KERNEL=="capi[0-9]*", NAME="capi/%n"
-
-# video devices
-KERNEL=="card[0-9]*", NAME="dri/%k"
-
-# misc devices
-KERNEL=="hw_random", NAME="hwrng"
-KERNEL=="tun", NAME="net/%k"
-
-KERNEL=="cdemu[0-9]*", NAME="cdemu/%n"
-KERNEL=="pktcdvd[0-9]*", NAME="pktcdvd/%n"
-KERNEL=="pktcdvd", NAME="pktcdvd/control"
-
-KERNEL=="cpu[0-9]*", NAME="cpu/%n/cpuid"
-KERNEL=="msr[0-9]*", NAME="cpu/%n/msr"
-KERNEL=="microcode", NAME="cpu/microcode"
-
-KERNEL=="umad*", NAME="infiniband/%k"
-KERNEL=="issm*", NAME="infiniband/%k"
-KERNEL=="uverbs*", NAME="infiniband/%k"
-KERNEL=="ucm", NAME="infiniband/%k"
-
-KERNEL=="buzzer", NAME="misc/buzzer"
-
-# ALSA devices
-KERNEL=="controlC[0-9]*", NAME="snd/%k"
-KERNEL=="hwC[D0-9]*", NAME="snd/%k"
-KERNEL=="pcmC[D0-9cp]*", NAME="snd/%k"
-KERNEL=="midiC[D0-9]*", NAME="snd/%k"
-KERNEL=="timer", NAME="snd/%k"
-KERNEL=="seq", NAME="snd/%k"
-
-# ieee1394 devices
-KERNEL=="dv1394*", NAME="dv1394/%n"
-KERNEL=="video1394*", NAME="video1394/%n"
-
-# input devices
-KERNEL=="mice", NAME="input/%k"
-KERNEL=="mouse[0-9]*", NAME="input/%k"
-KERNEL=="event[0-9]*", NAME="input/%k"
-KERNEL=="js[0-9]*", NAME="input/%k"
-KERNEL=="ts[0-9]*", NAME="input/%k"
-KERNEL=="uinput", NAME="input/%k"
-
-# Zaptel
-KERNEL=="zapctl", NAME="zap/ctl"
-KERNEL=="zaptimer", NAME="zap/timer"
-KERNEL=="zapchannel", NAME="zap/channel"
-KERNEL=="zappseudo", NAME="zap/pseudo"
-KERNEL=="zap[0-9]*", NAME="zap/%n"
-
-# AOE character devices
-SUBSYSTEM=="aoe", KERNEL=="discover", NAME="etherd/%k"
-SUBSYSTEM=="aoe", KERNEL=="err", NAME="etherd/%k"
-SUBSYSTEM=="aoe", KERNEL=="interfaces", NAME="etherd/%k"
-
-# device mapper creates its own device nodes, so ignore these
-KERNEL=="dm-[0-9]*", OPTIONS+="ignore_device"
-KERNEL=="device-mapper", NAME="mapper/control"
-
-KERNEL="rfcomm[0-9]*", NAME="%k", GROUP="users", MODE="0660"
-
-# Firmware Helper
-ACTION=="add", SUBSYSTEM=="firmware", RUN+="/sbin/firmware_helper"
diff --git a/meta/recipes-core/udev/files/udev_network_queue.sh b/meta/recipes-core/udev/files/udev_network_queue.sh
deleted file mode 100644
index 05e08e9d1b..0000000000
--- a/meta/recipes-core/udev/files/udev_network_queue.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#! /bin/sh
-#
-# Copyright Matthias Hentges <devel@hentges.net> (c) 2006
-# License: GPL (see http://www.gnu.org/licenses/gpl.txt for a copy of the license)
-#
-# Filename: udev_network_queue.sh
-# Date: 03-May-06
-
-do_start() {
- if test -e /dev/udev_network_queue
- then
- echo "Activating queued NICs..."
- for NIC in `cat /dev/udev_network_queue`
- do
- export INTERFACE="$NIC" ; export ACTION=add
- /etc/udev/scripts/network.sh
- done
- echo ""
- else
- echo "No NICs queued"
- fi
-}
-
-do_stop() {
- /bin/true
-}
-
-case "$1" in
-start) do_start;;
-stop) do_stop;;
-restart) do_stop
- do_start;;
-*) echo "Usage: `basename $0` [ start | stop | restart ]"
- exit 0;;
-esac
diff --git a/meta/recipes-core/udev/files/udevsynthesize.patch b/meta/recipes-core/udev/files/udevsynthesize.patch
deleted file mode 100644
index 5122ea2b22..0000000000
--- a/meta/recipes-core/udev/files/udevsynthesize.patch
+++ /dev/null
@@ -1,778 +0,0 @@
-Upstream-Status: Inappropriate [distribution]
-
---- udev-081/udevsynthesize.c.orig 2006-01-29 12:22:45.000000000 +0100
-+++ udev-081/udevsynthesize.c 2006-01-29 12:22:40.000000000 +0100
-@@ -0,0 +1,763 @@
-+/*
-+ * udevcoldplug.c
-+ *
-+ * Copyright (C) 2005 SUSE Linux Products GmbH
-+ *
-+ * Author:
-+ * Kay Sievers <kay.sievers@vrfy.org>
-+ *
-+ * Synthesize kernel events from sysfs information and pass them
-+ * to the udevd daemon.
-+ *
-+ * This program is free software; you can redistribute it and/or modify it
-+ * under the terms of the GNU General Public License as published by the
-+ * Free Software Foundation version 2 of the License.
-+ *
-+ * This program is distributed in the hope that it will be useful, but
-+ * WITHOUT ANY WARRANTY; without even the implied warranty of
-+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-+ * General Public License for more details.
-+ *
-+ * You should have received a copy of the GNU General Public License along
-+ * with this program; if not, write to the Free Software Foundation, Inc.,
-+ * 675 Mass Ave, Cambridge, MA 02139, USA.
-+ *
-+ */
-+
-+#include <stdlib.h>
-+#include <stddef.h>
-+#include <string.h>
-+#include <stdio.h>
-+#include <unistd.h>
-+#include <errno.h>
-+#include <ctype.h>
-+#include <fcntl.h>
-+#include <dirent.h>
-+#include <signal.h>
-+#include <syslog.h>
-+#include <sys/socket.h>
-+#include <sys/un.h>
-+#include <sys/wait.h>
-+#include <sys/stat.h>
-+#include <sys/types.h>
-+
-+#include "udev_libc_wrapper.h"
-+#include "udev.h"
-+#include "udevd.h"
-+#include "udev_version.h"
-+#include "logging.h"
-+
-+#include "list.h"
-+
-+#ifndef DT_DIR
-+#define DT_DIR 4
-+#endif
-+
-+static const char *udev_log_str;
-+static int udevd_sock = -1;
-+
-+#ifdef USE_LOG
-+void log_message(int priority, const char *format, ...)
-+{
-+ va_list args;
-+
-+ if (priority > udev_log_priority)
-+ return;
-+
-+ va_start(args, format);
-+ vsyslog(priority, format, args);
-+ va_end(args);
-+}
-+#endif
-+
-+struct device {
-+ struct list_head node;
-+ struct udevd_msg msg;
-+ size_t bufpos;
-+ char *path;
-+};
-+
-+static dev_t read_devt(const char *path)
-+{
-+ char filename[PATH_SIZE];
-+ char majorminor[64];
-+ unsigned int major, minor;
-+ ssize_t count;
-+ int fd;
-+
-+ snprintf(filename, sizeof(filename), "%s/%s", path, "dev");
-+ filename[sizeof(filename)-1] = '\0';
-+
-+ fd = open(filename, O_RDONLY);
-+ if (fd < 0)
-+ return 0;
-+
-+ count = read(fd, majorminor, sizeof(majorminor));
-+ close(fd);
-+ majorminor[count] = '\0';
-+ if (sscanf(majorminor, "%u:%u", &major, &minor) != 2)
-+ return 0;
-+ dbg("found major=%d, minor=%d", major, minor);
-+
-+ return makedev(major, minor);
-+}
-+
-+static ssize_t read_file(const char *directory, const char *file, char *str, size_t len)
-+{
-+ char filename[PATH_SIZE];
-+ ssize_t count;
-+ int fd;
-+
-+ memset(filename, 0, sizeof(filename));
-+ snprintf(filename, sizeof(filename), "%s/%s", directory, file);
-+ filename[sizeof(filename)-1] = '\0';
-+
-+ fd = open(filename, O_RDONLY);
-+ if (fd < 0)
-+ return -1;
-+
-+ count = read(fd, str, len-1);
-+ close(fd);
-+
-+ if (count > (ssize_t)len)
-+ count = len;
-+ str[count-1] = '\0';
-+
-+ return count;
-+}
-+
-+static ssize_t read_link(const char *directory, const char *file, char *str, size_t size)
-+{
-+ char filename[PATH_SIZE];
-+ char target[PATH_SIZE];
-+ int len;
-+ char *back;
-+ char *strip;
-+ int level = 1;
-+
-+ snprintf(filename, sizeof(filename), "%s/%s", directory, file);
-+ filename[sizeof(filename)-1] = '\0';
-+
-+ len = readlink(filename, target, sizeof(target)-1);
-+ if (len < 0)
-+ return -1;
-+ target[len] = '\0';
-+
-+ back = target;
-+ while (strncmp(back, "../", 3) == 0) {
-+ back += 3;
-+ level++;
-+ }
-+ while(level--) {
-+ strip = strrchr(filename, '/');
-+ if (!strip)
-+ return -1;
-+ strip[0] = '\0';
-+ }
-+
-+ snprintf(str, size, "%s/%s", filename, back);
-+ str[size-1] = '\0';
-+
-+ return len;
-+}
-+
-+static char *add_env_key(struct device *device, const char *key, const char *value)
-+{
-+ size_t pos = device->bufpos;
-+ device->bufpos += sprintf(&device->msg.envbuf[device->bufpos], "%s=%s", key, value)+1;
-+ return &device->msg.envbuf[pos];
-+}
-+
-+static struct device *device_create(const char *path, const char *subsystem, dev_t devt)
-+{
-+ struct device *device;
-+ const char *devpath = &path[strlen(sysfs_path)];
-+ char target[PATH_SIZE];
-+
-+ device = malloc(sizeof(struct device));
-+ if (device == NULL) {
-+ dbg("error malloc");
-+ return NULL;
-+ }
-+ memset(device, 0x00, sizeof(struct device));
-+
-+ device->path = add_env_key(device, "DEVPATH", devpath);
-+ device->path += strlen("DEVPATH=");
-+ add_env_key(device, "SUBSYSTEM", subsystem);
-+ add_env_key(device, "ACTION", "add");
-+ add_env_key(device, "UDEV_COLDPLUG", "1");
-+
-+ if (major(devt)) {
-+ char number[32];
-+ sprintf(number, "%u", major(devt));
-+ add_env_key(device, "MAJOR", number);
-+ sprintf(number, "%u", minor(devt));
-+ add_env_key(device, "MINOR", number);
-+ }
-+
-+ if (strncmp(devpath, "/block/", strlen("/block/")) == 0 ||
-+ strncmp(devpath, "/class/", strlen("/class/")) == 0) {
-+ char physpath[PATH_SIZE];
-+
-+ if (read_link(path, "device", physpath, sizeof(physpath)) > (ssize_t)strlen(sysfs_path)) {
-+ add_env_key(device, "PHYSDEVPATH", &physpath[strlen(sysfs_path)]);
-+ if (read_link(physpath, "driver", target, sizeof(target)) > (ssize_t)strlen(sysfs_path)) {
-+ char *pos = strrchr(target, '/');
-+ if (pos)
-+ add_env_key(device, "PHYSDEVDRIVER", &pos[1]);
-+ }
-+ if (read_link(physpath, "bus", target, sizeof(target)) > (ssize_t)strlen(sysfs_path)) {
-+ char *pos = strrchr(target, '/');
-+ if (pos)
-+ add_env_key(device, "PHYSDEVBUS", &pos[1]);
-+ }
-+ }
-+ } else if (strncmp(devpath, "/devices/", strlen("/devices/")) == 0) {
-+ if (read_link(path, "driver", target, sizeof(target)) > (ssize_t)strlen(sysfs_path)) {
-+ char *pos = strrchr(target, '/');
-+ if (pos)
-+ add_env_key(device, "PHYSDEVDRIVER", &pos[1]);
-+ }
-+ if (read_link(path, "bus", target, sizeof(target)) > (ssize_t)strlen(sysfs_path)) {
-+ char *pos = strrchr(target, '/');
-+ if (pos)
-+ add_env_key(device, "PHYSDEVBUS", &pos[1]);
-+ }
-+ }
-+
-+ return device;
-+}
-+
-+static int device_list_insert(struct list_head *device_list, struct device *device)
-+{
-+ struct device *loop_device;
-+
-+ dbg("insert: '%s'", device->path);
-+
-+ /* sort files in lexical order */
-+ list_for_each_entry(loop_device, device_list, node)
-+ if (strcmp(loop_device->path, device->path) > 0)
-+ break;
-+
-+ list_add_tail(&device->node, &loop_device->node);
-+
-+ return 0;
-+}
-+
-+static int add_device_udevd(struct device *device)
-+{
-+ size_t msg_len;
-+ struct sockaddr_un saddr;
-+ socklen_t addrlen;
-+ int retval;
-+
-+ memset(&saddr, 0x00, sizeof(struct sockaddr_un));
-+ saddr.sun_family = AF_LOCAL;
-+ /* use abstract namespace for socket path */
-+ strcpy(&saddr.sun_path[1], UDEVD_SOCK_PATH);
-+ addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path+1) + 1;
-+
-+ strcpy(device->msg.magic, UDEV_MAGIC);
-+ device->msg.type = UDEVD_UEVENT_UDEVSEND;
-+
-+ msg_len = offsetof(struct udevd_msg, envbuf) + device->bufpos;
-+ dbg("msg_len=%i", msg_len);
-+
-+ retval = sendto(udevd_sock, &device->msg, msg_len, 0, (struct sockaddr *)&saddr, addrlen);
-+ if (retval < 0)
-+ return -1;
-+
-+ return 0;
-+}
-+
-+static void exec_list(struct list_head *device_list, const char *first[], const char *last[])
-+{
-+ struct device *loop_device;
-+ struct device *tmp_device;
-+ int i;
-+
-+ /* handle the "first" type devices first */
-+ if (first)
-+ list_for_each_entry_safe(loop_device, tmp_device, device_list, node) {
-+ for (i = 0; first[i] != NULL; i++) {
-+ if (strncmp(loop_device->path, first[i], strlen(first[i])) == 0) {
-+ add_device_udevd(loop_device);
-+ list_del(&loop_device->node);
-+ free(loop_device);
-+ break;
-+ }
-+ }
-+ }
-+
-+ /* handle the devices we are allowed to, excluding the "last" type devices */
-+ if (last)
-+ list_for_each_entry_safe(loop_device, tmp_device, device_list, node) {
-+ int found = 0;
-+ for (i = 0; last[i] != NULL; i++) {
-+ if (strncmp(loop_device->path, last[i], strlen(last[i])) == 0) {
-+ found = 1;
-+ break;
-+ }
-+ }
-+ if (found)
-+ continue;
-+
-+ add_device_udevd(loop_device);
-+ list_del(&loop_device->node);
-+ free(loop_device);
-+ }
-+
-+ /* handle the rest of the devices */
-+ list_for_each_entry_safe(loop_device, tmp_device, device_list, node) {
-+ add_device_udevd(loop_device);
-+ list_del(&loop_device->node);
-+ free(loop_device);
-+ }
-+}
-+
-+static int udev_scan_class(void)
-+{
-+ char base[PATH_SIZE];
-+ DIR *dir;
-+ struct dirent *dent;
-+ LIST_HEAD(device_list);
-+
-+ /* we want /dev/null and /dev/console first */
-+ const char *first[] = {
-+ "/class/mem",
-+ "/class/tty",
-+ NULL,
-+ };
-+
-+ snprintf(base, sizeof(base), "%s/class", sysfs_path);
-+ base[sizeof(base)-1] = '\0';
-+
-+ dir = opendir(base);
-+ if (!dir)
-+ return -1;
-+
-+ for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
-+ char dirname[PATH_SIZE];
-+ DIR *dir2;
-+ struct dirent *dent2;
-+
-+ if (dent->d_name[0] == '.')
-+ continue;
-+
-+ snprintf(dirname, sizeof(dirname), "%s/%s", base, dent->d_name);
-+ dirname[sizeof(dirname)-1] = '\0';
-+
-+ dir2 = opendir(dirname);
-+ if (!dir2)
-+ continue;
-+ for (dent2 = readdir(dir2); dent2 != NULL; dent2 = readdir(dir2)) {
-+ char dirname2[PATH_SIZE];
-+ struct device *device;
-+ dev_t devt;
-+
-+ if (dent2->d_name[0] == '.')
-+ continue;
-+ if (dent2->d_type != DT_DIR)
-+ continue;
-+
-+ snprintf(dirname2, sizeof(dirname2), "%s/%s", dirname, dent2->d_name);
-+ dirname2[sizeof(dirname2)-1] = '\0';
-+ devt = read_devt(dirname2);
-+ device = device_create(dirname2, dent->d_name, devt);
-+
-+ if (strcmp(dent->d_name, "net") == 0 ||
-+ strcmp(dent->d_name, "bluetooth") == 0) {
-+ add_env_key(device, "INTERFACE", dent2->d_name);
-+ } else if (strcmp(dent->d_name, "pcmcia_socket") == 0 &&
-+ strlen(dent->d_name) > 14) {
-+ add_env_key(device, "SOCKET_NO",
-+ dent2->d_name + 14);
-+ }
-+
-+ device_list_insert(&device_list, device);
-+ }
-+ closedir(dir2);
-+ }
-+ closedir(dir);
-+ exec_list(&device_list, first, NULL);
-+
-+ return 0;
-+}
-+
-+static int udev_scan_block(void)
-+{
-+ char base[PATH_SIZE];
-+ DIR *dir;
-+ struct dirent *dent;
-+ LIST_HEAD(device_list);
-+
-+ /* dm wants to have the block devices around before it */
-+ const char *last[] = {
-+ "/block/dm",
-+ NULL,
-+ };
-+
-+ snprintf(base, sizeof(base), "%s/block", sysfs_path);
-+ base[sizeof(base)-1] = '\0';
-+
-+ dir = opendir(base);
-+ if (!dir)
-+ return -1;
-+
-+ for (dent = readdir(dir); dent != NULL; dent = readdir(dir)) {
-+ char dirname[PATH_SIZE];
-+ struct device *device;
-+ struct dirent *dent2;
-+ DIR *dir2;
-+ dev_t devt;
-+