Hello community,
here is the log from the commit of package udev for openSUSE:Factory
checked in at Tue Jul 14 23:01:21 CEST 2009.
--------
--- udev/udev.changes 2009-07-09 17:28:27.000000000 +0200
+++ udev/udev.changes 2009-07-13 13:18:20.000000000 +0200
@@ -1,0 +2,8 @@
+Mon Jul 13 12:26:17 CEST 2009 - kay.sievers@novell.com
+
+- new upstream release 145
+ fix crash when workers are busy, rules are changed and workers killed
+ use qsort() to speed up sorting a large udevadm trigger list
+- add static nodes for /dev/ptmx /dev/tty*
+
+-------------------------------------------------------------------
calling whatdependson for head-i586
Old:
----
udev-144.tar.bz2
New:
----
udev-145.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ udev.spec ++++++
--- /var/tmp/diff_new_pack.5xGU8F/_old 2009-07-14 23:00:44.000000000 +0200
+++ /var/tmp/diff_new_pack.5xGU8F/_new 2009-07-14 23:00:44.000000000 +0200
@@ -1,5 +1,5 @@
#
-# spec file for package udev (Version 144)
+# spec file for package udev (Version 145)
#
# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
@@ -20,7 +20,7 @@
Name: udev
Url: http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html
-Version: 144
+Version: 145
Release: 1
License: GPL v2 or later
Group: System/Kernel
@@ -237,6 +237,10 @@
%attr(660,root,root) %dev(c,1,11) /lib/udev/devices/kmsg
%attr(666,root,root) %dev(c,1,3) /lib/udev/devices/null
%attr(666,root,root) %dev(c,1,5) /lib/udev/devices/zero
+%attr(666,root,tty) %dev(c,5,2) /lib/udev/devices/ptmx
+%attr(666,root,tty) %dev(c,5,0) /lib/udev/devices/tty
+%attr(620,root,tty) %dev(c,4,0) /lib/udev/devices/tty0
+%attr(620,root,tty) %dev(c,4,1) /lib/udev/devices/tty1
%attr(660,root,root) %dev(c,108,0) /lib/udev/devices/ppp
%attr(666,root,root) %dev(c,10,200) /lib/udev/devices/net/tun
%attr(660,root,lp) %dev(c,6,0) /lib/udev/devices/lp0
++++++ udev-144.tar.bz2 -> udev-145.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/udev-144/ChangeLog new/udev-145/ChangeLog
--- old/udev-144/ChangeLog 2009-07-06 00:52:46.000000000 +0200
+++ new/udev-145/ChangeLog 2009-07-13 12:16:24.000000000 +0200
@@ -1,3 +1,22 @@
+Summary of changes from v144 to v145
+============================================
+
+Ian Campbell (1):
+ scsi_id: correct error handling in prepend_vendor_model
+
+Kay Sievers (10):
+ README: add CONFIG_BLK_DEV_BSG
+ use MIN() MAX() from param.h
+ configure.ac: version bump
+ libudev: device - free values before updating them
+ libudev: enumerate - sort with qsort()
+ udevd: detach event from worker if we kill a worker
+ udevadm: info - add space after R:, A:, W: on database export
+ udevd: make sure a worker finishes event handling before exiting
+ udevd: handle SIGCHLD before the worker event message
+ udevd: use bool
+
+
Summary of changes from v143 to v144
============================================
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/udev-144/NEWS new/udev-145/NEWS
--- old/udev-144/NEWS 2009-07-04 16:59:31.000000000 +0200
+++ new/udev-145/NEWS 2009-07-13 12:18:54.000000000 +0200
@@ -1,3 +1,8 @@
+udev 145
+========
+Fix possible crash in udevd when worker processes are busy, rules are
+changed at the same time, and workers get killed to reload the rules.
+
udev 144
========
Bugfixes.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/udev-144/README new/udev-145/README
--- old/udev-144/README 2009-06-17 22:14:40.000000000 +0200
+++ new/udev-145/README 2009-07-07 09:34:30.000000000 +0200
@@ -22,9 +22,10 @@
CONFIG_SYSFS_DEPRECATED*=n
CONFIG_PROC_FS=y
CONFIG_TMPFS=y
- CONFIG_TMPFS_POSIX_ACL=y
CONFIG_INOTIFY=y
CONFIG_SIGNALFD=y
+ CONFIG_TMPFS_POSIX_ACL=y (user ACLs for device nodes)
+ CONFIG_BLK_DEV_BSG=y (SCSI tape devices)
- For reliable operation, the kernel must not use the CONFIG_SYSFS_DEPRECATED*
option.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/udev-144/configure new/udev-145/configure
--- old/udev-144/configure 2009-07-06 00:53:34.000000000 +0200
+++ new/udev-145/configure 2009-07-13 12:19:30.000000000 +0200
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.63 for udev 144.
+# Generated by GNU Autoconf 2.63 for udev 145.
#
# Report bugs to .
#
@@ -745,8 +745,8 @@
# Identity of this package.
PACKAGE_NAME='udev'
PACKAGE_TARNAME='udev'
-PACKAGE_VERSION='144'
-PACKAGE_STRING='udev 144'
+PACKAGE_VERSION='145'
+PACKAGE_STRING='udev 145'
PACKAGE_BUGREPORT='linux-hotplug@vger.kernel.org'
# Factoring default headers for most tests.
@@ -1520,7 +1520,7 @@
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures udev 144 to adapt to many kinds of systems.
+\`configure' configures udev 145 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1590,7 +1590,7 @@
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of udev 144:";;
+ short | recursive ) echo "Configuration of udev 145:";;
esac
cat <<\_ACEOF
@@ -1715,7 +1715,7 @@
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-udev configure 144
+udev configure 145
generated by GNU Autoconf 2.63
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1729,7 +1729,7 @@
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by udev $as_me 144, which was
+It was created by udev $as_me 145, which was
generated by GNU Autoconf 2.63. Invocation command line was
$ $0 $@
@@ -2579,7 +2579,7 @@
# Define the identity of the package.
PACKAGE='udev'
- VERSION='144'
+ VERSION='145'
cat >>confdefs.h <<_ACEOF
@@ -13520,7 +13520,7 @@
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by udev $as_me 144, which was
+This file was extended by udev $as_me 145, which was
generated by GNU Autoconf 2.63. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -13583,7 +13583,7 @@
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_version="\\
-udev config.status 144
+udev config.status 145
configured by $0, generated by GNU Autoconf 2.63,
with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/udev-144/configure.ac new/udev-145/configure.ac
--- old/udev-144/configure.ac 2009-07-05 16:04:53.000000000 +0200
+++ new/udev-145/configure.ac 2009-07-07 23:20:09.000000000 +0200
@@ -1,4 +1,4 @@
-AC_INIT([udev], [144], [linux-hotplug@vger.kernel.org])
+AC_INIT([udev], [145], [linux-hotplug@vger.kernel.org])
AC_PREREQ(2.60)
AM_INIT_AUTOMAKE([check-news foreign 1.9 dist-bzip2])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/udev-144/extras/gudev/docs/html/index.html new/udev-145/extras/gudev/docs/html/index.html
--- old/udev-144/extras/gudev/docs/html/index.html 2009-07-06 00:58:18.000000000 +0200
+++ new/udev-145/extras/gudev/docs/html/index.html 2009-07-13 12:24:32.000000000 +0200
@@ -35,7 +35,7 @@
</p></div></div>
</div>
</div></div>
-<div><p class="releaseinfo">For GUdev version 144
+<div><p class="releaseinfo">For GUdev version 145
</p></div>
<div><p class="copyright">Copyright © 2009 The GUDev Authors</p></div>
<div><div class="legalnotice" title="Legal Notice">
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/udev-144/extras/gudev/docs/version.xml new/udev-145/extras/gudev/docs/version.xml
--- old/udev-144/extras/gudev/docs/version.xml 2009-07-06 00:53:52.000000000 +0200
+++ new/udev-145/extras/gudev/docs/version.xml 2009-07-13 12:19:48.000000000 +0200
@@ -1 +1 @@
-144
+145
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/udev-144/extras/scsi_id/scsi_serial.c new/udev-145/extras/scsi_id/scsi_serial.c
--- old/udev-144/extras/scsi_id/scsi_serial.c 2009-06-28 02:18:04.000000000 +0200
+++ new/udev-145/extras/scsi_id/scsi_serial.c 2009-07-06 16:21:08.000000000 +0200
@@ -467,7 +467,7 @@
if (ind != (VENDOR_LENGTH + MODEL_LENGTH)) {
info(udev, "%s: expected length %d, got length %d\n",
dev_scsi->kernel, (VENDOR_LENGTH + MODEL_LENGTH), ind);
- return 1;
+ return -1;
}
return ind;
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/udev-144/libudev/Makefile.am new/udev-145/libudev/Makefile.am
--- old/udev-144/libudev/Makefile.am 2009-07-05 16:05:49.000000000 +0200
+++ new/udev-145/libudev/Makefile.am 2009-07-07 23:20:46.000000000 +0200
@@ -29,7 +29,7 @@
libudev-queue.c
LT_CURRENT=4
-LT_REVISION=1
+LT_REVISION=2
LT_AGE=4
libudev_la_LDFLAGS = \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/udev-144/libudev/Makefile.in new/udev-145/libudev/Makefile.in
--- old/udev-144/libudev/Makefile.in 2009-07-06 00:53:40.000000000 +0200
+++ new/udev-145/libudev/Makefile.in 2009-07-13 12:19:36.000000000 +0200
@@ -335,7 +335,7 @@
libudev-queue.c
LT_CURRENT = 4
-LT_REVISION = 1
+LT_REVISION = 2
LT_AGE = 4
libudev_la_LDFLAGS = \
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/udev-144/libudev/docs/html/index.html new/udev-145/libudev/docs/html/index.html
--- old/udev-144/libudev/docs/html/index.html 2009-07-06 00:58:14.000000000 +0200
+++ new/udev-145/libudev/docs/html/index.html 2009-07-13 12:24:28.000000000 +0200
@@ -16,7 +16,7 @@
<div class="titlepage">
<div>
<div><table class="navigation" id="top" width="100%" cellpadding="2" cellspacing="0"><tr><th valign="middle"><p class="title">libudev Reference Manual</p></th></tr></table></div>
-<div><p class="releaseinfo">for libudev version 144
+<div><p class="releaseinfo">for libudev version 145
</p></div>
<div><p class="copyright">Copyright © 2009 Kay Sievers <kay.sievers@vrfy.org></p></div>
</div>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/udev-144/libudev/docs/version.xml new/udev-145/libudev/docs/version.xml
--- old/udev-144/libudev/docs/version.xml 2009-07-06 00:53:51.000000000 +0200
+++ new/udev-145/libudev/docs/version.xml 2009-07-13 12:19:47.000000000 +0200
@@ -1 +1 @@
-144
+145
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/udev-144/libudev/libudev-device.c new/udev-145/libudev/libudev-device.c
--- old/udev-144/libudev/libudev-device.c 2009-07-04 04:12:06.000000000 +0200
+++ new/udev-145/libudev/libudev-device.c 2009-07-08 00:59:34.000000000 +0200
@@ -1282,6 +1282,7 @@
int udev_device_set_devpath_old(struct udev_device *udev_device, const char *devpath_old)
{
+ free(udev_device->devpath_old);
udev_device->devpath_old = strdup(devpath_old);
if (udev_device->devpath_old == NULL)
return -ENOMEM;
@@ -1296,6 +1297,7 @@
int udev_device_set_knodename(struct udev_device *udev_device, const char *knodename)
{
+ free(udev_device->knodename);
udev_device->knodename = strdup(knodename);
if (udev_device->knodename == NULL)
return -ENOMEM;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/udev-144/libudev/libudev-enumerate.c new/udev-145/libudev/libudev-enumerate.c
--- old/udev-144/libudev/libudev-enumerate.c 2009-06-15 19:59:45.000000000 +0200
+++ new/udev-145/libudev/libudev-enumerate.c 2009-07-08 01:12:38.000000000 +0200
@@ -17,13 +17,13 @@
#include
#include
#include
+#include
#include
+#include
#include "libudev.h"
#include "libudev-private.h"
-static int devices_sort(struct udev_enumerate *udev_enumerate);
-
/**
* SECTION:libudev-enumerate
* @short_description: lookup and sort sys devices
@@ -32,6 +32,11 @@
* and return a sorted list of devices.
*/
+struct syspath {
+ char *syspath;
+ size_t len;
+};
+
/**
* udev_enumerate:
*
@@ -46,7 +51,10 @@
struct udev_list_node subsystem_nomatch_list;
struct udev_list_node properties_match_list;
struct udev_list_node devices_list;
- int devices_sorted;
+ struct syspath *devices;
+ unsigned int devices_cur;
+ unsigned int devices_max;
+ bool devices_uptodate:1;
};
/**
@@ -64,12 +72,12 @@
return NULL;
udev_enumerate->refcount = 1;
udev_enumerate->udev = udev;
- udev_list_init(&udev_enumerate->devices_list);
udev_list_init(&udev_enumerate->sysattr_match_list);
udev_list_init(&udev_enumerate->sysattr_nomatch_list);
udev_list_init(&udev_enumerate->subsystem_match_list);
udev_list_init(&udev_enumerate->subsystem_nomatch_list);
udev_list_init(&udev_enumerate->properties_match_list);
+ udev_list_init(&udev_enumerate->devices_list);
return udev_enumerate;
}
@@ -98,17 +106,22 @@
**/
void udev_enumerate_unref(struct udev_enumerate *udev_enumerate)
{
+ unsigned int i;
+
if (udev_enumerate == NULL)
return;
udev_enumerate->refcount--;
if (udev_enumerate->refcount > 0)
return;
- udev_list_cleanup_entries(udev_enumerate->udev, &udev_enumerate->devices_list);
udev_list_cleanup_entries(udev_enumerate->udev, &udev_enumerate->sysattr_match_list);
udev_list_cleanup_entries(udev_enumerate->udev, &udev_enumerate->sysattr_nomatch_list);
udev_list_cleanup_entries(udev_enumerate->udev, &udev_enumerate->subsystem_match_list);
udev_list_cleanup_entries(udev_enumerate->udev, &udev_enumerate->subsystem_nomatch_list);
udev_list_cleanup_entries(udev_enumerate->udev, &udev_enumerate->properties_match_list);
+ udev_list_cleanup_entries(udev_enumerate->udev, &udev_enumerate->devices_list);
+ for (i = 0; i < udev_enumerate->devices_cur; i++)
+ free(udev_enumerate->devices[i].syspath);
+ free(udev_enumerate->devices);
free(udev_enumerate);
}
@@ -125,6 +138,75 @@
return udev_enumerate->udev;
}
+static int syspath_add(struct udev_enumerate *udev_enumerate, const char *syspath)
+{
+ char *path;
+ struct syspath *entry;
+
+ /* double array size if needed */
+ if (udev_enumerate->devices_cur >= udev_enumerate->devices_max) {
+ struct syspath *buf;
+ unsigned int add;
+
+ add = udev_enumerate->devices_max;
+ if (add < 1024)
+ add = 1024;
+ buf = realloc(udev_enumerate->devices, (udev_enumerate->devices_max + add) * sizeof(struct syspath));
+ if (buf == NULL)
+ return -ENOMEM;
+ udev_enumerate->devices = buf;
+ udev_enumerate->devices_max += add;
+ }
+
+ path = strdup(syspath);
+ if (path == NULL)
+ return -ENOMEM;
+ entry = &udev_enumerate->devices[udev_enumerate->devices_cur];
+ entry->syspath = path;
+ entry->len = strlen(path);
+ udev_enumerate->devices_cur++;
+ udev_enumerate->devices_uptodate = false;
+ return 0;
+}
+
+static int syspath_cmp(const void *p1, const void *p2)
+{
+ const struct syspath *path1 = p1;
+ const struct syspath *path2 = p2;
+ size_t len;
+ int ret;
+
+ len = MIN(path1->len, path2->len);
+ ret = memcmp(path1->syspath, path2->syspath, len);
+ if (ret == 0) {
+ if (path1->len < path2->len)
+ ret = -1;
+ else if (path1->len > path2->len)
+ ret = 1;
+ }
+ return ret;
+}
+
+static int devices_delay(struct udev *udev, const char *syspath)
+{
+ static const char *delay_device_list[] = {
+ "/block/md",
+ "/block/dm-",
+ NULL
+ };
+ size_t len;
+ int i;
+
+ len = strlen(udev_get_sys_path(udev));
+ for (i = 0; delay_device_list[i] != NULL; i++) {
+ if (strstr(&syspath[len], delay_device_list[i]) != NULL) {
+ dbg(udev, "delaying: %s\n", syspath);
+ return 1;
+ }
+ }
+ return 0;
+}
+
/**
* udev_enumerate_get_list_entry:
* @udev_enumerate: context
@@ -135,8 +217,46 @@
{
if (udev_enumerate == NULL)
return NULL;
- if (!udev_enumerate->devices_sorted)
- devices_sort(udev_enumerate);
+ if (!udev_enumerate->devices_uptodate) {
+ unsigned int i;
+ unsigned int max;
+ struct syspath *prev = NULL;
+
+ udev_list_cleanup_entries(udev_enumerate->udev, &udev_enumerate->devices_list);
+ qsort(udev_enumerate->devices, udev_enumerate->devices_cur, sizeof(struct syspath), syspath_cmp);
+
+ max = udev_enumerate->devices_cur;
+ for (i = 0; i < max; i++) {
+ struct syspath *entry = &udev_enumerate->devices[i];
+
+ /* skip duplicated entries */
+ if (prev != NULL &&
+ entry->len == prev->len &&
+ memcmp(entry->syspath, prev->syspath, entry->len) == 0)
+ continue;
+ prev = entry;
+
+ /* skip to be delayed devices, and add them to the end of the list */
+ if (devices_delay(udev_enumerate->udev, entry->syspath)) {
+ syspath_add(udev_enumerate, entry->syspath);
+ continue;
+ }
+
+ udev_list_entry_add(udev_enumerate->udev, &udev_enumerate->devices_list,
+ entry->syspath, NULL, 0, 0);
+ }
+ /* add and cleanup delayed devices from end of list */
+ for (i = max; i < udev_enumerate->devices_cur; i++) {
+ struct syspath *entry = &udev_enumerate->devices[i];
+
+ udev_list_entry_add(udev_enumerate->udev, &udev_enumerate->devices_list,
+ entry->syspath, NULL, 0, 0);
+ free(entry->syspath);
+ }
+ udev_enumerate->devices_cur = max;
+
+ udev_enumerate->devices_uptodate = true;
+ }
return udev_list_get_entry(&udev_enumerate->devices_list);
}
@@ -222,7 +342,7 @@
{
struct udev_device *device;
const char *val = NULL;
- int match = 0;
+ bool match = false;
device = udev_device_new_from_syspath(udev, syspath);
if (device == NULL)
@@ -231,11 +351,11 @@
if (val == NULL)
goto exit;
if (match_val == NULL) {
- match = 1;
+ match = true;
goto exit;
}
if (fnmatch(match_val, val, 0) == 0) {
- match = 1;
+ match = true;
goto exit;
}
exit:
@@ -293,7 +413,7 @@
{
struct udev_device *dev;
struct udev_list_entry *list_entry;
- int match = 0;
+ int match = false;
/* no match always matches */
if (udev_list_get_entry(&udev_enumerate->properties_match_list) == NULL)
@@ -318,13 +438,13 @@
if (fnmatch(match_key, dev_key, 0) != 0)
continue;
if (match_value == NULL && dev_value == NULL) {
- match = 1;
+ match = true;
goto out;
}
if (match_value == NULL || dev_value == NULL)
continue;
if (fnmatch(match_value, dev_value, 0) == 0) {
- match = 1;
+ match = true;
goto out;
}
}
@@ -375,7 +495,7 @@
continue;
if (!match_property(udev_enumerate, syspath))
continue;
- udev_list_entry_add(udev, &udev_enumerate->devices_list, syspath, NULL, 1, 1);
+ syspath_add(udev_enumerate, syspath);
}
closedir(dir);
return 0;
@@ -422,50 +542,6 @@
return 0;
}
-static int devices_delay(struct udev *udev, const char *syspath)
-{
- static const char *delay_device_list[] = {
- "/block/md",
- "/block/dm-",
- NULL
- };
- size_t len;
- int i;
-
- len = strlen(udev_get_sys_path(udev));
- for (i = 0; delay_device_list[i] != NULL; i++) {
- if (strstr(&syspath[len], delay_device_list[i]) != NULL) {
- dbg(udev, "delaying: %s\n", syspath);
- return 1;
- }
- }
- return 0;
-}
-
-/* sort delayed devices to the end of the list */
-static int devices_sort(struct udev_enumerate *udev_enumerate)
-{
- struct udev_list_entry *entry_loop;
- struct udev_list_entry *entry_tmp;
- struct udev_list_node devices_list;
-
- udev_list_init(&devices_list);
- /* move delayed to delay list */
- udev_list_entry_foreach_safe(entry_loop, entry_tmp, udev_list_get_entry(&udev_enumerate->devices_list)) {
- if (devices_delay(udev_enumerate->udev, udev_list_entry_get_name(entry_loop))) {
- udev_list_entry_remove(entry_loop);
- udev_list_entry_append(entry_loop, &devices_list);
- }
- }
- /* move delayed back to end of list */
- udev_list_entry_foreach_safe(entry_loop, entry_tmp, udev_list_get_entry(&devices_list)) {
- udev_list_entry_remove(entry_loop);
- udev_list_entry_append(entry_loop, &udev_enumerate->devices_list);
- }
- udev_enumerate->devices_sorted = 1;
- return 0;
-}
-
/**
* udev_enumerate_add_syspath:
* @udev_enumerate: context
@@ -477,7 +553,6 @@
*/
int udev_enumerate_add_syspath(struct udev_enumerate *udev_enumerate, const char *syspath)
{
- struct udev *udev = udev_enumerate_get_udev(udev_enumerate);
struct udev_device *udev_device;
if (udev_enumerate == NULL)
@@ -488,8 +563,7 @@
udev_device = udev_device_new_from_syspath(udev_enumerate->udev, syspath);
if (udev_device == NULL)
return -EINVAL;
- udev_list_entry_add(udev, &udev_enumerate->devices_list,
- udev_device_get_syspath(udev_device), NULL, 1, 1);
+ syspath_add(udev_enumerate, udev_device_get_syspath(udev_device));
udev_device_unref(udev_device);
return 0;
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/udev-144/libudev/libudev-private.h new/udev-145/libudev/libudev-private.h
--- old/udev-144/libudev/libudev-private.h 2009-06-14 17:32:27.000000000 +0200
+++ new/udev-145/libudev/libudev-private.h 2009-07-07 17:51:21.000000000 +0200
@@ -16,7 +16,6 @@
#include "libudev.h"
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-#define UDEV_MAX(a,b) ((a) > (b) ? (a) : (b))
#define READ_END 0
#define WRITE_END 1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/udev-144/libudev/libudev-util-private.c new/udev-145/libudev/libudev-util-private.c
--- old/udev-144/libudev/libudev-util-private.c 2009-06-17 00:33:25.000000000 +0200
+++ new/udev-145/libudev/libudev-util-private.c 2009-07-11 15:25:33.000000000 +0200
@@ -20,6 +20,7 @@
#include
#include
#include
+#include
#include "libudev.h"
#include "libudev-private.h"
@@ -356,7 +357,7 @@
FD_SET(outpipe[READ_END], &readfds);
if (errpipe[READ_END] > 0)
FD_SET(errpipe[READ_END], &readfds);
- fdcount = select(UDEV_MAX(outpipe[READ_END], errpipe[READ_END])+1, &readfds, NULL, NULL, NULL);
+ fdcount = select(MAX(outpipe[READ_END], errpipe[READ_END])+1, &readfds, NULL, NULL, NULL);
if (fdcount < 0) {
if (errno == EINTR)
continue;
@@ -434,11 +435,11 @@
}
waitpid(pid, &status, 0);
if (WIFEXITED(status)) {
- info(udev, "'%s' returned with status %i\n", argv[0], WEXITSTATUS(status));
+ info(udev, "'%s' returned with exitcode %i\n", command, WEXITSTATUS(status));
if (WEXITSTATUS(status) != 0)
err = -1;
} else {
- err(udev, "'%s' abnormal exit\n", command);
+ err(udev, "'%s' unexpected exit with status 0x%04x\n", command, status);
err = -1;
}
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/udev-144/libudev/test-libudev.c new/udev-145/libudev/test-libudev.c
--- old/udev-144/libudev/test-libudev.c 2009-06-15 17:08:03.000000000 +0200
+++ new/udev-145/libudev/test-libudev.c 2009-07-07 23:55:47.000000000 +0200
@@ -329,6 +329,26 @@
test_enumerate_print_list(udev_enumerate);
udev_enumerate_unref(udev_enumerate);
+ printf("enumerate 'net' + duplicated scan + null + zero\n");
+ udev_enumerate = udev_enumerate_new(udev);
+ if (udev_enumerate == NULL)
+ return -1;
+ udev_enumerate_add_match_subsystem(udev_enumerate, "net");
+ udev_enumerate_scan_devices(udev_enumerate);
+ udev_enumerate_scan_devices(udev_enumerate);
+ udev_enumerate_add_syspath(udev_enumerate, "/sys/class/mem/zero");
+ udev_enumerate_add_syspath(udev_enumerate, "/sys/class/mem/null");
+ udev_enumerate_add_syspath(udev_enumerate, "/sys/class/mem/zero");
+ udev_enumerate_add_syspath(udev_enumerate, "/sys/class/mem/null");
+ udev_enumerate_add_syspath(udev_enumerate, "/sys/class/mem/zero");
+ udev_enumerate_add_syspath(udev_enumerate, "/sys/class/mem/null");
+ udev_enumerate_add_syspath(udev_enumerate, "/sys/class/mem/null");
+ udev_enumerate_add_syspath(udev_enumerate, "/sys/class/mem/zero");
+ udev_enumerate_add_syspath(udev_enumerate, "/sys/class/mem/zero");
+ udev_enumerate_scan_devices(udev_enumerate);
+ test_enumerate_print_list(udev_enumerate);
+ udev_enumerate_unref(udev_enumerate);
+
printf("enumerate 'block'\n");
udev_enumerate = udev_enumerate_new(udev);
if (udev_enumerate == NULL)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/udev-144/udev/udevadm-info.c new/udev-145/udev/udevadm-info.c
--- old/udev-144/udev/udevadm-info.c 2009-06-10 15:55:13.000000000 +0200
+++ new/udev-145/udev/udevadm-info.c 2009-07-08 17:05:43.000000000 +0200
@@ -144,15 +144,15 @@
i = udev_device_get_num_fake_partitions(device);
if (i != 0)
- printf("A:%u\n", i);
+ printf("A: %u\n", i);
i = udev_device_get_ignore_remove(device);
if (i != 0)
- printf("R:%u\n", i);
+ printf("R: %u\n", i);
i = udev_device_get_watch_handle(device);
if (i >= 0)
- printf("W:%u\n", i);
+ printf("W: %u\n", i);
udev_list_entry_foreach(list_entry, udev_device_get_devlinks_list_entry(device)) {
len = strlen(udev_get_dev_path(udev_device_get_udev(device)));
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/udev-144/udev/udevadm-monitor.c new/udev-145/udev/udevadm-monitor.c
--- old/udev-144/udev/udevadm-monitor.c 2009-06-07 02:57:53.000000000 +0200
+++ new/udev-145/udev/udevadm-monitor.c 2009-07-07 17:37:09.000000000 +0200
@@ -204,7 +204,7 @@
if (udev_monitor != NULL)
FD_SET(udev_monitor_get_fd(udev_monitor), &readfds);
- fdcount = select(UDEV_MAX(udev_monitor_get_fd(kernel_monitor), udev_monitor_get_fd(udev_monitor))+1,
+ fdcount = select(MAX(udev_monitor_get_fd(kernel_monitor), udev_monitor_get_fd(udev_monitor))+1,
&readfds, NULL, NULL, NULL);
if (fdcount < 0) {
if (errno != EINTR)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/udev-144/udev/udevd.c new/udev-145/udev/udevd.c
--- old/udev-144/udev/udevd.c 2009-06-20 03:42:41.000000000 +0200
+++ new/udev-145/udev/udevd.c 2009-07-13 03:19:51.000000000 +0200
@@ -24,6 +24,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -45,7 +46,7 @@
#define UDEVD_PRIORITY -4
#define UDEV_PRIORITY -2
-static int debug;
+static bool debug;
static void log_fn(struct udev *udev, int priority,
const char *file, int line, const char *fn,
@@ -59,20 +60,20 @@
}
}
-static int debug_trace;
+static bool debug_trace;
static struct udev_rules *rules;
static struct udev_queue_export *udev_queue_export;
static struct udev_ctrl *udev_ctrl;
static struct udev_monitor *monitor;
static int worker_watch[2];
static pid_t settle_pid;
-static int stop_exec_queue;
-static int reload_config;
+static bool stop_exec_queue;
+static bool reload_config;
static int max_childs;
static int childs;
static struct udev_list_node event_list;
static struct udev_list_node worker_list;
-static int udev_exit;
+static bool udev_exit;
static volatile sig_atomic_t worker_exit;
enum poll_fd {
@@ -128,6 +129,8 @@
struct worker {
struct udev_list_node node;
+ struct udev *udev;
+ int refcount;
pid_t pid;
struct udev_monitor *monitor;
enum worker_state state;
@@ -171,14 +174,27 @@
_exit(1);
break;
case SIGTERM:
- worker_exit = 1;
+ worker_exit = true;
break;
}
}
+static struct worker *worker_ref(struct worker *worker)
+{
+ worker->refcount++;
+ return worker;
+}
+
static void worker_unref(struct worker *worker)
{
+ worker->refcount--;
+ if (worker->refcount > 0)
+ return;
+
+ udev_list_node_remove(&worker->node);
udev_monitor_unref(worker->monitor);
+ childs--;
+ info(worker->udev, "worker [%u] cleaned up\n", worker->pid);
free(worker);
}
@@ -201,12 +217,19 @@
worker = calloc(1, sizeof(struct worker));
if (worker == NULL)
return;
+ /* worker + event reference */
+ worker->refcount = 2;
+ worker->udev = event->udev;
pid = fork();
switch (pid) {
case 0: {
- sigset_t mask;
+ sigset_t sigmask;
struct udev_device *dev;
+ struct pollfd pmon = {
+ .fd = udev_monitor_get_fd(worker_monitor),
+ .events = POLLIN,
+ };
udev_queue_export_unref(udev_queue_export);
udev_monitor_unref(monitor);
@@ -225,11 +248,12 @@
sigaction(SIGTERM, &act, NULL);
sigaction(SIGALRM, &act, NULL);
- /* unblock signals */
- sigfillset(&mask);
- sigdelset(&mask, SIGTERM);
- sigdelset(&mask, SIGALRM);
- sigprocmask(SIG_SETMASK, &mask, NULL);
+ /* unblock SIGALRM */
+ sigfillset(&sigmask);
+ sigdelset(&sigmask, SIGALRM);
+ sigprocmask(SIG_SETMASK, &sigmask, NULL);
+ /* SIGTERM is unblocked in ppoll() */
+ sigdelset(&sigmask, SIGTERM);
/* request TERM signal if parent exits */
prctl(PR_SET_PDEATHSIG, SIGTERM);
@@ -237,7 +261,7 @@
/* initial device */
dev = event->dev;
- while (!worker_exit) {
+ do {
struct udev_event *udev_event;
struct worker_message msg;
int err;
@@ -272,20 +296,31 @@
/* send processed event back to libudev listeners */
udev_monitor_send_device(worker_monitor, NULL, dev);
- info(event->udev, "seq %llu processed with %i\n", udev_device_get_seqnum(dev), err);
- udev_device_unref(dev);
- udev_event_unref(udev_event);
-
/* send back the result of the event execution */
msg.exitcode = err;
msg.pid = getpid();
send(worker_watch[WRITE_END], &msg, sizeof(struct worker_message), 0);
- /* wait for more device messages from udevd */
- do
- dev = udev_monitor_receive_device(worker_monitor);
- while (!worker_exit && dev == NULL);
- }
+ info(event->udev, "seq %llu processed with %i\n", udev_device_get_seqnum(dev), err);
+ udev_event_unref(udev_event);
+ udev_device_unref(dev);
+ dev = NULL;
+
+ /* wait for more device messages or signal from udevd */
+ while (!worker_exit) {
+ int fdcount;
+
+ fdcount = ppoll(&pmon, 1, NULL, &sigmask);
+ if (fdcount < 0)
+ continue;
+
+ if (pmon.revents & POLLIN) {
+ dev = udev_monitor_receive_device(worker_monitor);
+ if (dev != NULL)
+ break;
+ }
+ }
+ } while (dev != NULL);
udev_monitor_unref(worker_monitor);
udev_log_close();
@@ -323,17 +358,17 @@
if (worker->state != WORKER_IDLE)
continue;
- worker->event = event;
- worker->state = WORKER_RUNNING;
- event->state = EVENT_RUNNING;
count = udev_monitor_send_device(monitor, worker->monitor, event->dev);
if (count < 0) {
- err(event->udev, "worker [%u] did not accept message, kill it\n", worker->pid);
- event->state = EVENT_QUEUED;
- worker->state = WORKER_KILLED;
+ err(event->udev, "worker [%u] did not accept message %zi (%m), kill it\n", worker->pid, count);
kill(worker->pid, SIGKILL);
+ worker->state = WORKER_KILLED;
continue;
}
+ worker_ref(worker);
+ worker->event = event;
+ worker->state = WORKER_RUNNING;
+ event->state = EVENT_RUNNING;
return;
}
@@ -375,7 +410,7 @@
}
}
-static void worker_kill(int retain)
+static void worker_kill(struct udev *udev, int retain)
{
struct udev_list_node *loop;
int max;
@@ -525,7 +560,9 @@
worker->event->exitcode = msg.exitcode;
event_queue_delete(worker->event);
worker->event = NULL;
- worker->state = WORKER_IDLE;
+ if (worker->state != WORKER_KILLED)
+ worker->state = WORKER_IDLE;
+ worker_unref(worker);
break;
}
}
@@ -547,22 +584,22 @@
if (i >= 0) {
info(udev, "udevd message (SET_LOG_PRIORITY) received, log_priority=%i\n", i);
udev_set_log_priority(udev, i);
- worker_kill(0);
+ worker_kill(udev, 0);
}
if (udev_ctrl_get_stop_exec_queue(ctrl_msg) > 0) {
info(udev, "udevd message (STOP_EXEC_QUEUE) received\n");
- stop_exec_queue = 1;
+ stop_exec_queue = true;
}
if (udev_ctrl_get_start_exec_queue(ctrl_msg) > 0) {
info(udev, "udevd message (START_EXEC_QUEUE) received\n");
- stop_exec_queue = 0;
+ stop_exec_queue = false;
}
if (udev_ctrl_get_reload_rules(ctrl_msg) > 0) {
info(udev, "udevd message (RELOAD_RULES) received\n");
- reload_config = 1;
+ reload_config = true;
}
str = udev_ctrl_get_set_env(ctrl_msg);
@@ -589,7 +626,7 @@
}
free(key);
}
- worker_kill(0);
+ worker_kill(udev, 0);
}
i = udev_ctrl_get_set_max_childs(ctrl_msg);
@@ -631,7 +668,7 @@
ev = (struct inotify_event *)(buf + pos);
if (ev->len) {
dbg(udev, "inotify event: %x for %s\n", ev->mask, ev->name);
- reload_config = 1;
+ reload_config = true;
continue;
}
@@ -666,7 +703,7 @@
switch (signo) {
case SIGINT:
case SIGTERM:
- udev_exit = 1;
+ udev_exit = true;
break;
case SIGCHLD:
while (1) {
@@ -684,31 +721,24 @@
if (worker->pid != pid)
continue;
- /* fail event, if worker died unexpectedly */
- if (worker->event != NULL) {
- int exitcode;
-
- if (WIFEXITED(status))
- exitcode = WEXITSTATUS(status);
- else if (WIFSIGNALED(status))
- exitcode = WTERMSIG(status) + 128;
- else
- exitcode = 0;
- worker->event->exitcode = exitcode;
- err(udev, "worker [%u] unexpectedly returned with %i\n", pid, exitcode);
- event_queue_delete(worker->event);
+ info(udev, "worker [%u] exit\n", pid);
+ if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
+ err(udev, "worker [%u] unexpectedly returned with status 0x%04x\n", pid, status);
+ if (worker->event != NULL) {
+ err(udev, "worker [%u] failed while handling '%s'\n", pid, worker->event->devpath);
+ worker->event->exitcode = -32;
+ event_queue_delete(worker->event);
+ /* drop reference from running event */
+ worker_unref(worker);
+ }
}
-
- udev_list_node_remove(&worker->node);
worker_unref(worker);
- childs--;
- info(udev, "worker [%u] exit\n", pid);
break;
}
}
break;
case SIGHUP:
- reload_config = 1;
+ reload_config = true;
break;
}
}
@@ -746,7 +776,7 @@
int fd;
sigset_t mask;
const char *value;
- int daemonize = 0;
+ int daemonize = false;
int resolve_names = 1;
static const struct option options[] = {
{ "daemon", no_argument, NULL, 'd' },
@@ -777,13 +807,13 @@
switch (option) {
case 'd':
- daemonize = 1;
+ daemonize = true;
break;
case 't':
- debug_trace = 1;
+ debug_trace = true;
break;
case 'D':
- debug = 1;
+ debug = true;
if (udev_get_log_priority(udev) < LOG_INFO)
udev_set_log_priority(udev, LOG_INFO);
break;
@@ -995,7 +1025,7 @@
/* timeout - kill idle workers */
if (fdcount == 0)
- worker_kill(2);
+ worker_kill(udev, 2);
/* event has finished */
if (pfd[FD_WORKER].revents & POLLIN)
@@ -1044,7 +1074,7 @@
if (reload_config) {
struct udev_rules *rules_new;
- worker_kill(0);
+ worker_kill(udev, 0);
rules_new = udev_rules_new(udev, resolve_names);
if (rules_new != NULL) {
udev_rules_unref(rules);
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
--
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org