hal: Branch 'master' - 28 commits

Danny Kukawka dkukawka at kemper.freedesktop.org
Tue Apr 13 07:17:57 PDT 2010


 doc/spec/hal-spec-properties.xml       |   92 +++++++++
 hald/ci-tracker.c                      |    6 
 hald/ck-tracker.c                      |    6 
 hald/create_cache.c                    |    5 
 hald/device.c                          |   21 +-
 hald/device_info.c                     |   17 +
 hald/hald_dbus.c                       |   10 +
 hald/linux/.gitignore                  |    1 
 hald/linux/addons/addon-input.c        |   18 +
 hald/linux/blockdev.c                  |  133 ++++++++------
 hald/linux/device.c                    |  309 +++++++++++++++++----------------
 hald/linux/osspec.c                    |   26 +-
 hald/linux/probing/.gitignore          |   12 -
 hald/linux/probing/Makefile.am         |    4 
 hald/linux/probing/probe-lsb-release.c |  224 +++++++++++++++++++++++
 hald/linux/probing/probe-smbios.c      |    3 
 hald/util.c                            |   13 +
 tools/hal-device.c                     |   21 --
 18 files changed, 668 insertions(+), 253 deletions(-)

New commits:
commit 23267656d59fe56cb6401f65a278c3ee2b32de39
Author: Takashi Iwai <tiwai at suse.de>
Date:   Mon Mar 29 15:40:12 2010 +0200

    fixed hotplug support for e-SATA (dea5997df8966719)
    
    Fixed hotplug support for e-SATA from commit dea5997df8966719
    (bnc#576506 and bnc#590163).

diff --git a/hald/linux/device.c b/hald/linux/device.c
index b384611..aafad71 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -3094,13 +3094,28 @@ out:
 	return rc;
 }
 
+static 
+void check_ahci_port_cmd(const char *sysfs_path, HalDevice *d, int host_num)
+{
+	gchar path[HAL_PATH_MAX];
+	gint port_cmd;
+
+	if (!hal_util_get_int_from_file(sysfs_path, "ahci_port_cmd", &port_cmd, 16)) {
+		snprintf(path, sizeof(path), "%s/scsi_host/host%d", sysfs_path, host_num);
+		 if (!hal_util_get_int_from_file(path, "ahci_port_cmd", &port_cmd, 16))
+			return;
+	}
+
+	hal_device_property_set_int(d, "scsi_host.ahci_port_cmd", port_cmd);
+	hal_device_property_set_bool(d, "scsi_host.hotpluggable", !!(port_cmd & (1 << 21)));
+}
+
 static HalDevice *
 scsi_host_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path)
 {
 	HalDevice *d;
 	gint host_num;
 	const gchar *last_elem;
-	gint port_cmd;
 
 	d = NULL;
 
@@ -3123,14 +3138,8 @@ scsi_host_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *par
 	hal_device_add_capability (d, "scsi_host");
 	hal_device_property_set_string (d, "info.product", "SCSI Host Adapter");
 
-	if (hal_util_get_int_from_file(sysfs_path, "ahci_port_cmd", &port_cmd, 16)) {
-		hal_device_property_set_int(d, "scsi_host.ahci_port_cmd", port_cmd);
-		hal_device_property_set_bool(d, "scsi_host.hotpluggable",
-					     !!(port_cmd & (1 << 21)));
-		hal_device_property_set_bool(parent_dev,
-					     "scsi_host.hotpluggable",
-					     !!(port_cmd & (1 << 21)));
-	}
+	check_ahci_port_cmd(sysfs_path, d, host_num);
+
 out:
 	return d;
 }
commit 00b4ee496fd29c4cc832013d6109b63fafc3be01
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Tue Mar 16 11:11:05 2010 +0100

    added new system.lsb.* properties to the SPEC
    
    Added the new system.lsb.* properties to the SPEC.

diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index 3dffc6d..f4ac87e 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -7478,6 +7478,56 @@ org.freedesktop.Hal.Device.Volume.method_signatures = {'ssas', 'as', 'as'}
                 The serial number of the base board.
               </entry>
             </row>
+            <row>
+              <entry>
+                <literal>system.lsb.version</literal> (string)
+              </entry>
+              <entry>example: 'core-2.0-ia64:core-2.0-noarch:graphics-2.0-ia64:graphics-2.0-noarch'</entry>
+              <entry>No</entry>
+              <entry>
+                The version of the LSB specification against which the distribution is compliant (as provided by lsb_release).
+              </entry>
+            </row>
+            <row>
+              <entry>
+                <literal>system.lsb.distributor_id</literal> (string)
+              </entry>
+              <entry>example: MyDistrib</entry>
+              <entry>No</entry>
+              <entry>
+                The LSB distributor ID (as provided by lsb_release).
+              </entry>
+            </row>
+            <row>
+              <entry>
+                <literal>system.lsb.description</literal> (string)
+              </entry>
+              <entry>example: 'I enjoy using my distrib'</entry>
+              <entry>No</entry>
+              <entry>
+                The LSB single line text description of the distribution (as provided by lsb_release).
+              </entry>
+            </row>
+            <row>
+              <entry>
+                <literal>system.lsb.release</literal> (string)
+              </entry>
+              <entry>example: 1.0RC4</entry>
+              <entry>No</entry>
+              <entry>
+                The LSB release number of the distribution (as provided by lsb_release).
+              </entry>
+            </row>
+            <row>
+              <entry>
+                <literal>system.lsb.codename</literal> (string)
+              </entry>
+              <entry>example: TryIt</entry>
+              <entry>No</entry>
+              <entry>
+                The LSB codename according to the distribution release (as provided by lsb_release).
+              </entry>
+            </row>
           </tbody>
         </tgroup>
       </informaltable>
commit a2890dd1641e3e497cafb18360252e437acd356a
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Tue Mar 16 10:59:37 2010 +0100

    add new prober to get the results of lsb_release
    
    Added new prober to get the results of lsb_release. Parse
    the output and add these new keys:
    - system.lsb.version
    - system.lsb.distributor_id
    - system.lsb.description
    - system.lsb.release
    - system.lsb.codename

diff --git a/hald/linux/osspec.c b/hald/linux/osspec.c
index e339902..a8233fd 100644
--- a/hald/linux/osspec.c
+++ b/hald/linux/osspec.c
@@ -799,6 +799,22 @@ computer_probing_pm_is_supported_helper_done (HalDevice *d, guint32 exit_type,
 }
 
 static void
+computer_probing_lsb_release_helper_done (HalDevice *d, guint32 exit_type,
+                                          gint return_code, gchar **error,
+                                          gpointer data1, gpointer data2)
+{
+        /* Try and set the suspend/hibernate keys using pm-is-supported
+         */
+        if (g_file_test ("/usr/bin/pm-is-supported", G_FILE_TEST_IS_EXECUTABLE)) {
+                hald_runner_run (d, "hal-system-power-pm-is-supported", NULL, HAL_HELPER_TIMEOUT,
+                                 computer_probing_pm_is_supported_helper_done, NULL, NULL);
+        } else {
+                decode_dmi (d);
+        }
+}
+
+
+static void
 get_primary_videocard (HalDevice *d)
 {
         GDir *dir;
@@ -884,14 +900,8 @@ osspec_probe (void)
         /* set the vendor/product of primary video card */
         get_primary_videocard (root);
 
-        /* Try and set the suspend/hibernate keys using pm-is-supported
-         */
-        if (g_file_test ("/usr/bin/pm-is-supported", G_FILE_TEST_IS_EXECUTABLE)) {
-                hald_runner_run (root, "hal-system-power-pm-is-supported", NULL, HAL_HELPER_TIMEOUT,
-                                 computer_probing_pm_is_supported_helper_done, NULL, NULL);
-        } else {
-                decode_dmi (root);
-        }
+        hald_runner_run (root, "hald-probe-lsb-release", NULL, HAL_HELPER_TIMEOUT,
+                         computer_probing_lsb_release_helper_done, NULL, NULL);
 }
 
 DBusHandlerResult
diff --git a/hald/linux/probing/.gitignore b/hald/linux/probing/.gitignore
index d537ee3..1edb416 100644
--- a/hald/linux/probing/.gitignore
+++ b/hald/linux/probing/.gitignore
@@ -4,16 +4,6 @@ Makefile
 Makefile.in
 *.lo
 *.la
-hald-probe-hiddev
-hald-probe-input
-hald-probe-net-bluetooth
-hald-probe-pc-floppy
-hald-probe-printer
-hald-probe-smbios
-hald-probe-storage
-hald-probe-volume
-hald-probe-serial
-hald-probe-ieee1394-unit
-hald-probe-video4linux
+hald-probe-*
 *.o
 *~
diff --git a/hald/linux/probing/Makefile.am b/hald/linux/probing/Makefile.am
index ec7f94d..3b37ca4 100644
--- a/hald/linux/probing/Makefile.am
+++ b/hald/linux/probing/Makefile.am
@@ -20,6 +20,7 @@ libexec_PROGRAMS = 			\
 	hald-probe-serial 		\
 	hald-probe-ieee1394-unit 	\
 	hald-probe-net-bluetooth 	\
+	hald-probe-lsb-release		\
 	hald-probe-video4linux
 endif
 
@@ -53,6 +54,9 @@ hald_probe_ieee1394_unit_LDADD = $(top_builddir)/libhal/libhal.la @DBUS_LIBS@
 hald_probe_net_bluetooth_SOURCES = probe-net-bluetooth.c ../../logger.c
 hald_probe_net_bluetooth_LDADD = $(top_builddir)/libhal/libhal.la @DBUS_LIBS@
 
+hald_probe_lsb_release_SOURCES = probe-lsb-release.c ../../logger.c
+hald_probe_lsb_release_LDADD = $(top_builddir)/libhal/libhal.la
+
 hald_probe_video4linux_SOURCES = probe-video4linux.c ../../logger.c
 hald_probe_video4linux_LDADD = $(top_builddir)/libhal/libhal.la @DBUS_LIBS@
 
diff --git a/hald/linux/probing/probe-lsb-release.c b/hald/linux/probing/probe-lsb-release.c
new file mode 100644
index 0000000..8a83add
--- /dev/null
+++ b/hald/linux/probing/probe-lsb-release.c
@@ -0,0 +1,224 @@
+/***************************************************************************
+ * CVSID: $Id$
+ *
+ * probe-lsb-release.c : Probe LSB information
+ *
+ * Copyright (C) 2010 Danny Kukawka, <danny.kukawka at web.de>
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ **************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "libhal/libhal.h"
+#include "../../logger.h"
+
+#define strbegin(buf, str) (strncmp (buf, str, strlen (str)) == 0)
+
+/* global */
+static char *udi = NULL;
+static LibHalContext *ctx = NULL;
+
+/** 
+ *  setstr:
+ *  @buf:		The non tabbed prefixed, null terminated string
+ *  @str:		The strings to compare with e.g. "Vendor:"
+ *  @prop:		The HAL property to set
+ *
+ *  Returns:		TRUE is found, FALSE otherwise.
+ *
+ *  Finds the start of a null terminated string and sets HAL
+ *  property if valid.
+ */
+static int
+setstr (char *buf, char *str, char *prop)
+{
+	DBusError error;
+	char *value;
+
+	dbus_error_init (&error);
+
+	if (buf[strlen(buf)-1] == '\n')
+		buf[strlen(buf)-1] = '\0';	
+
+	value = buf + strlen (str) + 1;
+	if (strcmp (value, "n/a") == 0)
+		goto out;
+
+	if (!libhal_device_set_property_string (ctx, udi, prop, value, &error))
+		dbus_error_init (&error);
+
+	HAL_DEBUG (("Setting %s='%s'", prop, value));
+	return TRUE;
+
+out:
+	return FALSE;
+}
+
+
+/** 
+ *  main:
+ *  @argc:	Number of arguments given to program
+ *  @argv:	Arguments given to program
+ *
+ *  Returns: 	Return code
+ * 
+ *  Main entry point
+ */
+int 
+main (int argc, char *argv[])
+{
+	int ret;
+	DBusError error;
+	char buf[512];
+	int lsbpipe[2];
+	int nullfd;
+	FILE *f;
+
+	uint i;
+	struct stat s;
+	const char *path = NULL;
+	const char *possible_paths[] = {
+		"/usr/bin/lsb_release",
+		"/bin/lsb_release",
+		"/sbin/lsb_release",
+		"/usr/local/bin/lsb_release",
+        };
+
+	/* assume failure */
+	ret = 1;
+
+	setup_logger ();
+
+	dbus_error_init (&error);
+
+	udi = getenv ("UDI");
+	if (udi == NULL) {
+		HAL_ERROR (("UDI not set"));
+		goto out;
+	}
+
+	if ((ctx = libhal_ctx_init_direct (&error)) == NULL) {
+		HAL_ERROR (("ctx init failed"));
+		goto out;
+	}
+
+
+	/* find the path to lsb_release */
+        for (i = 0; i < sizeof (possible_paths) / sizeof (char *); i++) {
+                if (stat (possible_paths[i], &s) == 0 && S_ISREG (s.st_mode)) {
+                        path = possible_paths[i];
+                        break;
+                }
+        }
+
+        if (path == NULL) {
+                HAL_ERROR(("Could not find lsb_release, exit!"));
+		exit(1);
+	}
+
+	if(pipe (lsbpipe) == -1) {
+		HAL_ERROR(("Could not create pipe (error: '%s'), exit!", strerror(errno)));
+		exit(1);
+	}	
+
+	if ((f = fdopen (lsbpipe[0], "r")) == NULL) {
+		HAL_ERROR(("Could not open file (error: '%s'), exit!", strerror(errno)));
+		exit(1);
+	}
+
+	if ((nullfd = open ("/dev/null", O_RDONLY)) == -1){
+		HAL_ERROR(("Could not open /dev/null (error: '%s'), exit!", strerror(errno)));
+		exit(1);
+	}
+	
+	/* fork the child process */
+	switch (fork ()) {
+	case 0:
+		/* child */
+		
+		dup2 (nullfd, STDIN_FILENO);
+		dup2 (lsbpipe[1], STDOUT_FILENO);
+		close (lsbpipe[0]);
+		close (lsbpipe[1]);
+		
+		/* execute the child */
+		execl (path, path, "-a", NULL);
+		
+		/* throw an error if we ever reach this point */
+		HAL_ERROR (("Failed to execute lsb_release!"));
+		exit (1);
+		break;
+	case -1:
+		HAL_ERROR (("Cannot fork!"));
+		goto out;
+	}
+	
+	/* parent continues from here */
+	
+	/* close unused descriptor */
+	close (lsbpipe[1]);
+	
+	/* read the output of the child */
+	while(fgets (buf, sizeof(buf), f) != NULL)
+	{
+		HAL_DEBUG (("probe-lsb-release, got line: '%s'", buf));
+
+		if (strbegin (buf, "LSB Version:")) {
+			setstr (buf, "LSB Version:", "system.lsb.version");
+		} else if (strbegin (buf, "Distributor ID:")) {
+			setstr (buf, "Distributor ID:", "system.lsb.distributor_id");
+		} else if (strbegin (buf, "Description:")) {
+			setstr (buf, "Description:", "system.lsb.description");
+		} else if (strbegin (buf, "Release:")) {
+			setstr (buf, "Release:", "system.lsb.release");
+		} else if (strbegin (buf, "Codename:")) {
+			setstr (buf, "Codename:", "system.lsb.codename");
+		}
+
+		/* return success only if there was something usefull to parse */
+		ret = 0;
+	}
+
+	/* as read to EOF, close */
+	fclose (f);
+
+out:
+	LIBHAL_FREE_DBUS_ERROR (&error);
+
+	/* free ctx */
+	if (ctx != NULL) {
+		libhal_ctx_shutdown (ctx, &error);
+		LIBHAL_FREE_DBUS_ERROR (&error);
+		libhal_ctx_free (ctx);
+	}
+
+	return ret;
+}
commit c404ccdebe695ed3ad76175b21282b334475373e
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Mon Mar 15 18:59:10 2010 +0100

    added new key scsi.transport to identify FC/iSCSI/SAS
    
    Added new key scsi.transport for SCSI devices to identify e.g.
    FiberChannel, iSCSI or SAS. This allow to handle them in FDI
    files (e.g. set volume.ignore or storage.automount_enabled_hint).

diff --git a/hald/linux/device.c b/hald/linux/device.c
index 95ba3ae..b384611 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -2885,6 +2885,16 @@ scsi_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_d
 	hal_device_property_set_int (d, "scsi.target", target_num);
 	hal_device_property_set_int (d, "scsi.lun", lun_num);
 
+	if (strstr(sysfs_path, "/host") != NULL && strstr(sysfs_path, "/target") != NULL) {
+		if (strstr(sysfs_path, "/rport-") != NULL) {
+			hal_device_property_set_string (d, "scsi.transport", "FC");
+		} else if (strstr(sysfs_path, "/session") != NULL) {
+			hal_device_property_set_string (d, "scsi.transport", "iSCSI");
+		} else if (strstr(sysfs_path, "/port-") != NULL && strstr(sysfs_path, "/end_device-") != NULL) {
+			hal_device_property_set_string (d, "scsi.transport", "SAS");
+		}
+	}
+
 	hal_util_set_driver (d, "info.linux.driver", sysfs_path);
 
 	hal_device_property_set_string (d, "info.product", "SCSI Device");
commit 2f34097e359b8868569e30511d497639f2983566
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Mon Mar 15 19:07:16 2010 +0100

    add scsi.transport property to SPEC
    
    Added new scsi.transport property to SPEC.

diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index 190e93f..3dffc6d 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -2829,6 +2829,32 @@ org.freedesktop.Hal.Device.Volume.method_signatures = {'ssas', 'as', 'as'}
               <entry></entry>
               <entry>The type of this SCSI device is unknwon.</entry>
             </row>
+            <row>
+              <entry>
+                <literal>scsi.transport</literal> (string)
+              </entry>
+              <entry>Example: FC</entry>
+              <entry>No</entry>
+              <entry>The SCSI Transport protocol used by the device.</entry>
+            </row>
+            <row>
+              <entry></entry>
+              <entry>FC</entry>
+              <entry></entry>
+              <entry>This is a SCSI FiberChannel device.</entry>
+            </row>
+            <row>
+              <entry></entry>
+              <entry>iSCSI</entry>
+              <entry></entry>
+              <entry>This is a iSCSI (internet Small Computer System Interface) device.</entry>
+            </row>
+            <row>
+              <entry></entry>
+              <entry>SAS</entry>
+              <entry></entry>
+              <entry>This is a SAS (Serial Attached SCSI) device.</entry>
+            </row>
           </tbody>
         </tgroup>
       </informaltable>
commit 9f1406af4b13c8a164ffa808e81ecc8ed1dc1580
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Mon Mar 15 18:55:15 2010 +0100

    fix storage.bus handling for SCSI
    
    Fixed storage.bus handling for SCSI. Prevent fall through to PCI as
    storage bus. Current HAL marked SCSI storage devices which are not
    usb or ieee1394 get marked with storage.bus=pci and not as scsi.

diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index bdcc475..ff16580 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -1082,12 +1082,14 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
 	if (!is_partition && !is_device_mapper && !is_fakevolume) {
 		const char *udi_it;
 		const char *physdev_udi;
+		const char *scsidev_udi;
 		HalDevice *scsidev;
 		HalDevice *physdev;
 		gboolean is_hotpluggable;
 		gboolean is_removable;
 		gboolean requires_eject;
 		gboolean no_partitions_hint;
+		gboolean was_scsi;
 		const gchar *bus;
 		const gchar *parent_bus;
 
@@ -1096,6 +1098,7 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
 		 *******************************/
 
 		scsidev = NULL;
+		scsidev_udi = NULL;
 		physdev = NULL;
 		physdev_udi = NULL;
 
@@ -1103,6 +1106,7 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
 		is_hotpluggable = FALSE;
 		requires_eject = FALSE;
 		no_partitions_hint = FALSE;
+		was_scsi = FALSE;
 
 		/* defaults */
 		hal_device_property_set_string (d, "storage.bus", "unknown");
@@ -1123,6 +1127,7 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
 		 * start with our parent. On the way, optionally pick up
 		 * the scsi if it exists */
 		udi_it = hal_device_get_udi (parent);
+		
 		while (udi_it != NULL) {
 			HalDevice *d_it;
 
@@ -1199,9 +1204,11 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
 					scsidev = d_it;
 					physdev = d_it;
 					physdev_udi = udi_it;
+					scsidev_udi = udi_it;
 					hal_device_property_set_string (d, "storage.bus", "scsi");
 					hal_device_copy_property (scsidev, "scsi.lun", d, "storage.lun");
 					is_hotpluggable = hal_device_property_get_bool(scsidev, "scsi.hotpluggable");
+					was_scsi = TRUE;
 
 					/* want to continue here, because it may be USB or IEEE1394 */
 				} else if (strcmp (bus, "usb") == 0) {
@@ -1251,10 +1258,18 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
 					hal_device_property_set_string (d, "storage.bus", "vio");
 					break;
 				} else if (strcmp (bus, "pci") == 0) {
-					physdev = d_it;
-					physdev_udi = udi_it;
-					hal_device_property_set_string (d, "storage.bus", "pci");
-					break;
+					if (was_scsi) {
+						/* lets assume we are SCSI but not usb or ieee1394 */
+						physdev = scsidev;
+						physdev_udi = scsidev_udi;
+						hal_device_property_set_string (d, "storage.bus", "scsi");
+						break;
+					} else {
+						physdev = d_it;
+						physdev_udi = udi_it;
+						hal_device_property_set_string (d, "storage.bus", "pci");
+						break;
+					}
 				}
 			}
 
@@ -1360,6 +1375,7 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
 				HAL_WARNING (("scsi.type is unknown"));
 				goto error;
 			}
+
 			hal_device_copy_property (parent, "scsi.type", d, "storage.drive_type");
 			hal_device_copy_property (parent, "scsi.vendor", d, "storage.vendor");
 			hal_device_copy_property (parent, "scsi.model", d, "storage.model");
@@ -1430,7 +1446,7 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
 					hal_device_property_set_string (d, "storage.drive_type", "disk");
 				}
 			}
-		}
+		} 
 
 		hal_device_property_set_string (d, "info.category", "storage");
 		hal_device_add_capability (d, "storage");
commit bcbd8cb90b2570187417c0579530c36576923f73
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Mon Mar 15 18:51:42 2010 +0100

    fixed compiler warnings from cgcc
    
    Fixed compiler warnings from cgcc.

diff --git a/tools/hal-device.c b/tools/hal-device.c
index 38458a5..c82518b 100644
--- a/tools/hal-device.c
+++ b/tools/hal-device.c
@@ -74,11 +74,6 @@ int add_udi(LibHalContext *hal_ctx, char *arg);
 void process_property(LibHalContext *hal_ctx, char *buf, lh_prop_t **prop);
 int add_properties(LibHalContext *hal_ctx, new_dev_t *nd, lh_prop_t *prop);
 lh_prop_t *free_properties(lh_prop_t *prop);
-static char *skip_space(char *s);
-static char *skip_non_eq_or_space(char *s);
-static char *skip_number(char *s);
-static char *skip_nonquote(char *s);
-
 
 new_dev_t new_dev;
 
@@ -89,11 +84,11 @@ struct {
 	char *udi;
 } opt;
 
-struct option options[] = {
+static struct option options[] = {
 	{ "remove", 1, NULL, 'r' },
 	{ "add", 1, NULL, 'a' },
 	{ "help", 0, NULL, 'h' },
-	{ 0, 0, 0, 0 }
+	{ NULL , 0, NULL , 0 }
 };
 
 
@@ -168,7 +163,7 @@ int main(int argc, char **argv)
 }
 
 
-void help()
+void help(void)
 {
 	fprintf(stderr,
 		"usage: hal-device [--help] [--add udi] [--remove udi] [udi]\n"
@@ -419,7 +414,7 @@ int add_udi(LibHalContext *hal_ctx, char *arg)
 }
 
 
-char *skip_space(char *s)
+static char *skip_space(char *s)
 {
 	while (isspace(*s)) s++;
 
@@ -427,7 +422,7 @@ char *skip_space(char *s)
 }
 
 
-char *skip_non_eq_or_space(char *s)
+static char *skip_non_eq_or_space(char *s)
 {
 	while (*s && *s != '=' && !isspace(*s))
 		s++;
@@ -435,8 +430,7 @@ char *skip_non_eq_or_space(char *s)
 	return s;
 }
 
-
-char *skip_number(char *s)
+static char *skip_number(char *s)
 {
 	while (*s == '-' || *s == '+' || *s == '.' || isdigit(*s))
 		s++;
@@ -444,8 +438,7 @@ char *skip_number(char *s)
 	return s;
 }
 
-
-char *skip_nonquote(char *s)
+static char *skip_nonquote(char *s)
 {
 	while (*s && *s != '\'')
 		s++;
commit 829968ed2ace38908db3ead8204d544d7198159f
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Mar 11 13:48:03 2010 +0100

    updated SPEC due to new properties from commit dea5997df896
    
    Updated SPEC due to new properties from commit dea5997df896.
    Added new:
    - scsi.hotpluggable
    - scsi_host.hotpluggable

diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index fdfacf1..190e93f 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -2755,6 +2755,14 @@ org.freedesktop.Hal.Device.Volume.method_signatures = {'ssas', 'as', 'as'}
             </row>
             <row>
               <entry>
+                <literal>scsi.hotpluggable</literal> (bool)
+              </entry>
+              <entry></entry>
+              <entry>No</entry>
+              <entry>The SCSI device can be removed while the system is running (e.g. in case of eSATA)</entry>
+            </row>
+            <row>
+              <entry>
                 <literal>scsi.type</literal> (string)
               </entry>
               <entry>Example: disk</entry>
@@ -2856,6 +2864,14 @@ org.freedesktop.Hal.Device.Volume.method_signatures = {'ssas', 'as', 'as'}
               <entry>Yes</entry>
               <entry>A unique number identifying the SCSI host adaptor</entry>
             </row>
+            <row>
+              <entry>
+                <literal>scsi_host.hotpluggable</literal> (bool)
+              </entry>
+              <entry></entry>
+              <entry>No</entry>
+              <entry>The host device can be removed while the system is running</entry>
+            </row>
           </tbody>
         </tgroup>
       </informaltable>
commit 1b998b3d6d417fb47fdbed22743b39016a18efc3
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Mar 11 13:42:59 2010 +0100

    add *.orig to hald/linux/.gitignore
    
    Added *.orig to hald/linux/.gitignore

diff --git a/hald/linux/.gitignore b/hald/linux/.gitignore
index 4bec0e4..7ded558 100644
--- a/hald/linux/.gitignore
+++ b/hald/linux/.gitignore
@@ -6,3 +6,4 @@ Makefile.in
 *.la
 *.o
 *~
+*.orig
commit dea5997df8966719d707b7136621ffd37f69a4d7
Author: Takashi Iwai <tiwai at suse.de>
Date:   Thu Mar 11 13:40:57 2010 +0100

    add hotplug support for e-SATA
    
    Add hotplug support for e-SATA (bnc#576506); hotpluggable flag
    is set if ahci_cmd_port is exported in sysfs (available in the
    recent kernel)

diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index d01e707..bdcc475 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -1201,6 +1201,8 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
 					physdev_udi = udi_it;
 					hal_device_property_set_string (d, "storage.bus", "scsi");
 					hal_device_copy_property (scsidev, "scsi.lun", d, "storage.lun");
+					is_hotpluggable = hal_device_property_get_bool(scsidev, "scsi.hotpluggable");
+
 					/* want to continue here, because it may be USB or IEEE1394 */
 				} else if (strcmp (bus, "usb") == 0) {
 					physdev = d_it;
diff --git a/hald/linux/device.c b/hald/linux/device.c
index c61cc69..95ba3ae 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -2932,6 +2932,10 @@ scsi_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_d
 		hal_device_property_set_string (d, "scsi.type", "unknown");
 	}
 
+	if (hal_device_has_property(parent_dev, "scsi_host.hotpluggable"))
+		hal_device_property_set_bool(d, "scsi.hotpluggable",
+			hal_device_property_get_bool(parent_dev, "scsi_host.hotpluggable"));
+
 out:
 	return d;
 }
@@ -3086,6 +3090,7 @@ scsi_host_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *par
 	HalDevice *d;
 	gint host_num;
 	const gchar *last_elem;
+	gint port_cmd;
 
 	d = NULL;
 
@@ -3107,6 +3112,15 @@ scsi_host_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *par
 	hal_device_property_set_string (d, "info.category", "scsi_host");
 	hal_device_add_capability (d, "scsi_host");
 	hal_device_property_set_string (d, "info.product", "SCSI Host Adapter");
+
+	if (hal_util_get_int_from_file(sysfs_path, "ahci_port_cmd", &port_cmd, 16)) {
+		hal_device_property_set_int(d, "scsi_host.ahci_port_cmd", port_cmd);
+		hal_device_property_set_bool(d, "scsi_host.hotpluggable",
+					     !!(port_cmd & (1 << 21)));
+		hal_device_property_set_bool(parent_dev,
+					     "scsi_host.hotpluggable",
+					     !!(port_cmd & (1 << 21)));
+	}
 out:
 	return d;
 }
commit d42ba7af860b08c9c9246703643d1110f6efc22c
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Mar 11 13:36:43 2010 +0100

    fix drm_compute_udi()
    
    Fix drm_compute_udi() to prevent such udi's:
    /org/freedesktop/Hal/devices/pci_1002_71c5_drm__null__card0
    
    Use drm.dri_library only if the property is really set.

diff --git a/hald/linux/device.c b/hald/linux/device.c
index 6ee20b8..c61cc69 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -557,12 +557,19 @@ drm_compute_udi (HalDevice *d)
 
 	name = hal_util_get_last_element(dir);
 
-	/* generate e.g.: /org/freedesktop/Hal/devices/pci_8086_2a02_drm_i915_card0 */
-	hald_compute_udi (udi, sizeof (udi),
-			  "%s_drm_%s_%s",
-			  hal_device_property_get_string (d, "info.parent"),
-			  hal_device_property_get_string (d, "drm.dri_library"),
-			  name);
+	if (hal_device_has_property (d, "drm.dri_library")) {
+		/* generate e.g.: /org/freedesktop/Hal/devices/pci_8086_2a02_drm_i915_card0 */
+		hald_compute_udi (udi, sizeof (udi),
+				  "%s_drm_%s_%s",
+				  hal_device_property_get_string (d, "info.parent"),
+				  hal_device_property_get_string (d, "drm.dri_library"),
+				  name);
+	} else {
+		hald_compute_udi (udi, sizeof (udi),
+				  "%s_drm_%s",
+				  hal_device_property_get_string (d, "info.parent"),
+				  name);
+	}
 
 	hal_device_set_udi (d, udi);
 
commit 96a4b208757d5bd922571c04f9b2d85bba8ed10f
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Tue Mar 9 12:20:34 2010 +0100

    event_io(): always use the same exit
    
    Changed event_io() to always use the same exit and cleanup.

diff --git a/hald/linux/addons/addon-input.c b/hald/linux/addons/addon-input.c
index 0c4cbec..37599ec 100644
--- a/hald/linux/addons/addon-input.c
+++ b/hald/linux/addons/addon-input.c
@@ -229,7 +229,7 @@ event_io (GIOChannel *channel, GIOCondition condition, gpointer data)
 		if (input_data->offset + read_bytes < sizeof (struct input_event)) {
 			input_data->offset = input_data->offset + read_bytes;
 			HAL_DEBUG (("incomplete read"));
-			return TRUE;
+			goto out;
 		} else {
 			input_data->offset = 0;
 		}
@@ -303,7 +303,7 @@ event_io (GIOChannel *channel, GIOCondition condition, gpointer data)
 			/* this is a key repeat and should be ignored for the sleep key */
 			if (input_data->event.code == KEY_SLEEP && input_data->event.value == 2) {
 				HAL_INFO (("key release event for KEY_SLEEP, ignoring"));
-				return TRUE;
+				goto out;	
 			}
 
 			libhal_device_emit_condition (ctx, input_data->udi,
@@ -314,6 +314,7 @@ event_io (GIOChannel *channel, GIOCondition condition, gpointer data)
 		}
 	}
 
+out:
 	LIBHAL_FREE_DBUS_ERROR (&error);
 
 	return TRUE;
commit 05b243e5aa70ee413f135eb383f0ad379bfceee2
Author: Holger Macht <hmacht at suse.de>
Date:   Tue Mar 9 12:11:22 2010 +0100

    fix SLEEP key for some broken BIOSe
    
    Some BIOSe are broken and create infinite key press events for
    the sleep key (FN-F5). So ignore all key repeats for the SLEEP
    key. (bnc#525959)

diff --git a/hald/linux/addons/addon-input.c b/hald/linux/addons/addon-input.c
index 1d6fcbc..0c4cbec 100644
--- a/hald/linux/addons/addon-input.c
+++ b/hald/linux/addons/addon-input.c
@@ -300,6 +300,12 @@ event_io (GIOChannel *channel, GIOCondition condition, gpointer data)
 				}
 			}
 		} else if (input_data->event.type == EV_KEY && key_name[input_data->event.code] != NULL && input_data->event.value) {
+			/* this is a key repeat and should be ignored for the sleep key */
+			if (input_data->event.code == KEY_SLEEP && input_data->event.value == 2) {
+				HAL_INFO (("key release event for KEY_SLEEP, ignoring"));
+				return TRUE;
+			}
+
 			libhal_device_emit_condition (ctx, input_data->udi,
 						      "ButtonPressed",
 						      key_name[input_data->event.code],
commit a3ea90ad7c3d17888df173ffec84a4798264d88c
Merge: c81927e... 597c1ff...
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Wed Mar 10 10:11:35 2010 +0100

    Merge branch 'master' of ssh://dkukawka@git.freedesktop.org/git/hal

commit c81927e3575bba4b1dc7c2bd2ff8d40883239dae
Author: Stephan Kulow <coolo at suse.de>
Date:   Mon Feb 22 16:39:04 2010 +0100

    do not crash on unhandled rules (bnc#537452)
    
    Do not crash on unhandled rules (bnc#537452)

diff --git a/hald/device_info.c b/hald/device_info.c
index 1056733..27f73d5 100644
--- a/hald/device_info.c
+++ b/hald/device_info.c
@@ -1142,7 +1142,9 @@ rules_match_and_merge_device (void *fdi_rules_list, HalDevice *d)
 			rule = di_jump(rule);
 			break;
 		}
-		rule = di_next(rule);
+
+		if (rule)
+			rule = di_next(rule);
 	}
 }
 
commit 534beb6766ebc78543c94dc4b760c32312a62289
Merge: a1718c6... 9c940ee...
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Mon Feb 22 16:15:31 2010 +0100

    Merge branch 'master' of ssh://dkukawka@git.freedesktop.org/git/hal

commit a1718c626d9247daafc53ec374154d2a4736c736
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Fri Nov 27 11:15:57 2009 +0100

    fixed indentation
    
    Fixed indentation in device.c

diff --git a/hald/linux/device.c b/hald/linux/device.c
index 2d3800d..824046c 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -273,10 +273,8 @@ ccw_add_dasd_properties (HalDevice *d, const gchar *sysfs_path)
 {
 	const gchar *disc;
 	
-	hal_util_set_int_from_file (d, "ccw.dasd.use_diag", sysfs_path,
-				    "use_diag", 2);
-	hal_util_set_int_from_file (d, "ccw.dasd.readonly", sysfs_path,
-				    "readonly", 2);
+	hal_util_set_int_from_file (d, "ccw.dasd.use_diag", sysfs_path, "use_diag", 2);
+	hal_util_set_int_from_file (d, "ccw.dasd.readonly", sysfs_path, "readonly", 2);
 	disc = hal_util_get_string_from_file (sysfs_path, "discipline");
 	if (disc)
 		hal_device_property_set_string(d, "ccw.dasd.discipline", disc);
@@ -293,10 +291,8 @@ ccw_add_zfcp_properties (HalDevice *d, const gchar *sysfs_path)
 	if (!online)
 		return;
 
-	hal_util_set_int_from_file (d, "ccw.zfcp.in_recovery", sysfs_path,
-				    "in_recovery", 2);
-	hal_util_set_int_from_file (d, "ccw.zfcp.failed", sysfs_path,
-				    "failed", 2);
+	hal_util_set_int_from_file (d, "ccw.zfcp.in_recovery", sysfs_path, "in_recovery", 2);
+	hal_util_set_int_from_file (d, "ccw.zfcp.failed", sysfs_path, "failed", 2);
 }
 
 static inline void
@@ -307,30 +303,24 @@ ccw_add_tape_properties (HalDevice *d, const gchar *sysfs_path)
 	const gchar *state_text[3] = {"unknown", "loaded", "no medium"};
 
 	hal_util_set_string_from_file (d, "ccw.tape.state", sysfs_path, "state");
-    	hal_util_set_string_from_file (d, "ccw.tape.operation", sysfs_path,
-				       "operation");
+    	hal_util_set_string_from_file (d, "ccw.tape.operation", sysfs_path, "operation");
 	/* The following properties are only valid for online devices. */
 	if (!hal_util_get_int_from_file (sysfs_path, "online", &online, 2))
 		return;
 	if (!online)
 		return;
-	hal_util_set_int_from_file (d, "ccw.tape.blocksize", sysfs_path,
-				    "blocksize", 10);
-	if (!hal_util_get_int_from_file (sysfs_path, "medium_state",
-					&medium_state, 10))
+	hal_util_set_int_from_file (d, "ccw.tape.blocksize", sysfs_path, "blocksize", 10);
+	if (!hal_util_get_int_from_file (sysfs_path, "medium_state", &medium_state, 10))
 		return;
-	hal_device_property_set_string (d, "ccw.tape.medium_state",
-					state_text[medium_state]);
+	hal_device_property_set_string (d, "ccw.tape.medium_state", state_text[medium_state]);
 }
 
 static inline void
 ccw_add_3270_properties (HalDevice *d, const gchar *sysfs_path)
 {
-	hal_util_set_int_from_file (d, "ccw.3270.model", sysfs_path,
-				    "model", 10);
+	hal_util_set_int_from_file (d, "ccw.3270.model", sysfs_path, "model", 10);
 	hal_util_set_int_from_file (d, "ccw.3270.rows", sysfs_path, "rows", 10);
-	hal_util_set_int_from_file (d, "ccw.3270.columns", sysfs_path,
-				    "columns", 10);
+	hal_util_set_int_from_file (d, "ccw.3270.columns", sysfs_path, "columns", 10);
 }
 
 static HalDevice *
@@ -360,10 +350,8 @@ ccw_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_de
 
 	hal_device_property_set_string (d, "ccw.bus_id", bus_id);
 	hal_util_set_int_from_file (d, "ccw.online", sysfs_path, "online", 2);
-	hal_util_set_string_from_file (d, "ccw.availablity", sysfs_path,
-				       "availability");
-	hal_util_set_int_from_file (d, "ccw.cmb_enable", sysfs_path,
-				    "cmb_enable", 2);
+	hal_util_set_string_from_file (d, "ccw.availablity", sysfs_path, "availability");
+	hal_util_set_int_from_file (d, "ccw.cmb_enable", sysfs_path, "cmb_enable", 2);
 	hal_util_set_string_from_file (d, "ccw.cutype", sysfs_path, "cutype");
 	hal_util_set_string_from_file (d, "ccw.devtype", sysfs_path, "devtype");
 
@@ -428,82 +416,54 @@ ccwgroup_add_qeth_properties (HalDevice *d, const gchar *sysfs_path)
 	/* Some attributes are not applicable for devices in layer2 mode. */
 	hal_util_get_int_from_file (sysfs_path, "layer2", &is_layer2, 2);
 
-	hal_util_set_string_from_file (d, "ccwgroup.qeth.large_send",
-				       sysfs_path, "large_send");
-	hal_util_set_string_from_file (d, "ccwgroup.qeth.card_type", sysfs_path,
-				       "card_type");
-	hal_util_set_string_from_file (d, "ccwgroup.qeth.checksumming",
-				       sysfs_path, "checksumming");
+	hal_util_set_string_from_file (d, "ccwgroup.qeth.large_send", sysfs_path, "large_send");
+	hal_util_set_string_from_file (d, "ccwgroup.qeth.card_type", sysfs_path, "card_type");
+	hal_util_set_string_from_file (d, "ccwgroup.qeth.checksumming", sysfs_path, "checksumming");
+
 	if (!is_layer2) {
 		/* CH: the next two are only valid for token ring devices */
-		hal_util_set_int_from_file (d,
-					    "ccwgroup.qeth.canonical_macaddr",
-					    sysfs_path, "canonical_macaddr", 2);
-		hal_util_set_string_from_file (d,
-					       "ccwgroup.qeth.broadcast_mode",
-					       sysfs_path, "broadcast_mode");
-		hal_util_set_int_from_file (d, "ccwgroup.qeth.fake_broadcast",
-					    sysfs_path, "fake_broadcast", 2);
-		hal_util_set_int_from_file (d, "ccwgroup.qeth.fake_ll",
-					    sysfs_path, "fake_ll", 2);
+		hal_util_set_int_from_file (d, "ccwgroup.qeth.canonical_macaddr", sysfs_path, "canonical_macaddr", 2);
+		hal_util_set_string_from_file (d, "ccwgroup.qeth.broadcast_mode", sysfs_path, "broadcast_mode");
+		hal_util_set_int_from_file (d, "ccwgroup.qeth.fake_broadcast", sysfs_path, "fake_broadcast", 2);
+		hal_util_set_int_from_file (d, "ccwgroup.qeth.fake_ll", sysfs_path, "fake_ll", 2);
+		hal_util_set_string_from_file (d, "ccwgroup.qeth.route4", sysfs_path, "route4");
+		hal_util_set_string_from_file (d, "ccwgroup.qeth.route6", sysfs_path, "route6");
 	}
+
 	hal_device_property_set_int (d, "ccwgroup.qeth.layer2", is_layer2);
-	hal_util_set_string_from_file (d, "ccwgroup.qeth.portname", sysfs_path,
-				       "portname");
-	hal_util_set_int_from_file (d, "ccwgroup.qeth.portno", sysfs_path,
-				    "portno", 10);
-	hal_util_set_int_from_file (d, "ccwgroup.qeth.buffer_count", sysfs_path,
-				    "buffer_count", 10);
-	hal_util_set_int_from_file (d, "ccwgroup.qeth.add_hhlen", sysfs_path,
-				    "add_hhlen", 10);
-	hal_util_set_string_from_file (d, "ccwgroup.qeth.priority_queueing",
-				       sysfs_path, "priority_queueing");
-	if (!is_layer2) {
-		hal_util_set_string_from_file (d, "ccwgroup.qeth.route4",
-					       sysfs_path, "route4");
-		hal_util_set_string_from_file (d, "ccwgroup.qeth.route6",
-					       sysfs_path, "route6");
-	}
-	hal_util_set_string_from_file (d, "ccwgroup.qeth.state", sysfs_path,
-				       "state");
+	hal_util_set_string_from_file (d, "ccwgroup.qeth.portname", sysfs_path, "portname");
+	hal_util_set_int_from_file (d, "ccwgroup.qeth.portno", sysfs_path, "portno", 10);
+	hal_util_set_int_from_file (d, "ccwgroup.qeth.buffer_count", sysfs_path, "buffer_count", 10);
+	hal_util_set_int_from_file (d, "ccwgroup.qeth.add_hhlen", sysfs_path, "add_hhlen", 10);
+	hal_util_set_string_from_file (d, "ccwgroup.qeth.priority_queueing", sysfs_path, "priority_queueing");
+	hal_util_set_string_from_file (d, "ccwgroup.qeth.state", sysfs_path, "state");
 }
 
 static inline void
 ccwgroup_add_ctc_properties (HalDevice *d, const gchar *sysfs_path)
 {
 	/* CH: use protocol descriptions? */
-	hal_util_set_int_from_file (d, "ccwgroup.ctc.protocol", sysfs_path,
-				    "protocol", 2);
-	hal_util_set_string_from_file (d, "ccwgroup.ctc.type", sysfs_path,
-				       "type");
-	hal_util_set_int_from_file (d, "ccwgroup.ctc.buffer", sysfs_path,
-				    "buffer", 10);
+	hal_util_set_int_from_file (d, "ccwgroup.ctc.protocol", sysfs_path, "protocol", 2);
+	hal_util_set_string_from_file (d, "ccwgroup.ctc.type", sysfs_path, "type");
+	hal_util_set_int_from_file (d, "ccwgroup.ctc.buffer", sysfs_path, "buffer", 10);
 }
 
 static inline void
 ccwgroup_add_lcs_properties (HalDevice *d, const gchar *sysfs_path)
 {
-	hal_util_set_int_from_file (d, "ccwgroup.lcs.portnumber", sysfs_path,
-				    "portno", 10);
-	hal_util_set_string_from_file (d, "ccwgroup.lcs.type", sysfs_path,
-				       "type");
-	hal_util_set_int_from_file (d, "ccwgroup.lcs.lancmd_timeout",
-				    sysfs_path, "lancmd_timeout", 10);
+	hal_util_set_int_from_file (d, "ccwgroup.lcs.portnumber", sysfs_path, "portno", 10);
+	hal_util_set_string_from_file (d, "ccwgroup.lcs.type", sysfs_path, "type");
+	hal_util_set_int_from_file (d, "ccwgroup.lcs.lancmd_timeout", sysfs_path, "lancmd_timeout", 10);
 }
 
 static inline void
 ccwgroup_add_claw_properties (HalDevice *d, const gchar *sysfs_path)
 {
-	hal_util_set_string_from_file (d, "ccwgroup.claw.api_type", sysfs_path,
-				       "api_type");
-	hal_util_set_string_from_file (d, "ccwgroup.claw.adapter_name",
-				       sysfs_path, "adapter_name");
-	hal_util_set_string_from_file (d, "ccwgroup.claw.host_name", sysfs_path,
-				       "host_name");
-	hal_util_set_int_from_file (d, "ccwgroup.claw.read_buffer", sysfs_path,
-				    "read_buffer", 10);
-	hal_util_set_int_from_file (d, "ccwgroup.claw.write_buffer", sysfs_path,
-				    "write_buffer", 10);
+	hal_util_set_string_from_file (d, "ccwgroup.claw.api_type", sysfs_path, "api_type");
+	hal_util_set_string_from_file (d, "ccwgroup.claw.adapter_name", sysfs_path, "adapter_name");
+	hal_util_set_string_from_file (d, "ccwgroup.claw.host_name", sysfs_path, "host_name");
+	hal_util_set_int_from_file (d, "ccwgroup.claw.read_buffer", sysfs_path, "read_buffer", 10);
+	hal_util_set_int_from_file (d, "ccwgroup.claw.write_buffer", sysfs_path, "write_buffer", 10);
 }
 
 static HalDevice *
@@ -517,18 +477,16 @@ ccwgroup_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *pare
 
 	d = hal_device_new ();
 	hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
+
 	if (parent_dev != NULL)
                 hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev));
         else
-                hal_device_property_set_string
-		  (d, "info.parent",
-		   "/org/freedesktop/Hal/devices/computer");
+                hal_device_property_set_string (d, "info.parent", "/org/freedesktop/Hal/devices/computer");
 
 	hal_util_set_driver (d, "info.linux.driver", sysfs_path);
 
 	hal_device_property_set_string (d, "ccwgroup.bus_id", bus_id);
-	hal_util_set_int_from_file (d, "ccwgroup.online", sysfs_path,
-				    "online", 2);
+	hal_util_set_int_from_file (d, "ccwgroup.online", sysfs_path, "online", 2);
 
 	/* Some devices have extra properties. */
 	if (hal_util_get_driver_name (sysfs_path, driver_name)) {
@@ -696,10 +654,8 @@ firewire_add_unit (const gchar *sysfs_path, int unit_id, HalDevice *parent_dev)
 	d = hal_device_new ();
 	hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
 	hal_device_property_set_string (d, "info.subsystem", "ieee1394_unit");
-	hal_device_property_set_string (d, "info.parent",
-					hal_device_get_udi (parent_dev));
-	hal_device_property_set_string (d, "ieee1394_unit.originating_device", 
-					hal_device_get_udi (parent_dev));
+	hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev));
+	hal_device_property_set_string (d, "ieee1394_unit.originating_device", hal_device_get_udi (parent_dev));
 	hal_device_property_set_int (d, "ieee1394_unit.unit_index", unit_id);
 	hal_device_add_capability (d, "ieee1394_unit");
 	hal_util_set_driver (d, "info.linux.driver", sysfs_path);
@@ -1304,10 +1260,8 @@ input_compute_udi (HalDevice *d)
 static inline void
 iucv_add_netiucv_properties (HalDevice *d, const gchar *sysfs_path)
 {
-	hal_util_set_string_from_file (d, "iucv.netiucv.user", sysfs_path,
-				       "user");
-	hal_util_set_int_from_file (d, "iucv.netiucv.buffer", sysfs_path,
-				    "buffer", 10);
+	hal_util_set_string_from_file (d, "iucv.netiucv.user", sysfs_path, "user");
+	hal_util_set_int_from_file (d, "iucv.netiucv.buffer", sysfs_path, "buffer", 10);
 }
 
 static HalDevice *
@@ -2691,6 +2645,7 @@ power_supply_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *
 		hal_device_property_set_string (d, "info.category", "battery");
 		if (battery_type != NULL)
 			hal_device_property_set_string (d, "battery.type", battery_type);
+
 		refresh_battery_slow (d);
 		hal_device_add_capability (d, "battery");
 
@@ -2717,6 +2672,7 @@ power_supply_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *
 	}
 
 	_have_sysfs_power_supply = TRUE;
+
 finish:
 	return d;
 }
@@ -3072,9 +3028,7 @@ missing_scsi_host (const gchar *sysfs_path, HotplugEvent *device_event, HotplugA
 		goto out;
 
 	/* look if host is present */
-	d = hal_device_store_match_key_value_string (hald_get_gdl (),
-						     "linux.sysfs_path",
-						     path);
+	d = hal_device_store_match_key_value_string (hald_get_gdl (), "linux.sysfs_path", path);
 
 	/* skip "add" if host is already created */
 	if (action == HOTPLUG_ACTION_ADD && d != NULL)
@@ -3711,8 +3665,7 @@ ssb_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_de
 
 	hal_util_set_driver (d, "info.linux.driver", sysfs_path);
 
-	hal_device_property_set_string (d, "ssb.bus_id",
-					hal_util_get_last_element (sysfs_path));
+	hal_device_property_set_string (d, "ssb.bus_id", hal_util_get_last_element (sysfs_path));
 	return d;
 }
 
@@ -3765,8 +3718,7 @@ tape_compute_udi (HalDevice *d)
 	gchar udi[256];
 	const gchar *sysfs_name;
 
-	sysfs_name = hal_util_get_last_element (hal_device_property_get_string
-						(d, "linux.sysfs_path"));
+	sysfs_name = hal_util_get_last_element (hal_device_property_get_string (d, "linux.sysfs_path"));
 	if (!sysfs_name)
 		return FALSE;
 
@@ -4351,8 +4303,7 @@ xen_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_de
 
 	hal_util_set_driver (d, "info.linux.driver", sysfs_path);
 
-	hal_device_property_set_string (d, "xen.bus_id",
-					hal_util_get_last_element (sysfs_path));
+	hal_device_property_set_string (d, "xen.bus_id", hal_util_get_last_element (sysfs_path));
 
 	hal_util_set_string_from_file (d, "xen.path", sysfs_path, "nodename");
 
commit afa1765215303e5dc5f6c8d80b9bf9cf1a969aca
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Fri Nov 27 10:55:37 2009 +0100

    small performance fix, don't strcasecmp() if result already known
    
    Small performance fix, don't strcasecmp() if result already known,
    because we have set a special string.

diff --git a/hald/linux/device.c b/hald/linux/device.c
index 2045e13..2d3800d 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -2854,10 +2854,9 @@ rfkill_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent
 	}
 
 	type = hal_util_get_string_from_file (sysfs_path, "type");
-	if (type == NULL)
-		type = "unknown";
-
-	if (strcasecmp (type, "wimax") == 0) {
+	if (type == NULL) {
+		hal_device_property_set_string (d, "killswitch.type", "unknown");
+	} else if (strcasecmp (type, "wimax") == 0) {
 		hal_device_property_set_string (d, "killswitch.type", "wwan");
 	} else { 
 		hal_device_property_set_string (d, "killswitch.type", type);
commit 21a77ced7eec32c9622e84dec1faabbd79e62c73
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Fri Nov 27 10:47:12 2009 +0100

    fixed small compiler warning
    
    Fixed small compiler warning.

diff --git a/hald/linux/device.c b/hald/linux/device.c
index bdc9558..2045e13 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -1203,7 +1203,7 @@ input_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_
 	int eventdev_num;
 	HalDevice *d;
         char *attr_sysfs_path;
-	char *last;       
+	const gchar *last;       
  
         d = NULL;
         attr_sysfs_path = NULL;
commit 0f97f9191286caac2597327c5997d18ad5cc593c
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Fri Nov 27 10:40:40 2009 +0100

    fixed possible sscanf() NULL pointer crashes
    
    Fixed possible sscanf() crashes caused by hal_util_get_last_element()
    returning a NULL pointer (in rare error case) which was used unchecked
    in sscanf() calls.

diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index 68f50dc..d01e707 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -894,6 +894,7 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
 	gboolean is_cciss_device;
         int md_number;
 	char tc;
+	const gchar *last_elem;
 
 	is_device_mapper = FALSE;
         is_fakevolume = FALSE;
@@ -908,11 +909,13 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
 		goto out;
 	}
 
-	if (strcmp (hal_util_get_last_element (sysfs_path), "fakevolume") == 0) {
+	last_elem = hal_util_get_last_element (sysfs_path);
+
+	if (strcmp (last_elem, "fakevolume") == 0) {
 		HAL_INFO (("Handling %s as fakevolume - sysfs_path_real=%s", device_file, sysfs_path_real));
 		is_fakevolume = TRUE;
 		sysfs_path_real = hal_util_get_parent_path (sysfs_path);
-        } else if (sscanf (hal_util_get_last_element (sysfs_path), "md%d%c", &md_number, &tc) == 1) {
+        } else if (last_elem && sscanf (last_elem, "md%d%c", &md_number, &tc) == 1) {
 		HAL_INFO (("Handling %s as MD device", device_file));
                 is_md_device = TRUE;
 		sysfs_path_real = g_strdup (sysfs_path);
diff --git a/hald/linux/device.c b/hald/linux/device.c
index e876a50..bdc9558 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -353,8 +353,7 @@ ccw_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_de
 	if (parent_dev != NULL)
                 hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev));
         else
-                hal_device_property_set_string
-		  (d, "info.parent",
+                hal_device_property_set_string (d, "info.parent",
 		   "/org/freedesktop/Hal/devices/computer");
 
 	hal_util_set_driver (d, "info.linux.driver", sysfs_path);
@@ -744,7 +743,9 @@ firewire_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *pare
 
 	bus_id = hal_util_get_last_element (sysfs_path);
 
-	if (sscanf (bus_id, "fw%d.%d", &device_id, &unit_id) == 2 ) {
+	if (bus_id == NULL) {
+		return NULL;
+	} else if (sscanf (bus_id, "fw%d.%d", &device_id, &unit_id) == 2 ) {
 		return firewire_add_unit (sysfs_path, unit_id, parent_dev);
 	} else if (sscanf (bus_id, "fw%d", &device_id) == 1) {
 		return firewire_add_device (sysfs_path, device_file, parent_dev);
@@ -853,16 +854,18 @@ ide_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_de
 
 	bus_id = hal_util_get_last_element (sysfs_path);
 
-	sscanf (bus_id, "%d.%d", &host, &channel);
-	hal_device_property_set_int (d, "ide.host", host);
-	hal_device_property_set_int (d, "ide.channel", channel);
+	if (bus_id) {
+		sscanf (bus_id, "%d.%d", &host, &channel);
+		hal_device_property_set_int (d, "ide.host", host);
+		hal_device_property_set_int (d, "ide.channel", channel);
 
-	if (channel == 0) {
-		hal_device_property_set_string (d, "info.product", "IDE device (master)");
-	} else {
-		hal_device_property_set_string (d, "info.product", "IDE device (slave)");
+		if (channel == 0) {
+			hal_device_property_set_string (d, "info.product", "IDE device (master)");
+		} else {
+			hal_device_property_set_string (d, "info.product", "IDE device (slave)");
+		}
 	}
-	
+
 	return d;
 }
 
@@ -904,6 +907,9 @@ ieee1394_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *pare
 
 	bus_id = hal_util_get_last_element (sysfs_path);
 
+	if (bus_id == NULL)
+		goto out;
+
 	if (sscanf (bus_id, "fw-host%d", &host_id) == 1)
 		goto out;
 
@@ -1197,7 +1203,8 @@ input_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_
 	int eventdev_num;
 	HalDevice *d;
         char *attr_sysfs_path;
-        
+	char *last;       
+ 
         d = NULL;
         attr_sysfs_path = NULL;
 
@@ -1205,7 +1212,8 @@ input_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_
 		goto out;
 
 	/* only care about evdev input devices */
-	if (sscanf (hal_util_get_last_element (sysfs_path), "event%d", &eventdev_num) != 1)
+	last = hal_util_get_last_element (sysfs_path);
+	if (last == NULL || sscanf (hal_util_get_last_element (sysfs_path), "event%d", &eventdev_num) != 1)
 		goto out;
         
         /* Prior to 2.6.23pre event%d was a child of input%d - after that event%d
@@ -1494,9 +1502,10 @@ memstick_host_add (const gchar *sysfs_path, const gchar *device_file, HalDevice
 	hal_device_property_set_string (d, "info.product", "Memory Stick Host Adapter");
 
 	last_elem = hal_util_get_last_element (sysfs_path);
-	sscanf (last_elem, "memstick%d", &host_num);
-	hal_device_property_set_int (d, "memstick_host.host", host_num);
-
+	if (last_elem != NULL) {
+		sscanf (last_elem, "memstick%d", &host_num);
+		hal_device_property_set_int (d, "memstick_host.host", host_num);
+	}
 out:
 	return d;
 }
@@ -1535,8 +1544,10 @@ mmc_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_de
 	hal_util_set_driver (d, "info.linux.driver", sysfs_path);
 
 	bus_id = hal_util_get_last_element (sysfs_path);
-	sscanf (bus_id, "mmc%d:%x", &host_num, &rca);
-	hal_device_property_set_int (d, "mmc.rca", rca);
+	if (bus_id) {
+		sscanf (bus_id, "mmc%d:%x", &host_num, &rca);
+		hal_device_property_set_int (d, "mmc.rca", rca);
+	}
 	
 	hal_util_set_string_from_file (d, "mmc.cid", sysfs_path, "cid");
 	hal_util_set_string_from_file (d, "mmc.csd", sysfs_path, "csd");
@@ -1631,8 +1642,10 @@ mmc_host_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *pare
 	hal_device_property_set_string (d, "info.product", "MMC/SD Host Adapter");
 
 	last_elem = hal_util_get_last_element (sysfs_path);
-	sscanf (last_elem, "mmc%d", &host_num);
-	hal_device_property_set_int (d, "mmc_host.host", host_num);
+	if (last_elem) {
+		sscanf (last_elem, "mmc%d", &host_num);
+		hal_device_property_set_int (d, "mmc_host.host", host_num);
+	}
 
 	hal_util_set_string_from_file (d, "mmc_host.slot_name", sysfs_path, "slot_name");
 
@@ -1801,6 +1814,7 @@ net_refresh (HalDevice *d)
 	path = hal_device_property_get_string (d, "linux.sysfs_path");
 	ifname = hal_util_get_last_element (path);
 	hal_device_property_set_string (d, "net.interface", ifname);
+
 	return TRUE;
 }
 
@@ -2012,8 +2026,10 @@ pcmcia_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent
 	hal_util_set_driver (d, "info.linux.driver", sysfs_path);
 
 	/* not sure if %d.%d means socket function - need to revisit */
-	sscanf (bus_id, "%d.%d", &socket, &function);
-	hal_device_property_set_int (d, "pcmcia.socket_number", socket);
+	if (bus_id) {
+		sscanf (bus_id, "%d.%d", &socket, &function);
+		hal_device_property_set_int (d, "pcmcia.socket_number", socket);
+	}
 
 	hal_util_set_string_from_file (d, "pcmcia.prod_id1", sysfs_path, "prod_id1");
 	hal_util_set_string_from_file (d, "pcmcia.prod_id2", sysfs_path, "prod_id2");
@@ -2901,7 +2917,7 @@ scsi_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_d
 		goto out;
 
 	bus_id = hal_util_get_last_element (sysfs_path);
-	if (sscanf (bus_id, "%d:%d:%d:%d", &host_num, &bus_num, &target_num, &lun_num) != 4)
+	if (bus_id == NULL || (sscanf (bus_id, "%d:%d:%d:%d", &host_num, &bus_num, &target_num, &lun_num) != 4))
 		goto out;
 
 	d = hal_device_new ();
@@ -3033,7 +3049,7 @@ missing_scsi_host (const gchar *sysfs_path, HotplugEvent *device_event, HotplugA
 
 	/* catch only scsi-devices */
 	last_elem = hal_util_get_last_element (sysfs_path);
-	if (sscanf (last_elem, "%d:%d:%d:%d", &host_num, &bus_num, &target_num, &lun_num) != 4)
+	if (last_elem == NULL || (sscanf (last_elem, "%d:%d:%d:%d", &host_num, &bus_num, &target_num, &lun_num) != 4))
 		goto out;
 
 	/* avoid loops */
@@ -3048,7 +3064,7 @@ missing_scsi_host (const gchar *sysfs_path, HotplugEvent *device_event, HotplugA
 			goto out;
 
 		last_elem = hal_util_get_last_element (path);
-		if (sscanf (last_elem, "host%d", &num) == 1)
+		if (last_elem != NULL && (sscanf (last_elem, "host%d", &num) == 1))
 			break;
 	}
 
@@ -3123,7 +3139,7 @@ scsi_host_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *par
 		goto out;
 
 	last_elem = hal_util_get_last_element (sysfs_path);
-	if (sscanf (last_elem, "host%d", &host_num) != 1)
+	if (last_elem == NULL || (sscanf (last_elem, "host%d", &host_num) != 1))
 		goto out;
 
 	d = hal_device_new ();
@@ -3172,9 +3188,11 @@ sdio_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_d
 	hal_util_set_driver (d, "info.linux.driver", sysfs_path);
 
 	bus_id = hal_util_get_last_element (sysfs_path);
-	sscanf (bus_id, "mmc%d:%x:%d", &host_num, &rca, &card_id);
-	hal_device_property_set_int (d, "sdio.rca", rca);
-	hal_device_property_set_int (d, "sdio.card_id", card_id);
+	if (bus_id != NULL) {
+		sscanf (bus_id, "mmc%d:%x:%d", &host_num, &rca, &card_id);
+		hal_device_property_set_int (d, "sdio.rca", rca);
+		hal_device_property_set_int (d, "sdio.card_id", card_id);
+	}
 
 	hal_util_set_int_from_file (d, "sdio.vendor_id", sysfs_path, "vendor", 16);
 	hal_util_set_int_from_file (d, "sdio.product_id", sysfs_path, "device", 16);
@@ -3752,9 +3770,8 @@ tape_compute_udi (HalDevice *d)
 						(d, "linux.sysfs_path"));
 	if (!sysfs_name)
 		return FALSE;
-	hald_compute_udi (udi, sizeof (udi),
-			  "/org/freedesktop/Hal/devices/tape_%s",
-			  sysfs_name);
+
+	hald_compute_udi (udi, sizeof (udi), "/org/freedesktop/Hal/devices/tape_%s", sysfs_name);
 	hal_device_set_udi (d, udi);
 
 	return TRUE;
@@ -3992,7 +4009,9 @@ usbclass_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *pare
 	}
 
 	last_elem = hal_util_get_last_element (sysfs_path);
-	if (sscanf (last_elem, "hiddev%d", &host_num) == 1) {
+	if (last_elem == NULL) {
+		goto out;
+	} else if (sscanf (last_elem, "hiddev%d", &host_num) == 1) {
 
 		d = hal_device_new ();
 		hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
@@ -4273,7 +4292,7 @@ vmbus_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_
 
 	bus_id = hal_util_get_last_element (sysfs_path);
 	hal_device_property_set_string (d, "vmbus.bus_id", bus_id);
-	if (sscanf (bus_id, "vmbus_%d_%d", &busnum, &devicenum) == 2) {
+	if (bus_id && sscanf (bus_id, "vmbus_%d_%d", &busnum, &devicenum) == 2) {
 		hal_device_property_set_int (d, "vmbus.bus_number", busnum);
 		hal_device_property_set_int (d, "vmbus.device_number", devicenum);
 	}
diff --git a/hald/util.c b/hald/util.c
index d5346ec..9514a8b 100644
--- a/hald/util.c
+++ b/hald/util.c
@@ -98,7 +98,7 @@ hal_util_remove_trailing_slash (gchar *path)
  *  foobar.
  *
  *  @param  path                Path
- *  @return                     Pointer into given string
+ *  @return                     Pointer into given string or NULL in error case
  */
 const gchar *
 hal_util_get_last_element (const gchar *s)
commit 396608559a26a60a2f7b5c709b5aa9466ef56b43
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Fri Nov 27 00:13:39 2009 +0100

    added more strlen related NULL pointer checks
    
    Added more strlen related NULL pointer checks.

diff --git a/hald/ci-tracker.c b/hald/ci-tracker.c
index a1354bb..fcaf0c3 100644
--- a/hald/ci-tracker.c
+++ b/hald/ci-tracker.c
@@ -72,6 +72,9 @@ validate_bus_name (const char *name)
         const char *last_dot;
         gboolean ret;
 
+	if (name == NULL)
+		return FALSE;
+
         s = name;
         len = strlen (name);
         end = name + len;
@@ -201,6 +204,9 @@ ci_tracker_name_owner_changed (CITracker *cit,
                                const char *old_service_name, 
                                const char *new_service_name)
 {
+	if (old_service_name == NULL)
+		return;
+
 	if (strlen (old_service_name) > 0) {
 		CICallerInfo *caller_info;
 
diff --git a/hald/ck-tracker.c b/hald/ck-tracker.c
index ae41b10..c8e1984 100644
--- a/hald/ck-tracker.c
+++ b/hald/ck-tracker.c
@@ -726,6 +726,12 @@ ck_tracker_process_system_bus_message (CKTracker *tracker, DBusMessage *message)
 			goto out;
 		}
 
+		if (new_service_name == NULL || old_service_name == NULL) {
+			HAL_ERROR (("new_service_name == NULL || old_service_name == NULL"));
+			goto out;
+		}
+			
+
 		if (strlen (new_service_name) == 0 && strcmp (name, "org.freedesktop.ConsoleKit") == 0) {
 			HAL_INFO (("uh, oh, ConsoleKit went away!"));
 			ck_tracker_remove_all_seats_and_sessions (tracker);
diff --git a/hald/create_cache.c b/hald/create_cache.c
index ed42b7f..2da91d0 100644
--- a/hald/create_cache.c
+++ b/hald/create_cache.c
@@ -544,6 +544,11 @@ rules_search_and_add_fdi_files (const char *dir, int fd)
 	struct dirent **name_list;
 	int num_skipped_fdi_files;
 
+	if (dir == NULL) {
+		HAL_ERROR (("Given 'dir' == NULL"));
+		goto error;
+	}
+
 	num_skipped_fdi_files = 0;
 
 	num_entries = scandir (dir, &name_list, NULL, _alphasort);
diff --git a/hald/device.c b/hald/device.c
index 72c66f4..70d566c 100644
--- a/hald/device.c
+++ b/hald/device.c
@@ -644,6 +644,11 @@ hal_device_merge_with_rewrite  (HalDevice    *target,
 {
 	merge_rewrite_ud_t ud;
 
+	if (source_namespace == NULL || target_namespace == NULL) {
+		HAL_ERROR(("source_namespace == NULL || target_namespace == NULL"));
+		return;
+	}
+
 	ud.target = target;
 	ud.source_namespace = source_namespace;
 	ud.target_namespace = target_namespace;
@@ -973,13 +978,15 @@ hal_device_property_get_as_string (HalDevice *device, const char *key, char *buf
 					const char *str;
 					
 					str = (const char *) iter->data;
-					len = strlen (str);
-					strncpy (buf + i, str, bufsize - i);
-					i += len;
-
-					if (i < bufsize) {
-						buf[i] = '\t';
-						i++;
+					if (str != NULL) {
+						len = strlen (str);
+						strncpy (buf + i, str, bufsize - i);
+						i += len;
+
+						if (i < bufsize) {
+							buf[i] = '\t';
+							i++;
+						}
 					}
 				}
 			}
diff --git a/hald/device_info.c b/hald/device_info.c
index b755018..1056733 100644
--- a/hald/device_info.c
+++ b/hald/device_info.c
@@ -407,9 +407,14 @@ handle_match (struct rule *rule, HalDevice *d)
 			should_be_empty = FALSE;
 		if (hal_device_property_get_type (d, prop_to_check) != HAL_PROPERTY_TYPE_STRING)
 			return FALSE;
-		if (hal_device_has_property (d, prop_to_check))
-			if (strlen (hal_device_property_get_string (d, prop_to_check)) > 0)
-				is_empty = FALSE;
+		if (hal_device_has_property (d, prop_to_check)) {
+			const char *s;
+			s = hal_device_property_get_string (d, prop_to_check);
+			if (s != NULL) {
+				if (strlen (s) > 0)
+					is_empty = FALSE;
+			}
+		}
 
 		if (should_be_empty) {
 			if (is_empty)
@@ -1033,7 +1038,7 @@ handle_merge (struct rule *rule, HalDevice *d)
 
 		} else {
 			/* only allow <remove key="foobar"/>, not <remove key="foobar">blah</remove> */
-			if (strlen (value) == 0)
+			if (value != NULL && strlen (value) == 0)
 				hal_device_property_remove (d, key);
 		}
 
diff --git a/hald/hald_dbus.c b/hald/hald_dbus.c
index a144f51..63f0cd1 100644
--- a/hald/hald_dbus.c
+++ b/hald/hald_dbus.c
@@ -3561,6 +3561,11 @@ hald_singleton_device_added (const char * command_line,
 	SingletonInfo *info;
 	gchar *extra_env[2] = {NULL, NULL};
 
+	if (command_line == NULL) {
+		HAL_ERROR (("command_line == NULL"));
+		return FALSE;
+	}
+
 	if (!singletons)
 		singletons = g_hash_table_new_full (
 				g_str_hash, g_str_equal,
@@ -5265,6 +5270,11 @@ hald_dbus_filter_function (DBusConnection * connection,
 
 		ci_tracker_name_owner_changed (ci_tracker, name, old_service_name, new_service_name);
 
+		if (old_service_name == NULL) {
+			HAL_ERROR (("old_service_name == NULL"));
+                        goto out;
+		}	
+
 		if (services_with_locks != NULL)
 			services_with_locks_remove_lockowner(old_service_name);
 
diff --git a/hald/linux/addons/addon-input.c b/hald/linux/addons/addon-input.c
index 0a433b1..1d6fcbc 100644
--- a/hald/linux/addons/addon-input.c
+++ b/hald/linux/addons/addon-input.c
@@ -355,9 +355,16 @@ add_device (LibHalContext *ctx,
 	int eventfp;
 	GIOChannel *channel;
 	InputData *data;
-	int len = strlen (udi);
+	int len;
 	const char* device_file;
 
+	if (udi == NULL) {
+		HAL_ERROR(("udi == NULL"));
+		return;
+	}	
+
+	len = strlen (udi);
+
 	data = (InputData*) g_malloc (sizeof (InputData) + len);
 
 	memcpy (&(data->udi), udi, len+1);
diff --git a/hald/linux/device.c b/hald/linux/device.c
index 2eca1ef..e876a50 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -3230,7 +3230,9 @@ serial_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent
 	hal_device_property_set_string (d, "serial.device", device_file);
 
 	last_elem = hal_util_get_last_element(sysfs_path);
-	if (sscanf (last_elem, "ttyS%d", &portnum) == 1) {
+	if (last_elem == NULL) {
+		goto out;
+	} else if (sscanf (last_elem, "ttyS%d", &portnum) == 1) {
 		hal_device_property_set_int (d, "serial.port", portnum);
 		hal_device_property_set_string (d, "serial.type", "platform");
 		hal_device_property_set_string (d, "info.product",
@@ -3388,7 +3390,9 @@ sound_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_
 	hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
 	device = hal_util_get_last_element(sysfs_path);
 
-	if (device_file[0] == '\0' && parent_dev == NULL && parent_path == NULL) {
+	if (device == NULL) {
+		goto out;
+	} else if (device_file[0] == '\0' && parent_dev == NULL && parent_path == NULL) {
 		goto out;
 	} else if (device_file[0] == '\0' && parent_dev != NULL && parent_path != NULL) {
 		HAL_INFO(("sound_add: handle sound card %s", sysfs_path));
diff --git a/hald/linux/probing/probe-smbios.c b/hald/linux/probing/probe-smbios.c
index 0bc9689..270021f 100644
--- a/hald/linux/probing/probe-smbios.c
+++ b/hald/linux/probing/probe-smbios.c
@@ -70,6 +70,9 @@ setstr (char *buf, char *str, char *prop)
 	DBusError error;
 	char *value;
 
+	if (str == NULL)
+		goto out;
+
 	if (strbegin (buf, str)) {
 		dbus_error_init (&error);
 		value = buf + strlen (str) + 1;
commit 92c858454d7d218493542b08164dc1702f077974
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Nov 26 22:33:05 2009 +0100

    added check for NULL pointer to prevent trouble with strlen
    
    Added some checks for NULL pointer in util.c to prevent
    trouble with crash in strlen caused by NULL pointer.

diff --git a/hald/util.c b/hald/util.c
index 5986686..d5346ec 100644
--- a/hald/util.c
+++ b/hald/util.c
@@ -132,6 +132,9 @@ hal_util_get_parent_path (const gchar *path)
 	guint len;
 	gchar *parent_path;
 
+	if (path == NULL)
+		return NULL;
+
 	/* Find parent device by truncating our own path */
 	parent_path = g_strndup (path, HAL_PATH_MAX);
 	len = strlen (parent_path);
@@ -152,6 +155,9 @@ hal_util_get_normalized_path (const gchar *path1, const gchar *path2)
 	const gchar *p2;
 	gchar buf[HAL_PATH_MAX];
 
+	if (path1 == NULL || path2 == NULL)
+		return NULL;
+
 	len1 = strlen (path1);
 	len2 = strlen (path2);
 
@@ -501,6 +507,9 @@ hal_util_grep_file (const gchar *directory, const gchar *file, const gchar *line
 
 	result = NULL;
 
+	if (linestart == NULL)
+		return result;
+
 	/* TODO: use reuse and _grep_can_reuse parameters to avoid loading
 	 *       the file again and again
 	 */
@@ -1200,7 +1209,7 @@ is_valid_interface_name (const char *name) {
 
 	last_dot = NULL;
 
-	if (strlen(name) == 0)
+	if (name == NULL || strlen(name) == 0)
 		return FALSE;	
 
 	end = name + strlen(name);
commit 1849fb1dbc7aa905274134ce5cfa161840390a4a
Merge: 254a0bd... 12ef5a6...
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Nov 26 21:05:19 2009 +0100

    Merge branch 'master' of ssh://dkukawka@git.freedesktop.org/git/hal

commit 254a0bd1083174c4baf573737443ea2fdb81aaa8
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Nov 26 21:01:08 2009 +0100

    added breaks to detection of storage.bus for ccw, vio and pci
    
    Added breaks to detection of storage.bus for ccw, vio and pci
    as e.g. in case of usb or ieee1394 to leave the while loop as
    soon as possible.

diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index 0433400..68f50dc 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -1239,14 +1239,17 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
 					physdev_udi = udi_it;
 					is_hotpluggable = TRUE;
 					hal_device_property_set_string (d, "storage.bus", "ccw");
+					break;
 				} else if (strcmp (bus, "vio") == 0) {
 					physdev = d_it;
 					physdev_udi = udi_it;
 					hal_device_property_set_string (d, "storage.bus", "vio");
+					break;
 				} else if (strcmp (bus, "pci") == 0) {
 					physdev = d_it;
 					physdev_udi = udi_it;
 					hal_device_property_set_string (d, "storage.bus", "pci");
+					break;
 				}
 			}
 
commit 949ea3e42c857a40fed260756093a2d98c1bcc14
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Fri Sep 25 12:14:40 2009 +0200

    fix if/else block to find storage bus
    
    Fixed if/else block to find storage bus. Since info.subsystem
    is a string, there is no need to check for USB after SCSI. Added
    extra USB if block to the SCSI block as 'else if' to prevent
    unneeded double check.

diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index 4bdd6cc..0433400 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -1199,9 +1199,7 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
 					hal_device_property_set_string (d, "storage.bus", "scsi");
 					hal_device_copy_property (scsidev, "scsi.lun", d, "storage.lun");
 					/* want to continue here, because it may be USB or IEEE1394 */
-				}
-
-				if (strcmp (bus, "usb") == 0) {
+				} else if (strcmp (bus, "usb") == 0) {
 					physdev = d_it;
 					physdev_udi = udi_it;
 					is_hotpluggable = TRUE;
commit f73a4aa354961662dc587086eaa71c49626bc4a7
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Fri Sep 25 12:10:03 2009 +0200

    fixed indentation
    
    Fixed indentation in blockdev.c

diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index 7fb15ef..4bdd6cc 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -1140,54 +1140,53 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
 			}
 
                         if (strcmp (udi_it, "/org/freedesktop/Hal/devices/computer") == 0) {
-					physdev = d_it;
-					physdev_udi = udi_it;
-                                        if (is_md_device) {
-                                                char *level;
-                                                char *model_name;
-
-                                                hal_device_property_set_string (d, "storage.bus", "linux_raid");
-
-                                                level = hal_util_get_string_from_file (sysfs_path_real, "md/level");
-                                                if (level == NULL)
-                                                        goto error;
-                                                hal_device_property_set_string (d, "storage.linux_raid.level", level);
-
-                                                hal_device_property_set_string (d, "storage.linux_raid.sysfs_path", sysfs_path_real);
-
-                                                hal_device_property_set_string (d, "storage.vendor", "Linux");
-                                                if (strcmp (level, "linear") == 0) {
-                                                        model_name = g_strdup ("Software RAID (Linear)");
-                                                } else if (strcmp (level, "raid0") == 0) {
-                                                        model_name = g_strdup ("Software RAID-0 (Stripe)");
-                                                } else if (strcmp (level, "raid1") == 0) {
-                                                        model_name = g_strdup ("Software RAID-1 (Mirror)");
-                                                } else if (strcmp (level, "raid5") == 0) {
-                                                        model_name = g_strdup ("Software RAID-5");
-                                                } else {
-                                                        model_name = g_strdup_printf ("Software RAID (%s)", level);
-                                                }
-                                                hal_device_property_set_string (d, "storage.model", model_name);
-                                                g_free (model_name);
-
-                                                hal_util_set_string_from_file (
-                                                        d, "storage.firmware_version", 
-                                                        sysfs_path_real, "md/metadata_version");
-                                                
-                                                hal_device_add_capability (d, "storage.linux_raid");
-
-                                                if (!refresh_md_state (d))
-                                                        goto error;
-
-                                                is_hotpluggable = hal_device_property_get_bool (
-                                                        d, "storage.hotpluggable");
-
-					} else if (is_cciss_device) {
-						HAL_DEBUG (("block_add: parent=/org/freedesktop/Hal/devices/computer, is_cciss_device=true"));
-						hal_device_property_set_string (d, "storage.bus", "cciss");
+				physdev = d_it;
+				physdev_udi = udi_it;
+
+                                if (is_md_device) {
+					char *level;
+					char *model_name;
+
+					hal_device_property_set_string (d, "storage.bus", "linux_raid");
+
+					level = hal_util_get_string_from_file (sysfs_path_real, "md/level");
+					if (level == NULL)
+						goto error;
+
+					hal_device_property_set_string (d, "storage.linux_raid.level", level);
+					hal_device_property_set_string (d, "storage.linux_raid.sysfs_path", sysfs_path_real);
+					hal_device_property_set_string (d, "storage.vendor", "Linux");
+
+					if (strcmp (level, "linear") == 0) {
+						model_name = g_strdup ("Software RAID (Linear)");
+					} else if (strcmp (level, "raid0") == 0) {
+						model_name = g_strdup ("Software RAID-0 (Stripe)");
+					} else if (strcmp (level, "raid1") == 0) {
+						model_name = g_strdup ("Software RAID-1 (Mirror)");
+					} else if (strcmp (level, "raid5") == 0) {
+						model_name = g_strdup ("Software RAID-5");
+					} else {
+						model_name = g_strdup_printf ("Software RAID (%s)", level);
 					}
-                                        break;
-                        }
+
+					hal_device_property_set_string (d, "storage.model", model_name);
+					g_free (model_name);
+
+					hal_util_set_string_from_file (d, "storage.firmware_version", sysfs_path_real, "md/metadata_version");
+
+					hal_device_add_capability (d, "storage.linux_raid");
+
+					if (!refresh_md_state (d))
+						goto error;
+
+					is_hotpluggable = hal_device_property_get_bool (d, "storage.hotpluggable");
+
+				} else if (is_cciss_device) {
+					HAL_DEBUG (("block_add: parent=/org/freedesktop/Hal/devices/computer, is_cciss_device=true"));
+					hal_device_property_set_string (d, "storage.bus", "cciss");
+				}
+				break;
+			}
 
 			/* Check info.subsystem */
 			if ((bus = hal_device_property_get_string (d_it, "info.subsystem")) != NULL) {
commit 4f4ccbdd31edd14bd328d3cefc2fb906223202e1
Merge: 74bf265... 2e5eed0...
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Tue Sep 22 11:19:55 2009 +0200

    Merge branch 'master' of ssh://dkukawka@git.freedesktop.org/git/hal

commit 74bf2659a02c5c0cf96121a8d58f0ee530fe9599
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Tue Aug 18 13:18:51 2009 +0200

    make hal-dockstation-undock-linux executable
    
    Changed hal-dockstation-undock-linux (chmod 744) to be
    executable.

diff --git a/tools/linux/hal-dockstation-undock-linux b/tools/linux/hal-dockstation-undock-linux
old mode 100644
new mode 100755


More information about the hal-commit mailing list