hal: Branch 'master' - 22 commits
Danny Kukawka
dkukawka at kemper.freedesktop.org
Wed Nov 26 06:43:09 PST 2008
doc/spec/hal-spec-properties.xml | 97 ++++++
fdi/policy/10osvendor/10-rfkill-switch.fdi | 4
hald/linux/addons/.gitignore | 1
hald/linux/addons/Makefile.am | 4
hald/linux/addons/addon-ipw-killswitch.c | 4
hald/linux/addons/addon-rfkill-killswitch.c | 373 ++++++++++++++++++++++++
hald/linux/blockdev.c | 184 ++++++++---
hald/linux/coldplug.c | 10
hald/linux/device.c | 142 +++++++++
hald/linux/hotplug.c | 12
hald/linux/hotplug.h | 3
hald/linux/osspec.c | 5
hald/linux/probing/probe-volume.c | 10
tools/linux/hal-system-lcd-get-brightness-linux | 6
tools/linux/hal-system-lcd-set-brightness-linux | 6
15 files changed, 792 insertions(+), 69 deletions(-)
New commits:
commit c3cf2b8b252dd593c4058b9688b5978e3e7ee7cc
Merge: 25f9536... 93579b1...
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Wed Nov 26 15:28:48 2008 +0100
Merge branch 'master' of ssh://dkukawka@people.freedesktop.org/~dkukawka/hal
commit 93579b151700c5c152153661d2800a5b3c0bd6a1
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Thu Nov 20 12:17:18 2008 +0100
fixed ipw addon
Fixed ipw addon, use fputs instead of fputc to set the status
to sysfs.
diff --git a/hald/linux/addons/addon-ipw-killswitch.c b/hald/linux/addons/addon-ipw-killswitch.c
index 674fb9d..866819c 100644
--- a/hald/linux/addons/addon-ipw-killswitch.c
+++ b/hald/linux/addons/addon-ipw-killswitch.c
@@ -155,9 +155,9 @@ set_killswitch (gboolean status)
}
if (status) {
- ret = fputc (0, f);
+ ret = fputs ("0", f);
} else {
- ret = fputc (1, f);
+ ret = fputs ("1", f);
}
if (ret == EOF) {
commit f0ec1d3468bb1be363044380a4782975d80001a3
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Wed Nov 19 20:35:01 2008 +0100
add new killswitch.state property
Added new (not mandatory) killswitch.state property to the killswitch
namespace reflecting the current state of the killswitch as reported
by e.g. the linux kernel.
There are three possible states:
- 0: Radio output (soft) blocked
- 1: Radio output allowed
- 2: Radio output (hard )blocked, non-overrideable via SetPower()
diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index 6d3c09b..2b40f62 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -4778,6 +4778,32 @@ org.freedesktop.Hal.Device.Volume.method_signatures = {'ssas', 'as', 'as'}
</row>
<row>
<entry>
+ <literal>killswitch.state</literal> (int)
+ </entry>
+ <entry></entry>
+ <entry>No</entry>
+ <entry>Current state of the killswitch (as reported by the kernel)</entry>
+ </row>
+ <row>
+ <entry></entry>
+ <entry>0</entry>
+ <entry></entry>
+ <entry>Radio output is blocked</entry>
+ </row>
+ <row>
+ <entry></entry>
+ <entry>1</entry>
+ <entry></entry>
+ <entry>Radio output is allowed/enabled</entry>
+ </row>
+ <row>
+ <entry></entry>
+ <entry>2</entry>
+ <entry></entry>
+ <entry>Radio output is (hard) blocked, non-overrideable via SetPower()</entry>
+ </row>
+ <row>
+ <entry>
<literal>killswitch.name</literal> (string)
</entry>
<entry></entry>
diff --git a/hald/linux/device.c b/hald/linux/device.c
index 6e87dfb..d16ac3a 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -2652,6 +2652,8 @@ rfkill_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent
hal_device_property_set_string (d, "killswitch.type", type);
}
+ hal_util_set_int_from_file (d, "killswitch.state", sysfs_path, "state", 10);
+
hal_device_property_set_string (d, "killswitch.access_method", "rfkill");
hal_util_set_string_from_file (d, "killswitch.name", sysfs_path, "name");
@@ -2664,6 +2666,19 @@ rfkill_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent
}
static gboolean
+rfkill_refresh (HalDevice *d)
+{
+ const char *sysfs_path;
+
+ if ((sysfs_path = hal_device_property_get_string (d, "linux.sysfs_path")) != NULL) {
+ /* refresh the killswitch state */
+ hal_util_set_int_from_file (d, "killswitch.state", sysfs_path, "state", 10);
+ }
+
+ return TRUE;
+}
+
+static gboolean
rfkill_compute_udi (HalDevice *d)
{
gchar udi[256];
@@ -4342,6 +4357,7 @@ static DevHandler dev_handler_rfkill =
.subsystem = "rfkill",
.add = rfkill_add,
.compute_udi = rfkill_compute_udi,
+ .refresh = rfkill_refresh,
.remove = dev_remove
};
commit ab020cb5f396f54691352edb323cf159894144a0
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Wed Nov 19 20:10:40 2008 +0100
add a new singleton addon for the rfkill subsystem
Added a new singleton addon for the rfkill subsystem to HAL. This
addon (hald-addon-rfkill-killswitch) handles all killswitches
provided by the rfkill linux kernel subsystem.
Note: If your system provides a rfkill device for the Intel
WLAN device(s), you may should build hal-info with
--disable-killswitch-ipw-wlan to prevent trouble.
TODO: Find a way in the fdi-files to prevent trouble with the
ipw killswitch device spawned by via the fdi-files.
diff --git a/fdi/policy/10osvendor/10-rfkill-switch.fdi b/fdi/policy/10osvendor/10-rfkill-switch.fdi
index b98fd54..9143cb1 100644
--- a/fdi/policy/10osvendor/10-rfkill-switch.fdi
+++ b/fdi/policy/10osvendor/10-rfkill-switch.fdi
@@ -9,6 +9,10 @@
<append key="info.addons" type="strlist">hald-addon-ipw-killswitch</append>
</match>
+ <match key="killswitch.access_method" string="rfkill">
+ <append key="info.addons.singleton" type="strlist">hald-addon-rfkill-killswitch</append>
+ </match>
+
<!-- For all other KillSwitch devices -->
<match key="killswitch.access_method" contains_not="ipw">
<match key="info.subsystem" contains_not="rfkill">
diff --git a/hald/linux/addons/.gitignore b/hald/linux/addons/.gitignore
index cf4441d..a075638 100644
--- a/hald/linux/addons/.gitignore
+++ b/hald/linux/addons/.gitignore
@@ -18,5 +18,6 @@ hald-addon-macbookpro-backlight
hald-addon-cpufreq
hald-addon-dell-backlight
hald-addon-imac-backlight
+hald-addon-rfkill-killswitch
*.o
*~
diff --git a/hald/linux/addons/Makefile.am b/hald/linux/addons/Makefile.am
index 46b41cf..ccfb6e6 100644
--- a/hald/linux/addons/Makefile.am
+++ b/hald/linux/addons/Makefile.am
@@ -14,6 +14,7 @@ libexec_PROGRAMS = \
hald-addon-hid-ups \
hald-addon-input \
hald-addon-ipw-killswitch \
+ hald-addon-rfkill-killswitch \
hald-addon-storage
if HAVE_PMU
@@ -101,3 +102,6 @@ hald_addon_generic_backlight_LDADD = $(top_builddir)/libhal/libhal.la @GLIB_LIBS
hald_addon_ipw_killswitch_SOURCES = addon-ipw-killswitch.c ../../logger.c ../../util_helper.c ../../util_helper_priv.c
hald_addon_ipw_killswitch_LDADD = $(top_builddir)/libhal/libhal.la @GLIB_LIBS@
+hald_addon_rfkill_killswitch_SOURCES = addon-rfkill-killswitch.c ../../logger.c ../../util_helper.c ../../util_helper_priv.c
+hald_addon_rfkill_killswitch_LDADD = $(top_builddir)/libhal/libhal.la @GLIB_LIBS@
+
diff --git a/hald/linux/addons/addon-rfkill-killswitch.c b/hald/linux/addons/addon-rfkill-killswitch.c
new file mode 100644
index 0000000..553ab89
--- /dev/null
+++ b/hald/linux/addons/addon-rfkill-killswitch.c
@@ -0,0 +1,373 @@
+/***************************************************************************
+ * CVSID: $Id$
+ *
+ * addon-rfkill-killswitch.c:
+ * Copyright (C) 2008 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 <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include <glib.h>
+#include <glib/gmain.h>
+#include <glib/gstdio.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+#include "libhal/libhal.h"
+#include "../../logger.h"
+#include "../../util_helper.h"
+#include "../../util_helper_priv.h"
+
+static GMainLoop *gmain = NULL;
+static LibHalContext *ctx = NULL;
+static GHashTable *rfkills = NULL;
+
+/* Getting status of the killswitch */
+static int
+get_killswitch (const char *udi)
+{
+ FILE *f;
+ char buf[64];
+ char path[256];
+ char *sysfs_path;
+ int kill_status;
+ int ret = -1;
+
+ f = NULL;
+
+ if (!g_hash_table_lookup_extended (rfkills, udi, NULL, (gpointer) &sysfs_path)) {
+ return -1;
+ }
+
+ snprintf (path, sizeof (path), "%s/state", sysfs_path);
+
+ if ((f = fopen (path, "r")) == NULL) {
+ HAL_WARNING(("Could not read killswitch status from '%s' for device '%s'", path, udi));
+ return -1;
+ }
+
+ if (fgets (buf, sizeof (buf), f) == NULL) {
+ HAL_ERROR (("Cannot read from '%s' for device '%s'", path, udi));
+ goto out;
+ }
+
+ errno = 0;
+ kill_status = strtol (buf, NULL, 10);
+ if (errno == 0) {
+ HAL_DEBUG (("Got '%d' from sysfs interface for device '%s'.", kill_status, udi));
+
+ switch(kill_status) {
+ case 1: /* RFKILL_STATE_UNBLOCKED (deprecated: RFKILL_STATE_ON): Radio output allowed */
+ ret = 1;
+ break;
+ case 0: /* RFKILL_STATE_SOFT_BLOCKED (deprecated: RFKILL_STATE_OFF): Radio output blocked */
+ case 2: /* RFKILL_STATE_HARD_BLOCKED: Output blocked, non-overrideable via sysfs */
+ ret = 0;
+ break;
+ default:
+ break;
+ }
+ }
+
+out:
+ if (f != NULL)
+ fclose (f);
+
+ return ret;
+}
+
+/* Setting status of the killswitch */
+static int
+set_killswitch (const char *udi, gboolean status)
+{
+ FILE *f;
+ int ret;
+ char path[256];
+ char *sysfs_path;
+
+ if (!g_hash_table_lookup_extended (rfkills, udi, NULL, (gpointer) &sysfs_path)) {
+ return -1;
+ }
+
+ snprintf (path, sizeof (path), "%s/state", sysfs_path);
+
+ if ((f = fopen (path, "w")) == NULL) {
+ HAL_WARNING(("Could not open '%s' for device '%s'", path, udi));
+ return -1;
+ }
+
+ if (status) {
+ ret = fputs ("1", f);
+ } else {
+ ret = fputs ("0", f);
+ }
+
+ if (f != NULL)
+ fclose (f);
+
+ if (ret == EOF) {
+ HAL_WARNING(("Couldn't write status to '%s' for device '%s'", path, udi));
+ ret = -1;
+ } else {
+ int current_state = get_killswitch(udi);
+ if ((status && current_state) || (!status && !current_state)) {
+ ret = 0;
+ } else {
+ HAL_DEBUG (("Could not set the state (%d) to sysfs for device '%s', current state is %d.", status, udi, current_state));
+ ret = -1;
+ }
+ }
+
+ return ret;
+}
+
+/* DBus filter function */
+static DBusHandlerResult
+filter_function (DBusConnection *connection, DBusMessage *message, void *userdata)
+{
+ DBusError err;
+ DBusMessage *reply;
+ const char *_udi;
+ char *type;
+ char *action;
+ char *sysfs_path;
+
+ if ((_udi = dbus_message_get_path (message)) == NULL) {
+ HAL_DEBUG (("Couldn't get the udi for this call, ignore it."));
+ return DBUS_HANDLER_RESULT_HANDLED;
+ } else {
+ if(!g_hash_table_lookup_extended (rfkills, _udi, NULL, (gpointer *) &sysfs_path)) {
+ HAL_DEBUG (("This device (%s) isn't yet handled by the addon.", _udi));
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+ }
+
+ dbus_error_init (&err);
+
+ if ((type = libhal_device_get_property_string (ctx, _udi, "killswitch.type", &err)) == NULL) {
+ HAL_DEBUG (("Couldn't get the type of the killswitch device (%s). Ignore call.", _udi));
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ action = g_strdup_printf ("org.freedesktop.hal.killswitch.%s", type);
+
+ if (!check_priv (ctx, connection, message, dbus_message_get_path (message), action)) {
+ HAL_DEBUG(("User don't have the permissions to call the interface"));
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ reply = NULL;
+
+ if (dbus_message_is_method_call (message,
+ "org.freedesktop.Hal.Device.KillSwitch",
+ "SetPower")) {
+ gboolean status;
+
+ dbus_error_init (&err);
+ if (dbus_message_get_args (message,
+ &err,
+ DBUS_TYPE_BOOLEAN, &status,
+ DBUS_TYPE_INVALID)) {
+ int return_code = 0;
+ int set;
+
+ set = set_killswitch (_udi, status);
+
+ reply = dbus_message_new_method_return (message);
+ if (reply == NULL)
+ goto error;
+
+ if (set != 0)
+ return_code = 1;
+
+ dbus_message_append_args (reply,
+ DBUS_TYPE_INT32, &return_code,
+ DBUS_TYPE_INVALID);
+
+ dbus_connection_send (connection, reply, NULL);
+ }
+ } else if (dbus_message_is_method_call (message,
+ "org.freedesktop.Hal.Device.KillSwitch",
+ "GetPower")) {
+ int status;
+
+ dbus_error_init (&err);
+ if (dbus_message_get_args (message,
+ &err,
+ DBUS_TYPE_INVALID)) {
+ status = get_killswitch(_udi);
+
+ reply = dbus_message_new_method_return (message);
+ if (reply == NULL)
+ goto error;
+
+ dbus_message_append_args (reply,
+ DBUS_TYPE_INT32, &status,
+ DBUS_TYPE_INVALID);
+ dbus_connection_send (connection, reply, NULL);
+ }
+ }
+
+error:
+ if (reply != NULL)
+ dbus_message_unref (reply);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+}
+
+static void
+add_device (LibHalContext *ctx,
+ const char *udi,
+ const LibHalPropertySet *properties)
+{
+ DBusError err;
+ DBusConnection *dbus_connection;
+ const char* sysfs_path;
+ static gboolean initialized = FALSE;
+
+ if ((sysfs_path = libhal_ps_get_string (properties, "linux.sysfs_path")) == NULL) {
+ HAL_ERROR(("%s has no property linux.sysfs_path", udi));
+ return;
+ }
+
+ /* claim the interface */
+
+ if ((dbus_connection = libhal_ctx_get_dbus_connection(ctx)) == NULL) {
+ HAL_WARNING (("Cannot get DBus connection"));
+ return;
+ }
+
+ if (!initialized) {
+ dbus_connection_add_filter (dbus_connection, filter_function, NULL, NULL);
+ initialized = TRUE;
+ }
+
+ dbus_error_init (&err);
+
+ if (!libhal_device_claim_interface (ctx,
+ udi,
+ "org.freedesktop.Hal.Device.KillSwitch",
+ " <method name=\"SetPower\">\n"
+ " <arg name=\"value\" direction=\"in\" type=\"b\"/>\n"
+ " <arg name=\"return_code\" direction=\"out\" type=\"i\"/>\n"
+ " </method>\n"
+ " <method name=\"GetPower\">\n"
+ " <arg name=\"value\" direction=\"out\" type=\"i\"/>\n"
+ " </method>\n",
+ &err)) {
+ HAL_ERROR (("Cannot claim interface 'org.freedesktop.Hal.Device.KillSwitch'"));
+ return;
+ }
+
+ g_hash_table_insert (rfkills, g_strdup(udi), g_strdup(sysfs_path));
+}
+
+static void
+remove_device (LibHalContext *ctx,
+ const char *udi,
+ const LibHalPropertySet *properties)
+{
+ gpointer sysfs_path;
+ gboolean handling_udi;
+
+ HAL_DEBUG (("Removing channel for '%s'", udi));
+
+ handling_udi = g_hash_table_lookup_extended (rfkills, udi, NULL, &sysfs_path);
+
+ if (!handling_udi) {
+ HAL_ERROR(("DeviceRemove called for unknown device: '%s'.", udi));
+ return;
+ }
+
+ g_hash_table_remove (rfkills, udi);
+
+ if (g_hash_table_size (rfkills) == 0) {
+ HAL_INFO(("no more devices, exiting"));
+ g_main_loop_quit (gmain);
+ }
+}
+
+int
+main (int argc, char *argv[])
+{
+ DBusConnection *dbus_connection;
+ DBusError error;
+ const char *commandline;
+
+ hal_set_proc_title_init (argc, argv);
+
+ setup_logger ();
+
+ dbus_error_init (&error);
+ if ((ctx = libhal_ctx_init_direct (&error)) == NULL) {
+ HAL_WARNING (("Unable to init libhal context"));
+ goto out;
+ }
+
+ if ((dbus_connection = libhal_ctx_get_dbus_connection(ctx)) == NULL) {
+ HAL_WARNING (("Cannot get DBus connection"));
+ goto out;
+ }
+
+ if ((commandline = getenv ("SINGLETON_COMMAND_LINE")) == NULL) {
+ HAL_WARNING (("SINGLETON_COMMAND_LINE not set"));
+ goto out;
+ }
+
+ libhal_ctx_set_singleton_device_added (ctx, add_device);
+ libhal_ctx_set_singleton_device_removed (ctx, remove_device);
+
+ dbus_connection_setup_with_g_main (dbus_connection, NULL);
+ dbus_connection_set_exit_on_disconnect (dbus_connection, 0);
+
+ dbus_error_init (&error);
+
+ if (!libhal_device_singleton_addon_is_ready (ctx, commandline, &error)) {
+ goto out;
+ }
+
+ rfkills = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+ gmain = g_main_loop_new (NULL, FALSE);
+ g_main_loop_run (gmain);
+
+ return 0;
+
+out:
+ HAL_DEBUG (("An error occured, exiting cleanly"));
+ if (ctx != NULL) {
+ dbus_error_init (&error);
+ libhal_ctx_shutdown (ctx, &error);
+ libhal_ctx_free (ctx);
+ }
+
+ return 0;
+}
diff --git a/hald/linux/device.c b/hald/linux/device.c
index e86650d..6e87dfb 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -2652,6 +2652,8 @@ rfkill_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent
hal_device_property_set_string (d, "killswitch.type", type);
}
+ hal_device_property_set_string (d, "killswitch.access_method", "rfkill");
+
hal_util_set_string_from_file (d, "killswitch.name", sysfs_path, "name");
g_snprintf(buf, sizeof(buf), "%s %s Killswitch", hal_device_property_get_string (d, "killswitch.name"),
commit 79b92dbdf65b8c978d5a8f6fb2b421aac83c3de3
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Sat Nov 15 14:18:17 2008 +0100
improve HAL performance for filesystem detection
Improved HAL performance for filesystem detection. Call libvolume_id
functions in the volume prober to get the following information only
if we have no udev information about the filesystem:
- volume.fsusage
- volume.fstype
- volume.fsversion
- volume.uuid
- volume.label
HAL now simply use the already in the HotplugEvent stored information
from udev if available, since udev already called libvolume_id to get
these info. With this change HAL needs to probe only CD/DVD media and
maybe fakevolume related volumes.
diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index c46d4fb..ec4e405 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -57,6 +57,34 @@
#include "blockdev.h"
+static gchar *
+strdup_valid_utf8 (const char *str)
+{
+ char *endchar;
+ char *newstr;
+ unsigned int fixes;
+
+ if (str == NULL)
+ return NULL;
+
+ newstr = g_strdup (str);
+
+ fixes = 0;
+ while (!g_utf8_validate (newstr, -1, (const char **) &endchar)) {
+ *endchar = '_';
+ ++fixes;
+ }
+
+ /* If we had to fix more than 20% of the characters, give up */
+ if (fixes > 0 && g_utf8_strlen (newstr, -1) / fixes < 5) {
+ g_free (newstr);
+ newstr = g_strdup("");
+ }
+
+ return newstr;
+}
+
+
/*--------------------------------------------------------------------------------------------------------------*/
static gboolean
@@ -1428,6 +1456,8 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
} else {
guint sysfs_path_len;
gboolean is_physical_partition;
+ char *volume_label;
+ char buf[64];
/*************************
*
@@ -1443,12 +1473,32 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
hal_device_property_set_string (d, "volume.uuid", "");
hal_device_property_set_string (d, "volume.label", "");
hal_device_property_set_string (d, "volume.mount_point", "");
+
+ /* persistent properties from udev (may be empty) */
+ hal_device_property_set_string (d, "volume.fsusage", hotplug_event->sysfs.fsusage);
+ hal_device_property_set_string (d, "volume.fsversion", hotplug_event->sysfs.fsversion);
+ hal_device_property_set_string (d, "volume.uuid", hotplug_event->sysfs.fsuuid);
+ hal_device_property_set_string (d, "volume.fstype", hotplug_event->sysfs.fstype);
+ if (hotplug_event->sysfs.fstype[0] != '\0') {
+ snprintf (buf, sizeof (buf), "Volume (%s)", hotplug_event->sysfs.fstype);
+ } else {
+ snprintf (buf, sizeof (buf), "Volume");
+ }
+ hal_device_property_set_string (d, "info.product", buf);
+
+ volume_label = strdup_valid_utf8 (hotplug_event->sysfs.fslabel);
+ if (volume_label) {
+ hal_device_property_set_string (d, "volume.label", volume_label);
+ if (volume_label[0] != '\0') {
+ hal_device_property_set_string (d, "info.product", volume_label);
+ }
+ g_free(volume_label);
+ }
+
hal_device_property_set_bool (d, "volume.is_mounted", FALSE);
hal_device_property_set_bool (d, "volume.is_mounted_read_only", FALSE);
hal_device_property_set_bool (d, "volume.linux.is_device_mapper", is_device_mapper);
- hal_device_property_set_bool (
- d, "volume.is_disc",
- strcmp (hal_device_property_get_string (parent, "storage.drive_type"), "cdrom") == 0);
+ hal_device_property_set_bool (d, "volume.is_disc", strcmp (hal_device_property_get_string (parent, "storage.drive_type"), "cdrom") == 0);
is_physical_partition = TRUE;
diff --git a/hald/linux/probing/probe-volume.c b/hald/linux/probing/probe-volume.c
index d9ea48d..d298db2 100644
--- a/hald/linux/probing/probe-volume.c
+++ b/hald/linux/probing/probe-volume.c
@@ -316,6 +316,7 @@ main (int argc, char *argv[])
char *partition_number_str;
char *partition_start_str;
char *is_disc_str;
+ char *fsusage;
dbus_bool_t is_disc;
unsigned int partition_number;
guint64 partition_start;
@@ -364,6 +365,8 @@ main (int argc, char *argv[])
else
is_disc = FALSE;
+ fsusage = getenv ("HAL_PROP_VOLUME_FSUSAGE");
+
dbus_error_init (&error);
if ((ctx = libhal_ctx_init_direct (&error)) == NULL)
goto out;
@@ -603,8 +606,15 @@ main (int argc, char *argv[])
}
}
+ if (fsusage != NULL && strlen(fsusage) > 0) {
+ HAL_DEBUG(("have already information about fsusage from udev, no need to probe for filesystem"));
+ should_probe_for_fs = FALSE;
+ }
+
if (should_probe_for_fs) {
+ HAL_DEBUG(("start probing for filesystem ..."));
+
if ((stordev_dev_file = libhal_device_get_property_string (
ctx, parent_udi, "block.device", &error)) == NULL) {
goto out;
commit 35c4e22c066151a3099da748209ca5152ccf9b51
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Sat Nov 15 12:57:38 2008 +0100
Revert "cleanup handling volume filesystem information"
This reverts commit 7aca1f3fefefd3c760636aabcff1e25946ab6391.
Reverted the change to prevent trouble with CD/DVD media (because
they are fakevolumes and udev tell us no information about the
filesystem on insert the media).
diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index ec4e405..c46d4fb 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -57,34 +57,6 @@
#include "blockdev.h"
-static gchar *
-strdup_valid_utf8 (const char *str)
-{
- char *endchar;
- char *newstr;
- unsigned int fixes;
-
- if (str == NULL)
- return NULL;
-
- newstr = g_strdup (str);
-
- fixes = 0;
- while (!g_utf8_validate (newstr, -1, (const char **) &endchar)) {
- *endchar = '_';
- ++fixes;
- }
-
- /* If we had to fix more than 20% of the characters, give up */
- if (fixes > 0 && g_utf8_strlen (newstr, -1) / fixes < 5) {
- g_free (newstr);
- newstr = g_strdup("");
- }
-
- return newstr;
-}
-
-
/*--------------------------------------------------------------------------------------------------------------*/
static gboolean
@@ -1456,8 +1428,6 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
} else {
guint sysfs_path_len;
gboolean is_physical_partition;
- char *volume_label;
- char buf[64];
/*************************
*
@@ -1473,32 +1443,12 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
hal_device_property_set_string (d, "volume.uuid", "");
hal_device_property_set_string (d, "volume.label", "");
hal_device_property_set_string (d, "volume.mount_point", "");
-
- /* persistent properties from udev (may be empty) */
- hal_device_property_set_string (d, "volume.fsusage", hotplug_event->sysfs.fsusage);
- hal_device_property_set_string (d, "volume.fsversion", hotplug_event->sysfs.fsversion);
- hal_device_property_set_string (d, "volume.uuid", hotplug_event->sysfs.fsuuid);
- hal_device_property_set_string (d, "volume.fstype", hotplug_event->sysfs.fstype);
- if (hotplug_event->sysfs.fstype[0] != '\0') {
- snprintf (buf, sizeof (buf), "Volume (%s)", hotplug_event->sysfs.fstype);
- } else {
- snprintf (buf, sizeof (buf), "Volume");
- }
- hal_device_property_set_string (d, "info.product", buf);
-
- volume_label = strdup_valid_utf8 (hotplug_event->sysfs.fslabel);
- if (volume_label) {
- hal_device_property_set_string (d, "volume.label", volume_label);
- if (volume_label[0] != '\0') {
- hal_device_property_set_string (d, "info.product", volume_label);
- }
- g_free(volume_label);
- }
-
hal_device_property_set_bool (d, "volume.is_mounted", FALSE);
hal_device_property_set_bool (d, "volume.is_mounted_read_only", FALSE);
hal_device_property_set_bool (d, "volume.linux.is_device_mapper", is_device_mapper);
- hal_device_property_set_bool (d, "volume.is_disc", strcmp (hal_device_property_get_string (parent, "storage.drive_type"), "cdrom") == 0);
+ hal_device_property_set_bool (
+ d, "volume.is_disc",
+ strcmp (hal_device_property_get_string (parent, "storage.drive_type"), "cdrom") == 0);
is_physical_partition = TRUE;
diff --git a/hald/linux/probing/Makefile.am b/hald/linux/probing/Makefile.am
index d32a9a4..10bba43 100644
--- a/hald/linux/probing/Makefile.am
+++ b/hald/linux/probing/Makefile.am
@@ -45,7 +45,7 @@ hald_probe_storage_LDADD = @GLIB_LIBS@ @VOLUME_ID_LIBS@ $(top_builddir)/libhal/l
hald_probe_pc_floppy_SOURCES = probe-pc-floppy.c ../../logger.c
hald_probe_volume_SOURCES = probe-volume.c linux_dvd_rw_utils.c ../../logger.c
-hald_probe_volume_LDADD = $(top_builddir)/libhal/libhal.la $(top_builddir)/partutil/libpartutil.la @GLIB_LIBS@
+hald_probe_volume_LDADD = $(top_builddir)/libhal/libhal.la $(top_builddir)/partutil/libpartutil.la @GLIB_LIBS@ @VOLUME_ID_LIBS@
hald_probe_ieee1394_unit_SOURCES = probe-ieee1394-unit.c ../../logger.c
hald_probe_ieee1394_unit_LDADD = $(top_builddir)/libhal/libhal.la
diff --git a/hald/linux/probing/probe-volume.c b/hald/linux/probing/probe-volume.c
index a7c9951..d9ea48d 100644
--- a/hald/linux/probing/probe-volume.c
+++ b/hald/linux/probing/probe-volume.c
@@ -42,12 +42,116 @@
#include <signal.h>
#include <glib.h>
+#include <libvolume_id.h>
#include "libhal/libhal.h"
#include "partutil/partutil.h"
#include "linux_dvd_rw_utils.h"
#include "../../logger.h"
+static void vid_log(int priority, const char *file, int line, const char *format, ...)
+{
+ char log_str[1024];
+ va_list args;
+
+ va_start(args, format);
+ vsnprintf(log_str, sizeof(log_str), format, args);
+ logger_forward_debug("%s:%i %s\n", file, line, log_str);
+ va_end(args);
+}
+
+static gchar *
+strdup_valid_utf8 (const char *str)
+{
+ char *endchar;
+ char *newstr;
+ unsigned int fixes;
+
+ if (str == NULL)
+ return NULL;
+
+ newstr = g_strdup (str);
+
+ fixes = 0;
+ while (!g_utf8_validate (newstr, -1, (const char **) &endchar)) {
+ *endchar = '_';
+ ++fixes;
+ }
+
+ /* If we had to fix more than 20% of the characters, give up */
+ if (fixes > 0 && g_utf8_strlen (newstr, -1) / fixes < 5) {
+ g_free (newstr);
+ newstr = g_strdup("");
+ }
+
+ return newstr;
+}
+
+
+static void
+set_volume_id_values (LibHalChangeSet *cs, struct volume_id *vid)
+{
+ char buf[256];
+ const char *usage;
+ const char *type;
+ const char *type_version;
+ const char *label;
+ const char *uuid;
+ DBusError error;
+
+ dbus_error_init (&error);
+
+ if (!volume_id_get_usage(vid, &usage))
+ usage = "";
+ libhal_changeset_set_property_string (cs, "volume.fsusage", usage);
+ HAL_DEBUG (("volume.fsusage = '%s'", usage));
+
+ if (!volume_id_get_type(vid, &type))
+ type = "";
+ if (!libhal_changeset_set_property_string (cs, "volume.fstype", type))
+ libhal_changeset_set_property_string (cs, "volume.fstype", "");
+ HAL_DEBUG(("volume.fstype = '%s'", type));
+
+ if (!volume_id_get_type_version(vid, &type_version))
+ type_version = "";
+ libhal_changeset_set_property_string (cs, "volume.fsversion", type_version);
+ HAL_DEBUG(("volume.fsversion = '%s'", type_version));
+
+ if (!volume_id_get_uuid(vid, &uuid))
+ uuid = "";
+ libhal_changeset_set_property_string (cs, "volume.uuid", uuid);
+ HAL_DEBUG(("volume.uuid = '%s'", uuid));
+
+ if (!volume_id_get_label(vid, &label))
+ label = "";
+
+ if (label[0] != '\0') {
+ char *volume_label;
+
+ /* we need to be sure for a utf8 valid label, because dbus accept only utf8 valid strings */
+ volume_label = strdup_valid_utf8 (label);
+ if( volume_label != NULL ) {
+ libhal_changeset_set_property_string (cs, "volume.label", volume_label);
+ HAL_DEBUG(("volume.label = '%s'", volume_label));
+
+ if (volume_label[0] != '\0') {
+ libhal_changeset_set_property_string (cs, "info.product", volume_label);
+ g_free(volume_label);
+ return;
+ }
+
+ g_free(volume_label);
+ }
+ }
+
+ if (type[0] != '\0') {
+ snprintf (buf, sizeof (buf), "Volume (%s)", type);
+ } else {
+ snprintf (buf, sizeof (buf), "Volume (unknown)");
+ }
+ libhal_changeset_set_property_string (cs, "info.product", buf);
+}
+
static void
advanced_disc_detect (LibHalChangeSet *cs, int fd, const char *device_file)
{
@@ -207,6 +311,7 @@ main (int argc, char *argv[])
LibHalContext *ctx = NULL;
DBusError error;
char *parent_udi;
+ struct volume_id *vid;
char *stordev_dev_file;
char *partition_number_str;
char *partition_start_str;
@@ -225,6 +330,9 @@ main (int argc, char *argv[])
cs = NULL;
disc_may_have_data = FALSE;
+ /* hook in our debug into libvolume_id */
+ volume_id_log_fn = vid_log;
+
setup_logger ();
/* assume failure */
@@ -510,9 +618,76 @@ main (int argc, char *argv[])
vol_size = 0;
}
- if (disc_may_have_data) {
- libhal_changeset_set_property_bool (cs, "volume.disc.is_blank", FALSE);
- libhal_changeset_set_property_bool (cs, "volume.disc.has_data", TRUE);
+ /* probe for file system */
+ vid = volume_id_open_fd (fd);
+ if (vid != NULL) {
+ int vid_ret;
+ HAL_INFO (("invoking volume_id_probe_all, offset=%d, size=%d", vol_probe_offset, vol_size));
+ vid_ret = volume_id_probe_all (vid, vol_probe_offset, vol_size);
+ HAL_INFO (("volume_id_probe_all returned %d", vid_ret));
+
+ if (vid_ret != 0 && is_disc && vol_probe_offset != 0) {
+ /* Some cd-rom drives report the offset of the session in the cd's TOC
+ * wrong. Fallback to probing at offset 0, just to be sure */
+ HAL_INFO (("invoking volume_id_probe_all, offset=0, size=%d", vol_size));
+ vid_ret = volume_id_probe_all (vid, 0 , vol_size);
+ HAL_INFO (("volume_id_probe_all returned %d", vid_ret));
+ }
+
+ if (vid_ret == 0) {
+ set_volume_id_values(cs, vid);
+ if (disc_may_have_data) {
+ libhal_changeset_set_property_bool (cs, "volume.disc.is_blank", FALSE);
+ libhal_changeset_set_property_bool (cs, "volume.disc.has_data", TRUE);
+ }
+ } else {
+ libhal_changeset_set_property_string (cs, "info.product", "Volume");
+ }
+
+ /* If we didn't detect anything, look whether it's a partition table (some Apple discs
+ * uses Apple Partition Map) and look at partitions
+ *
+ * (kind of a hack - ugh - we ought to export all these as fakevolumes... but
+ * this is good enough for now... the only discs I know of that does this
+ * is in fact Apple's install disc.)
+ */
+ if (vid_ret != 0 && is_disc) {
+ PartitionTable *p;
+ p = part_table_load_from_disk (stordev_dev_file);
+ if (p != NULL) {
+ int i;
+
+ HAL_INFO (("Partition table with scheme '%s' on optical disc",
+ part_get_scheme_name (part_table_get_scheme (p))));
+
+ for (i = 0; i < part_table_get_num_entries (p); i++) {
+ char *part_type;
+
+ part_type = part_table_entry_get_type (p, i);
+ HAL_INFO ((" partition %d has type '%s'", i, part_type));
+ if (strcmp (part_type, "Apple_HFS") == 0) {
+ guint64 part_offset;
+
+ part_offset = part_table_entry_get_offset (p, i);
+ if (volume_id_probe_all (
+ vid, vol_probe_offset + part_offset, 0) == 0) {
+
+ set_volume_id_values(cs, vid);
+ }
+
+ /* and we're done */
+ break;
+ }
+ g_free (part_type);
+ }
+
+
+ HAL_INFO (("Done looking at part table"));
+ part_table_free (p);
+ }
+ }
+
+ volume_id_close(vid);
}
/* get partition type number, if we find a msdos partition table */
commit 9797bc78bd16640df362709d982446c34653ea09
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Mon Nov 10 12:31:18 2008 +0100
fixed call of hotplug_queue_now_empty() under linux
Fixed call of hotplug_queue_now_empty() under linux. Call the
function first if the hotplug queue is really empty and if there
is no hotplug event in progress. Otherwise you get DeviceAdded
events while HAL is still initialising on startup.
diff --git a/hald/linux/hotplug.c b/hald/linux/hotplug.c
index eb23417..9e80252 100644
--- a/hald/linux/hotplug.c
+++ b/hald/linux/hotplug.c
@@ -454,8 +454,10 @@ hotplug_event_process_queue (void)
processing = FALSE;
- hotplug_queue_now_empty ();
-
+ if (hotplug_event_queue->length == 0 && g_list_length (hotplug_events_in_progress) == 0) {
+ HAL_DEBUG(("Hotplug-queue empty now ... no hotplug events in progress"));
+ hotplug_queue_now_empty ();
+ }
}
gboolean
commit 2f9ad11a8835ae10e235a7d9d0374b40385d3533
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Fri Nov 7 16:31:09 2008 +0100
add memstick to storage.bus in spec
Documented memstick as possible value of storage.bus in the spec.
diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index 229bb14..6d3c09b 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -6239,6 +6239,12 @@ org.freedesktop.Hal.Device.Volume.method_signatures = {'ssas', 'as', 'as'}
</row>
<row>
<entry></entry>
+ <entry>memstick</entry>
+ <entry></entry>
+ <entry>Sony MemoryStick device/interface</entry>
+ </row>
+ <row>
+ <entry></entry>
<entry>mmc</entry>
<entry></entry>
<entry>MultiMediaCard (MMC) interface</entry>
commit a6080ac92f86bed66be3944cc3e8f9075edab785
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Fri Nov 7 16:26:53 2008 +0100
add memstick and memstick_host namespace to spec
Documented memstick and memstick_host namespace in spec.
diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index 0e1fe91..229bb14 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -2070,6 +2070,50 @@ org.freedesktop.Hal.Device.Volume.method_signatures = {'ssas', 'as', 'as'}
</informaltable>
</sect2>
+ <sect2 id="device-properties-memstick">
+ <title>
+ memstick namespace
+ </title>
+ <para>
+ Device objects with the capability <literal>memstick</literal> represent
+ a Sony MemoryStick device. No namespace specific properties.
+ </para>
+ </sect2>
+
+ <sect2 id="device-properties-memstick_host">
+ <title>
+ memstick_host namespace
+ </title>
+ <para>
+ Device objects with <literal>info.subsystem</literal> set to
+ <literal>memstick_host</literal> represent Sony MemoryStick
+ host adaptors. The following properties are available for such
+ device objects.
+ </para>
+ <informaltable>
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>Key (type)</entry>
+ <entry>Values</entry>
+ <entry>Mandatory</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <literal>memstick_host.host</literal> (int)
+ </entry>
+ <entry></entry>
+ <entry>Yes</entry>
+ <entry>A unique number identifying the Sony MemoryStick host adaptor</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </sect2>
+
<sect2 id="device-properties-mmc">
<title>
mmc namespace
commit 07196f11b42c2405d2bfadb66f82f28ee5a5fca5
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Fri Nov 7 14:54:33 2008 +0100
another fix for commit d29ea6b31b67bf540b23dfedfa1b7add4c22bce2
Another fix for commit d29ea6b31b67bf540b23dfedfa1b7add4c22bce2:
- info.bus is deprecated, don't add this key
- info.subsystem should get only set in the subsystem specific
code if it differs from the subsystem or in other rare cases
diff --git a/hald/linux/device.c b/hald/linux/device.c
index e913396..e86650d 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -1275,8 +1275,6 @@ memstick_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);
- hal_device_property_set_string (d, "info.subsystem", "memstick");
- hal_device_property_set_string (d, "info.bus", "memstick");
hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev));
hal_util_set_driver (d, "info.linux.driver", sysfs_path);
commit 01ef81e6e0bb277eec8a2b9fc2930c902b40c7b9
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Fri Nov 7 14:51:49 2008 +0100
fix commit d29ea6b31b67bf540b23dfedfa1b7add4c22bce2
Fixed commit d29ea6b31b67bf540b23dfedfa1b7add4c22bce2: keep
subsystem handler and related code in alphabetical order.
diff --git a/hald/linux/device.c b/hald/linux/device.c
index e43f56c..e913396 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -1263,6 +1263,95 @@ iucv_compute_udi (HalDevice *d)
/*--------------------------------------------------------------------------------------------------------------*/
static HalDevice *
+memstick_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path)
+{
+ HalDevice *d;
+ const gchar *bus_id;
+
+ if (parent_dev == NULL) {
+ d = NULL;
+ goto out;
+ }
+
+ d = hal_device_new ();
+ hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
+ hal_device_property_set_string (d, "info.subsystem", "memstick");
+ hal_device_property_set_string (d, "info.bus", "memstick");
+ hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev));
+
+ hal_util_set_driver (d, "info.linux.driver", sysfs_path);
+
+ bus_id = hal_util_get_last_element (sysfs_path);
+
+ hal_util_set_string_from_file (d, "info.product", sysfs_path, "attr_modelname");
+
+out:
+ return d;
+}
+
+static gboolean
+memstick_compute_udi (HalDevice *d)
+{
+ gchar udi[256];
+
+ hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
+ "%s_memstick_card",
+ hal_device_property_get_string (d, "info.parent"));
+ hal_device_set_udi (d, udi);
+ hal_device_property_set_string (d, "info.udi", udi);
+ return TRUE;
+
+}
+
+/*--------------------------------------------------------------------------------------------------------------*/
+
+static HalDevice *
+memstick_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;
+
+ d = NULL;
+
+ if (parent_dev == NULL || parent_path == NULL) {
+ goto out;
+ }
+
+ d = hal_device_new ();
+ hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
+
+ hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev));
+
+ hal_device_property_set_string (d, "info.category", "memstick_host");
+ hal_device_add_capability (d, "memstick_host");
+
+ 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);
+
+out:
+ return d;
+}
+
+static gboolean
+memstick_host_compute_udi (HalDevice *d)
+{
+ gchar udi[256];
+
+ hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
+ "%s_memstick_host",
+ hal_device_property_get_string (d, "info.parent"));
+ hal_device_set_udi (d, udi);
+ hal_device_property_set_string (d, "info.udi", udi);
+ return TRUE;
+}
+
+/*--------------------------------------------------------------------------------------------------------------*/
+
+static HalDevice *
mmc_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path)
{
HalDevice *d;
@@ -1646,51 +1735,6 @@ of_platform_compute_udi (HalDevice *d)
/*--------------------------------------------------------------------------------------------------------------*/
-
-static HalDevice *
-memstick_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;
-
- d = NULL;
-
- if (parent_dev == NULL || parent_path == NULL) {
- goto out;
- }
-
- d = hal_device_new ();
- hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
-
- hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev));
-
- hal_device_property_set_string (d, "info.category", "memstick_host");
- hal_device_add_capability (d, "memstick_host");
-
- 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);
-
-out:
- return d;
-}
-
-static gboolean
-memstick_host_compute_udi (HalDevice *d)
-{
- gchar udi[256];
-
- hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
- "%s_memstick_host",
- hal_device_property_get_string (d, "info.parent"));
- hal_device_set_udi (d, udi);
- hal_device_property_set_string (d, "info.udi", udi);
- return TRUE;
-}
-
static HalDevice *
pci_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path)
{
@@ -2579,47 +2623,6 @@ pseudo_compute_udi (HalDevice *d)
}
-static HalDevice *
-memstick_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path)
-{
- HalDevice *d;
- const gchar *bus_id;
-
- if (parent_dev == NULL) {
- d = NULL;
- goto out;
- }
-
- d = hal_device_new ();
- hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
- hal_device_property_set_string (d, "info.subsystem", "memstick");
- hal_device_property_set_string (d, "info.bus", "memstick");
- hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev));
-
- hal_util_set_driver (d, "info.linux.driver", sysfs_path);
-
- bus_id = hal_util_get_last_element (sysfs_path);
-
- hal_util_set_string_from_file (d, "info.product", sysfs_path, "attr_modelname");
-
-out:
- return d;
-}
-
-static gboolean
-memstick_compute_udi (HalDevice *d)
-{
- gchar udi[256];
-
- hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
- "%s_memstick_card",
- hal_device_property_get_string (d, "info.parent"));
- hal_device_set_udi (d, udi);
- hal_device_property_set_string (d, "info.udi", udi);
- return TRUE;
-
-}
-
/*--------------------------------------------------------------------------------------------------------------*/
static HalDevice *
@@ -4196,13 +4199,6 @@ static DevHandler dev_handler_ide = {
.remove = dev_remove
};
-static DevHandler dev_handler_memstick = {
- .subsystem = "memstick",
- .add = memstick_add,
- .compute_udi = memstick_compute_udi,
- .remove = dev_remove
-};
-
static DevHandler dev_handler_ieee1394 = {
.subsystem = "ieee1394",
.add = ieee1394_add,
@@ -4227,6 +4223,23 @@ static DevHandler dev_handler_iucv = {
.remove = dev_remove
};
+static DevHandler dev_handler_memstick = {
+ .subsystem = "memstick",
+ .add = memstick_add,
+ .compute_udi = memstick_compute_udi,
+ .remove = dev_remove
+};
+
+static DevHandler dev_handler_memstick_host =
+{
+ .subsystem = "memstick_host",
+ .add = memstick_host_add,
+ .get_prober = NULL,
+ .post_probing = NULL,
+ .compute_udi = memstick_host_compute_udi,
+ .remove = dev_remove
+};
+
static DevHandler dev_handler_mmc = {
.subsystem = "mmc",
.add = mmc_add,
@@ -4263,16 +4276,6 @@ static DevHandler dev_handler_of_platform =
.remove = dev_remove
};
-static DevHandler dev_handler_memstick_host =
-{
- .subsystem = "memstick_host",
- .add = memstick_host_add,
- .get_prober = NULL,
- .post_probing = NULL,
- .compute_udi = memstick_host_compute_udi,
- .remove = dev_remove
-};
-
static DevHandler dev_handler_pci = {
.subsystem = "pci",
.add = pci_add,
commit d29ea6b31b67bf540b23dfedfa1b7add4c22bce2
Author: Matthew Garrett <mjg59 at srcf.ucam.org>
Date: Fri Nov 7 14:42:25 2008 +0100
add memstick/memstick_host support
This adds basic memory stick support to hal. It's enough to get
automounting up, but it doesn't expose any of the memory stick specific
attributes yet since I'm not sure which of them are especially useful.
diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index 573613d..ec4e405 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -1230,6 +1230,12 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
is_hotpluggable = TRUE;
hal_device_property_set_string (d, "storage.bus", "mmc");
break;
+ } else if (strcmp (bus, "memstick") == 0) {
+ physdev = d_it;
+ physdev_udi = udi_it;
+ is_hotpluggable = TRUE;
+ hal_device_property_set_string (d, "storage.bus", "memstick");
+ break;
} else if (strcmp (bus, "ccw") == 0) {
physdev = d_it;
physdev_udi = udi_it;
@@ -1377,6 +1383,8 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
} else if (strcmp (parent_bus, "mmc") == 0) {
hal_device_property_set_string (d, "storage.drive_type", "sd_mmc");
+ } else if (strcmp (parent_bus, "memstick") == 0) {
+ hal_device_property_set_string (d, "storage.drive_type", "memstick");
} else if (strcmp (parent_bus, "vio") == 0) {
char buf[256];
const gchar *prop;
diff --git a/hald/linux/device.c b/hald/linux/device.c
index c3744e0..e43f56c 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -1646,6 +1646,51 @@ of_platform_compute_udi (HalDevice *d)
/*--------------------------------------------------------------------------------------------------------------*/
+
+static HalDevice *
+memstick_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;
+
+ d = NULL;
+
+ if (parent_dev == NULL || parent_path == NULL) {
+ goto out;
+ }
+
+ d = hal_device_new ();
+ hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
+
+ hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev));
+
+ hal_device_property_set_string (d, "info.category", "memstick_host");
+ hal_device_add_capability (d, "memstick_host");
+
+ 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);
+
+out:
+ return d;
+}
+
+static gboolean
+memstick_host_compute_udi (HalDevice *d)
+{
+ gchar udi[256];
+
+ hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
+ "%s_memstick_host",
+ hal_device_property_get_string (d, "info.parent"));
+ hal_device_set_udi (d, udi);
+ hal_device_property_set_string (d, "info.udi", udi);
+ return TRUE;
+}
+
static HalDevice *
pci_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path)
{
@@ -2534,6 +2579,47 @@ pseudo_compute_udi (HalDevice *d)
}
+static HalDevice *
+memstick_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *parent_dev, const gchar *parent_path)
+{
+ HalDevice *d;
+ const gchar *bus_id;
+
+ if (parent_dev == NULL) {
+ d = NULL;
+ goto out;
+ }
+
+ d = hal_device_new ();
+ hal_device_property_set_string (d, "linux.sysfs_path", sysfs_path);
+ hal_device_property_set_string (d, "info.subsystem", "memstick");
+ hal_device_property_set_string (d, "info.bus", "memstick");
+ hal_device_property_set_string (d, "info.parent", hal_device_get_udi (parent_dev));
+
+ hal_util_set_driver (d, "info.linux.driver", sysfs_path);
+
+ bus_id = hal_util_get_last_element (sysfs_path);
+
+ hal_util_set_string_from_file (d, "info.product", sysfs_path, "attr_modelname");
+
+out:
+ return d;
+}
+
+static gboolean
+memstick_compute_udi (HalDevice *d)
+{
+ gchar udi[256];
+
+ hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
+ "%s_memstick_card",
+ hal_device_property_get_string (d, "info.parent"));
+ hal_device_set_udi (d, udi);
+ hal_device_property_set_string (d, "info.udi", udi);
+ return TRUE;
+
+}
+
/*--------------------------------------------------------------------------------------------------------------*/
static HalDevice *
@@ -4110,6 +4196,13 @@ static DevHandler dev_handler_ide = {
.remove = dev_remove
};
+static DevHandler dev_handler_memstick = {
+ .subsystem = "memstick",
+ .add = memstick_add,
+ .compute_udi = memstick_compute_udi,
+ .remove = dev_remove
+};
+
static DevHandler dev_handler_ieee1394 = {
.subsystem = "ieee1394",
.add = ieee1394_add,
@@ -4170,6 +4263,16 @@ static DevHandler dev_handler_of_platform =
.remove = dev_remove
};
+static DevHandler dev_handler_memstick_host =
+{
+ .subsystem = "memstick_host",
+ .add = memstick_host_add,
+ .get_prober = NULL,
+ .post_probing = NULL,
+ .compute_udi = memstick_host_compute_udi,
+ .remove = dev_remove
+};
+
static DevHandler dev_handler_pci = {
.subsystem = "pci",
.add = pci_add,
@@ -4405,6 +4508,8 @@ static DevHandler *dev_handlers[] = {
&dev_handler_input,
&dev_handler_iucv,
&dev_handler_mmc,
+ &dev_handler_memstick,
+ &dev_handler_memstick_host,
&dev_handler_mmc_host,
&dev_handler_net,
&dev_handler_of_platform,
commit 7aca1f3fefefd3c760636aabcff1e25946ab6391
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Wed Nov 5 14:31:02 2008 +0100
cleanup handling volume filesystem information
Cleaned up handling of volume filesystem information. Don't call
libvolume_id functions in the volume prober to get the following
information:
- volume.fsusage
- volume.fstype
- volume.fsversion
- volume.uuid
- volume.label
HAL now simply use the already in the HotplugEvent stored information
from udev, since udev already called libvolume_id to get these info.
diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index 6432d31..573613d 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -57,6 +57,34 @@
#include "blockdev.h"
+static gchar *
+strdup_valid_utf8 (const char *str)
+{
+ char *endchar;
+ char *newstr;
+ unsigned int fixes;
+
+ if (str == NULL)
+ return NULL;
+
+ newstr = g_strdup (str);
+
+ fixes = 0;
+ while (!g_utf8_validate (newstr, -1, (const char **) &endchar)) {
+ *endchar = '_';
+ ++fixes;
+ }
+
+ /* If we had to fix more than 20% of the characters, give up */
+ if (fixes > 0 && g_utf8_strlen (newstr, -1) / fixes < 5) {
+ g_free (newstr);
+ newstr = g_strdup("");
+ }
+
+ return newstr;
+}
+
+
/*--------------------------------------------------------------------------------------------------------------*/
static gboolean
@@ -1420,6 +1448,8 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
} else {
guint sysfs_path_len;
gboolean is_physical_partition;
+ char *volume_label;
+ char buf[64];
/*************************
*
@@ -1435,12 +1465,32 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
hal_device_property_set_string (d, "volume.uuid", "");
hal_device_property_set_string (d, "volume.label", "");
hal_device_property_set_string (d, "volume.mount_point", "");
+
+ /* persistent properties from udev (may be empty) */
+ hal_device_property_set_string (d, "volume.fsusage", hotplug_event->sysfs.fsusage);
+ hal_device_property_set_string (d, "volume.fsversion", hotplug_event->sysfs.fsversion);
+ hal_device_property_set_string (d, "volume.uuid", hotplug_event->sysfs.fsuuid);
+ hal_device_property_set_string (d, "volume.fstype", hotplug_event->sysfs.fstype);
+ if (hotplug_event->sysfs.fstype[0] != '\0') {
+ snprintf (buf, sizeof (buf), "Volume (%s)", hotplug_event->sysfs.fstype);
+ } else {
+ snprintf (buf, sizeof (buf), "Volume");
+ }
+ hal_device_property_set_string (d, "info.product", buf);
+
+ volume_label = strdup_valid_utf8 (hotplug_event->sysfs.fslabel);
+ if (volume_label) {
+ hal_device_property_set_string (d, "volume.label", volume_label);
+ if (volume_label[0] != '\0') {
+ hal_device_property_set_string (d, "info.product", volume_label);
+ }
+ g_free(volume_label);
+ }
+
hal_device_property_set_bool (d, "volume.is_mounted", FALSE);
hal_device_property_set_bool (d, "volume.is_mounted_read_only", FALSE);
hal_device_property_set_bool (d, "volume.linux.is_device_mapper", is_device_mapper);
- hal_device_property_set_bool (
- d, "volume.is_disc",
- strcmp (hal_device_property_get_string (parent, "storage.drive_type"), "cdrom") == 0);
+ hal_device_property_set_bool (d, "volume.is_disc", strcmp (hal_device_property_get_string (parent, "storage.drive_type"), "cdrom") == 0);
is_physical_partition = TRUE;
diff --git a/hald/linux/probing/Makefile.am b/hald/linux/probing/Makefile.am
index 10bba43..d32a9a4 100644
--- a/hald/linux/probing/Makefile.am
+++ b/hald/linux/probing/Makefile.am
@@ -45,7 +45,7 @@ hald_probe_storage_LDADD = @GLIB_LIBS@ @VOLUME_ID_LIBS@ $(top_builddir)/libhal/l
hald_probe_pc_floppy_SOURCES = probe-pc-floppy.c ../../logger.c
hald_probe_volume_SOURCES = probe-volume.c linux_dvd_rw_utils.c ../../logger.c
-hald_probe_volume_LDADD = $(top_builddir)/libhal/libhal.la $(top_builddir)/partutil/libpartutil.la @GLIB_LIBS@ @VOLUME_ID_LIBS@
+hald_probe_volume_LDADD = $(top_builddir)/libhal/libhal.la $(top_builddir)/partutil/libpartutil.la @GLIB_LIBS@
hald_probe_ieee1394_unit_SOURCES = probe-ieee1394-unit.c ../../logger.c
hald_probe_ieee1394_unit_LDADD = $(top_builddir)/libhal/libhal.la
diff --git a/hald/linux/probing/probe-volume.c b/hald/linux/probing/probe-volume.c
index d9ea48d..a7c9951 100644
--- a/hald/linux/probing/probe-volume.c
+++ b/hald/linux/probing/probe-volume.c
@@ -42,116 +42,12 @@
#include <signal.h>
#include <glib.h>
-#include <libvolume_id.h>
#include "libhal/libhal.h"
#include "partutil/partutil.h"
#include "linux_dvd_rw_utils.h"
#include "../../logger.h"
-static void vid_log(int priority, const char *file, int line, const char *format, ...)
-{
- char log_str[1024];
- va_list args;
-
- va_start(args, format);
- vsnprintf(log_str, sizeof(log_str), format, args);
- logger_forward_debug("%s:%i %s\n", file, line, log_str);
- va_end(args);
-}
-
-static gchar *
-strdup_valid_utf8 (const char *str)
-{
- char *endchar;
- char *newstr;
- unsigned int fixes;
-
- if (str == NULL)
- return NULL;
-
- newstr = g_strdup (str);
-
- fixes = 0;
- while (!g_utf8_validate (newstr, -1, (const char **) &endchar)) {
- *endchar = '_';
- ++fixes;
- }
-
- /* If we had to fix more than 20% of the characters, give up */
- if (fixes > 0 && g_utf8_strlen (newstr, -1) / fixes < 5) {
- g_free (newstr);
- newstr = g_strdup("");
- }
-
- return newstr;
-}
-
-
-static void
-set_volume_id_values (LibHalChangeSet *cs, struct volume_id *vid)
-{
- char buf[256];
- const char *usage;
- const char *type;
- const char *type_version;
- const char *label;
- const char *uuid;
- DBusError error;
-
- dbus_error_init (&error);
-
- if (!volume_id_get_usage(vid, &usage))
- usage = "";
- libhal_changeset_set_property_string (cs, "volume.fsusage", usage);
- HAL_DEBUG (("volume.fsusage = '%s'", usage));
-
- if (!volume_id_get_type(vid, &type))
- type = "";
- if (!libhal_changeset_set_property_string (cs, "volume.fstype", type))
- libhal_changeset_set_property_string (cs, "volume.fstype", "");
- HAL_DEBUG(("volume.fstype = '%s'", type));
-
- if (!volume_id_get_type_version(vid, &type_version))
- type_version = "";
- libhal_changeset_set_property_string (cs, "volume.fsversion", type_version);
- HAL_DEBUG(("volume.fsversion = '%s'", type_version));
-
- if (!volume_id_get_uuid(vid, &uuid))
- uuid = "";
- libhal_changeset_set_property_string (cs, "volume.uuid", uuid);
- HAL_DEBUG(("volume.uuid = '%s'", uuid));
-
- if (!volume_id_get_label(vid, &label))
- label = "";
-
- if (label[0] != '\0') {
- char *volume_label;
-
- /* we need to be sure for a utf8 valid label, because dbus accept only utf8 valid strings */
- volume_label = strdup_valid_utf8 (label);
- if( volume_label != NULL ) {
- libhal_changeset_set_property_string (cs, "volume.label", volume_label);
- HAL_DEBUG(("volume.label = '%s'", volume_label));
-
- if (volume_label[0] != '\0') {
- libhal_changeset_set_property_string (cs, "info.product", volume_label);
- g_free(volume_label);
- return;
- }
-
- g_free(volume_label);
- }
- }
-
- if (type[0] != '\0') {
- snprintf (buf, sizeof (buf), "Volume (%s)", type);
- } else {
- snprintf (buf, sizeof (buf), "Volume (unknown)");
- }
- libhal_changeset_set_property_string (cs, "info.product", buf);
-}
-
static void
advanced_disc_detect (LibHalChangeSet *cs, int fd, const char *device_file)
{
@@ -311,7 +207,6 @@ main (int argc, char *argv[])
LibHalContext *ctx = NULL;
DBusError error;
char *parent_udi;
- struct volume_id *vid;
char *stordev_dev_file;
char *partition_number_str;
char *partition_start_str;
@@ -330,9 +225,6 @@ main (int argc, char *argv[])
cs = NULL;
disc_may_have_data = FALSE;
- /* hook in our debug into libvolume_id */
- volume_id_log_fn = vid_log;
-
setup_logger ();
/* assume failure */
@@ -618,76 +510,9 @@ main (int argc, char *argv[])
vol_size = 0;
}
- /* probe for file system */
- vid = volume_id_open_fd (fd);
- if (vid != NULL) {
- int vid_ret;
- HAL_INFO (("invoking volume_id_probe_all, offset=%d, size=%d", vol_probe_offset, vol_size));
- vid_ret = volume_id_probe_all (vid, vol_probe_offset, vol_size);
- HAL_INFO (("volume_id_probe_all returned %d", vid_ret));
-
- if (vid_ret != 0 && is_disc && vol_probe_offset != 0) {
- /* Some cd-rom drives report the offset of the session in the cd's TOC
- * wrong. Fallback to probing at offset 0, just to be sure */
- HAL_INFO (("invoking volume_id_probe_all, offset=0, size=%d", vol_size));
- vid_ret = volume_id_probe_all (vid, 0 , vol_size);
- HAL_INFO (("volume_id_probe_all returned %d", vid_ret));
- }
-
- if (vid_ret == 0) {
- set_volume_id_values(cs, vid);
- if (disc_may_have_data) {
- libhal_changeset_set_property_bool (cs, "volume.disc.is_blank", FALSE);
- libhal_changeset_set_property_bool (cs, "volume.disc.has_data", TRUE);
- }
- } else {
- libhal_changeset_set_property_string (cs, "info.product", "Volume");
- }
-
- /* If we didn't detect anything, look whether it's a partition table (some Apple discs
- * uses Apple Partition Map) and look at partitions
- *
- * (kind of a hack - ugh - we ought to export all these as fakevolumes... but
- * this is good enough for now... the only discs I know of that does this
- * is in fact Apple's install disc.)
- */
- if (vid_ret != 0 && is_disc) {
- PartitionTable *p;
- p = part_table_load_from_disk (stordev_dev_file);
- if (p != NULL) {
- int i;
-
- HAL_INFO (("Partition table with scheme '%s' on optical disc",
- part_get_scheme_name (part_table_get_scheme (p))));
-
- for (i = 0; i < part_table_get_num_entries (p); i++) {
- char *part_type;
-
- part_type = part_table_entry_get_type (p, i);
- HAL_INFO ((" partition %d has type '%s'", i, part_type));
- if (strcmp (part_type, "Apple_HFS") == 0) {
- guint64 part_offset;
-
- part_offset = part_table_entry_get_offset (p, i);
- if (volume_id_probe_all (
- vid, vol_probe_offset + part_offset, 0) == 0) {
-
- set_volume_id_values(cs, vid);
- }
-
- /* and we're done */
- break;
- }
- g_free (part_type);
- }
-
-
- HAL_INFO (("Done looking at part table"));
- part_table_free (p);
- }
- }
-
- volume_id_close(vid);
+ if (disc_may_have_data) {
+ libhal_changeset_set_property_bool (cs, "volume.disc.is_blank", FALSE);
+ libhal_changeset_set_property_bool (cs, "volume.disc.has_data", TRUE);
}
/* get partition type number, if we find a msdos partition table */
commit 98b0b8434bf3506c69c33de4f126d885448dcbbb
Merge: 689d050... 315ca27...
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Mon Nov 3 18:06:30 2008 +0100
Merged changes from git.freedesktop.org/git/hal.git (315ca276ffdde9a)
Merge commit '315ca276ffdde9a0cba809f67cddf58f258ee1d3'
commit 689d0503c451610d57645a4f8d316249c84a5746
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Fri Oct 31 15:58:49 2008 +0100
fix handling of Device Mapper devices for LUKS
HAL has currently a massive problem with Device Mapper devices,
especially on coldplug, and parallel device handling .
Since dm-devices are virtual devices and have no parent we can
never say (when HAL process the hotplug queue) which the related
parent storage device (e.g. /dev/sdb1) is and when it will be
available.
Changed HAL to identify dm-devices on hotplug/coldplug and to
mark them as such in the HotplugEvent with is_dm_device=TRUE.
When the hotplug queue get processed, delay all dm-device as long
as there are still non-dm block devices in the queue to be sure
that all block devices/volumes are available when the Device
Mapper block devices get handled.
diff --git a/hald/linux/coldplug.c b/hald/linux/coldplug.c
index d22fdd1..16fa34c 100644
--- a/hald/linux/coldplug.c
+++ b/hald/linux/coldplug.c
@@ -96,7 +96,11 @@ udev_info_to_hotplug_event (const UdevInfo *info)
if (info->device_file) {
g_snprintf (hotplug_event->sysfs.device_file, sizeof(hotplug_event->sysfs.device_file),
"%s/%s", dev_root, info->device_file);
- HAL_INFO(("with device file %s", hotplug_event->sysfs.device_file));
+ HAL_INFO(("with device file %s", hotplug_event->sysfs.device_file));
+ if (strstr(hotplug_event->sysfs.device_file, "/" DMPREFIX) != NULL) {
+ HAL_INFO (("Found a dm-device (%s) , mark it", hotplug_event->sysfs.device_file));
+ hotplug_event->sysfs.is_dm_device = TRUE;
+ }
}
if ((str = hal_util_strdup_valid_utf8(info->vendor)) != NULL) {
g_strlcpy (hotplug_event->sysfs.vendor, str, sizeof(hotplug_event->sysfs.vendor));
@@ -301,6 +305,10 @@ static HotplugEvent
HAL_INFO (("new event (dev node from kernel name) '%s' '%s'", sysfs_path, path));
g_strlcpy(hotplug_event->sysfs.device_file, path, sizeof(hotplug_event->sysfs.device_file));
+ if (strstr(hotplug_event->sysfs.device_file, "/" DMPREFIX) != NULL) {
+ HAL_INFO (("Found a dm-device (%s) , mark it", hotplug_event->sysfs.device_file));
+ hotplug_event->sysfs.is_dm_device = TRUE;
+ }
}
no_node:
diff --git a/hald/linux/hotplug.c b/hald/linux/hotplug.c
index 16ec1b4..eb23417 100644
--- a/hald/linux/hotplug.c
+++ b/hald/linux/hotplug.c
@@ -398,6 +398,12 @@ compare_events (HotplugEvent *hotplug_event, GList *events)
if (compare_event (hotplug_event, loop_event)) {
HAL_DEBUG (("event %s dependant on %s", hotplug_event->sysfs.sysfs_path, loop_event->sysfs.sysfs_path));
return TRUE;
+ } else if (hotplug_event->sysfs.is_dm_device) {
+ if ((loop_event->type == HOTPLUG_EVENT_SYSFS_BLOCK) && !loop_event->sysfs.is_dm_device) {
+ HAL_DEBUG (("event %s is dm-device, have at least one (%s) non-dm block device in queue -> held event.",
+ hotplug_event->sysfs.sysfs_path, loop_event->sysfs.sysfs_path ));
+ return TRUE;
+ }
}
}
return FALSE;
diff --git a/hald/linux/hotplug.h b/hald/linux/hotplug.h
index 06a32a5..24cd350 100644
--- a/hald/linux/hotplug.h
+++ b/hald/linux/hotplug.h
@@ -66,6 +66,9 @@ typedef struct
unsigned long long seqnum; /* kernel uevent sequence number */
int net_ifindex; /* Kernel ifindex for network devices */
+ /* if the device is a Device mapper device, used to prevent multiple string compares */
+ gboolean is_dm_device;
+
/* stuff udev may tell us about the device and we don't want to query */
char vendor[HAL_NAME_MAX];
char model[HAL_NAME_MAX];
diff --git a/hald/linux/osspec.c b/hald/linux/osspec.c
index 6d6472b..758b225 100644
--- a/hald/linux/osspec.c
+++ b/hald/linux/osspec.c
@@ -236,6 +236,11 @@ hald_udev_data (GIOChannel *source, GIOCondition condition, gpointer user_data)
HAL_INFO (("Temporary workaround: ignoring temporary cryptsetup file"));
goto invalid;
}
+ if (hotplug_event->sysfs.device_file && (strstr (hotplug_event->sysfs.device_file, "/dm-") != NULL)) {
+ HAL_DEBUG (("Found a dm-device (%s), mark it", hotplug_event->sysfs.device_file));
+ hotplug_event->sysfs.is_dm_device = TRUE;
+ }
+
HAL_INFO (("SEQNUM=%lld, ACTION=%s, SUBSYSTEM=%s, DEVPATH=%s, DEVNAME=%s, IFINDEX=%d",
hotplug_event->sysfs.seqnum, action, hotplug_event->sysfs.subsystem, hotplug_event->sysfs.sysfs_path,
commit b04aef9f3666a54a3f1b3b002a7f5c417219ee9f
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Thu Oct 30 18:56:23 2008 +0100
fixed typo, adjust description of volume.fstype.alternative.preferred
Fixed typo (s/prefered/preferred) and adjusted description of
volume.fstype.alternative.preferred to me more clear.
diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index 21b6104..0e1fe91 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -7374,14 +7374,17 @@ org.freedesktop.Hal.Device.Volume.method_signatures = {'ssas', 'as', 'as'}
</row>
<row>
<entry>
- <literal>volume.fstype.alternative.prefered</literal> (string)
+ <literal>volume.fstype.alternative.preferred</literal> (string)
</entry>
<entry>examples: ntfs-3g</entry>
<entry>No</entry>
<entry>
- The prefered alternative mount handler/filesystem. Allows e.g. a distributor
- do define a prefered handler especially if <literal>volume.fstype.alternative</literal>
- contains more than one value.
+ The preferred alternative mount handler/filesystem. Allows e.g. a distributor
+ do define a preferred of the alternative handlers.
+ If not set, the default filesystem (defined by <literal>volume.fstype</literal>)
+ should be used (or let the <literal>fstype</literal> parameter of Mount() empty),
+ otherwise it must be the name of one of the alternative handlers, as in
+ <literal>volume.fstype.alternative</literal>.
</entry>
</row>
<row>
commit 6f451b8a2c2053b4d5d8b58609c215024a55ea0d
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Thu Oct 30 15:43:59 2008 +0100
check module parameter of acpi video to set brightness_in_hardware
Check the acpi video module parameter brightness_switch_enabled via
sysfs to find out of the kernel handles already brightness changes if
a brightness key get pressed.
This works only for the generic 'video' module and only on HAL startup.
If someone change the module settings on runtime without reload the
module the value of brightness_in_hardware can be false. We can live
with this situation, since you should know what you do if you change
module parameter on runtime.
diff --git a/hald/linux/device.c b/hald/linux/device.c
index 7917e03..c3744e0 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -98,6 +98,7 @@ backlight_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *phy
{
HalDevice *d;
int max_brightness;
+ const char *id;
d = hal_device_new ();
hal_device_add_capability (d, "laptop_panel");
@@ -107,6 +108,23 @@ backlight_add (const gchar *sysfs_path, const gchar *device_file, HalDevice *phy
hal_device_property_set_string (d, "info.product", "Generic Backlight Device");
hal_device_property_set_string (d, "laptop_panel.access_method", "general");
+ id = hal_util_get_last_element (sysfs_path);
+ if (strstr(id, "acpi_video") != NULL) {
+ /* looks like the generic acpi video module */
+ const char *param;
+
+ /* Try to check the module parameter to decide if brightness_in_hardware should get set to true.
+ NOTE: this leads to wrong values if someone change the module parameter via
+ sysfs while HAL is running, but we can live with this situation! */
+ param = hal_util_get_string_from_file ("/sys/module/video/parameters/", "brightness_switch_enabled");
+
+ if (param && !strcmp(param, "Y")) {
+ hal_device_property_set_bool (d, "laptop_panel.brightness_in_hardware", TRUE);
+ } else {
+ hal_device_property_set_bool (d, "laptop_panel.brightness_in_hardware", FALSE);
+ }
+ }
+
hal_util_get_int_from_file (sysfs_path, "max_brightness", &max_brightness, 10);
hal_device_property_set_int (d, "laptop_panel.num_levels", max_brightness + 1);
return d;
commit fd4305a59fd0f3b9e5a7a260707e11ffebc4926d
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Thu Oct 30 13:46:34 2008 +0100
fixed md related code in hotplug_event_begin_add_blockdev()
Fixed md related code to find/set the parent devie in
hotplug_event_begin_add_blockdev().
diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index 40e363f..6432d31 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -891,7 +891,7 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
/* set parent to root computer device object */
parent = hal_device_store_find (hald_get_gdl (), "/org/freedesktop/Hal/devices/computer");
if (parent == NULL)
- d = hal_device_store_find (hald_get_tdl (), "/org/freedesktop/Hal/devices/computer");
+ parent = hal_device_store_find (hald_get_tdl (), "/org/freedesktop/Hal/devices/computer");
} else {
sysfs_path_real = g_strdup (sysfs_path);
}
commit 0e3a8372e81129433ed05e3690495f3e7175fff6
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Thu Oct 30 13:45:04 2008 +0100
add cciss as possible storage.bus to spec
Added cciss as possible storage.bus to spec.
diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index 29fa639..21b6104 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -6165,6 +6165,12 @@ org.freedesktop.Hal.Device.Volume.method_signatures = {'ssas', 'as', 'as'}
</row>
<row>
<entry></entry>
+ <entry>cciss</entry>
+ <entry></entry>
+ <entry>HP Smart Array CCISS interface</entry>
+ </row>
+ <row>
+ <entry></entry>
<entry>ccw</entry>
<entry></entry>
<entry>IBM s390/s390x ccw interface</entry>
commit fbaab44886211e38b1e839eb53d52bf4e8ed12a7
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Thu Oct 30 13:41:33 2008 +0100
add support for HP Smart Array CCISS block devices
Added support for HP Smart Array CCISS block devices, which are
in recent kernel versions virtual block/storage devices and no
longer pci based (also if the Smart Array controller is a PCI
device).
diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index ab42341..40e363f 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -864,11 +864,13 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
int floppy_num;
gboolean is_device_mapper;
gboolean is_md_device;
+ gboolean is_cciss_device;
int md_number;
is_device_mapper = FALSE;
is_fakevolume = FALSE;
is_md_device = FALSE;
+ is_cciss_device = FALSE;
HAL_INFO (("block_add: sysfs_path=%s dev=%s is_part=%d, parent=0x%08x",
sysfs_path, device_file, is_partition, parent));
@@ -905,63 +907,78 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
d = hal_device_new ();
- /* OK, no parent... it might a device-mapper device => check slaves/ subdir in sysfs */
+ /* OK, no parent... */
if (parent == NULL && !is_partition && !is_fakevolume && !hotplug_event->reposted) {
- DIR * dir;
- struct dirent *dp;
char path[HAL_PATH_MAX];
-
g_snprintf (path, HAL_PATH_MAX, "%s/slaves", sysfs_path);
- HAL_INFO (("Looking in %s for Device Mapper", path));
- if ((dir = opendir (path)) == NULL) {
- HAL_WARNING (("Unable to open %s: %s", path, strerror(errno)));
+ if (device_file && (strstr(device_file, "/dev/cciss/") != NULL)) {
+ /* ... it's a cciss (HP Smart Array CCISS) device */
+ if (g_file_test (path, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
+ HAL_DEBUG(("block_add: found cciss a base device"));
+
+ is_cciss_device = TRUE;
+ parent = hal_device_store_find (hald_get_gdl (), "/org/freedesktop/Hal/devices/computer");
+ if (parent == NULL)
+ parent = hal_device_store_find (hald_get_tdl (), "/org/freedesktop/Hal/devices/computer");
+ }
} else {
- while (((dp = readdir (dir)) != NULL) && (parent == NULL)) {
- char *link;
- char *target;
-
- link = g_strdup_printf ("%s/%s", path, dp->d_name);
- target = resolve_symlink (link);
- HAL_INFO ((" %s -> %s", link, target));
-
- if (target != NULL) {
- HalDevice *slave_volume;
-
- slave_volume = hal_device_store_match_key_value_string (hald_get_gdl (),
- "linux.sysfs_path",
- target);
- if (slave_volume != NULL) {
- const char *slave_volume_stordev_udi;
- const char *slave_volume_fstype;
-
- slave_volume_stordev_udi = hal_device_property_get_string (slave_volume, "block.storage_device");
- slave_volume_fstype = hal_device_property_get_string (slave_volume, "volume.fstype");
-
- /* Yup, we only support crypto_LUKS right now.
- *
- * In the future we can support other device-mapper mappings
- * such as LVM etc.
- */
- if (slave_volume_stordev_udi != NULL &&
- slave_volume_fstype != NULL &&
- (strcmp (slave_volume_fstype, "crypto_LUKS") == 0)) {
- HAL_INFO ((" slave_volume_stordev_udi='%s'!", slave_volume_stordev_udi));
- parent = hal_device_store_find (hald_get_gdl (), slave_volume_stordev_udi);
- if (parent != NULL) {
- HAL_INFO ((" parent='%s'!", hal_device_get_udi (parent)));
- hal_device_property_set_string (d, "volume.crypto_luks.clear.backing_volume", hal_device_get_udi (slave_volume));
- is_device_mapper = TRUE;
+ /* ... it might a device-mapper device => check slaves/ subdir in sysfs */
+ DIR * dir;
+ struct dirent *dp;
+
+ HAL_INFO (("Looking in %s for Device Mapper", path));
+
+ if ((dir = opendir (path)) == NULL) {
+ HAL_WARNING (("Unable to open %s: %s", path, strerror(errno)));
+ } else {
+ while (((dp = readdir (dir)) != NULL) && (parent == NULL)) {
+ char *link;
+ char *target;
+
+ link = g_strdup_printf ("%s/%s", path, dp->d_name);
+ target = resolve_symlink (link);
+ HAL_INFO ((" %s -> %s", link, target));
+
+ if (target != NULL) {
+ HalDevice *slave_volume;
+
+ slave_volume = hal_device_store_match_key_value_string (hald_get_gdl (),
+ "linux.sysfs_path",
+ target);
+ if (slave_volume != NULL) {
+ const char *slave_volume_stordev_udi;
+ const char *slave_volume_fstype;
+
+ slave_volume_stordev_udi = hal_device_property_get_string (slave_volume, "block.storage_device");
+ slave_volume_fstype = hal_device_property_get_string (slave_volume, "volume.fstype");
+
+ /* Yup, we only support crypto_LUKS right now.
+ *
+ * In the future we can support other device-mapper mappings
+ * such as LVM etc.
+ */
+ if (slave_volume_stordev_udi != NULL &&
+ slave_volume_fstype != NULL &&
+ (strcmp (slave_volume_fstype, "crypto_LUKS") == 0)) {
+ HAL_INFO ((" slave_volume_stordev_udi='%s'!", slave_volume_stordev_udi));
+ parent = hal_device_store_find (hald_get_gdl (), slave_volume_stordev_udi);
+ if (parent != NULL) {
+ HAL_INFO ((" parent='%s'!", hal_device_get_udi (parent)));
+ hal_device_property_set_string (d, "volume.crypto_luks.clear.backing_volume",
+ hal_device_get_udi (slave_volume));
+ is_device_mapper = TRUE;
+ }
}
+ } else {
+ HAL_INFO(("Couldn't find slave volume in devices"));
}
- } else {
- HAL_INFO(("Couldn't find slave volume in devices"));
}
+ g_free (target);
}
- g_free (target);
+ closedir(dir);
+ HAL_INFO (("Done looking in %s", path));
}
- closedir(dir);
- HAL_INFO (("Done looking in %s", path));
}
}
@@ -1136,12 +1153,17 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
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) {
+ HAL_DEBUG(("block_add: info.subsystem='%s'", bus));
+
if (strcmp (bus, "scsi") == 0) {
scsidev = d_it;
physdev = d_it;
commit 0eba52b670c9ed169d45d53c06d90456ff0dc75f
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Wed Oct 29 18:42:20 2008 +0100
add volume.fstype.alternative.prefered to spec
Defined new key volume.fstype.alternative.prefered (string) in the
spec. The new property allows e.g. a distributor to define the
prefered alternative mount handler/filesystem. The key can get used
by mount tools to find out which filesystem should be used if more
than one alternative was defined.
diff --git a/doc/spec/hal-spec-properties.xml b/doc/spec/hal-spec-properties.xml
index a942513..29fa639 100644
--- a/doc/spec/hal-spec-properties.xml
+++ b/doc/spec/hal-spec-properties.xml
@@ -7368,6 +7368,18 @@ org.freedesktop.Hal.Device.Volume.method_signatures = {'ssas', 'as', 'as'}
</row>
<row>
<entry>
+ <literal>volume.fstype.alternative.prefered</literal> (string)
+ </entry>
+ <entry>examples: ntfs-3g</entry>
+ <entry>No</entry>
+ <entry>
+ The prefered alternative mount handler/filesystem. Allows e.g. a distributor
+ do define a prefered handler especially if <literal>volume.fstype.alternative</literal>
+ contains more than one value.
+ </entry>
+ </row>
+ <row>
+ <entry>
<literal>volume.mount.[alternative].valid_options</literal> (string list)
</entry>
<entry>examples: locale=, uid=</entry>
commit a78b3c6b8fca7e3947cfb2c723cb4369135f4fca
Author: Danny Kukawka <danny.kukawka at web.de>
Date: Wed Oct 29 13:57:15 2008 +0100
remove generic sysfs backlight from scripts
Removed generic sysfs backlight from scripts. This is now handled
by the hald-addon-generic-backlight.
diff --git a/tools/linux/hal-system-lcd-get-brightness-linux b/tools/linux/hal-system-lcd-get-brightness-linux
index 5810785..65d7f67 100755
--- a/tools/linux/hal-system-lcd-get-brightness-linux
+++ b/tools/linux/hal-system-lcd-get-brightness-linux
@@ -7,12 +7,6 @@
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
-# we have /sys/class/backlight
-if [ -r "$HAL_PROP_LINUX_SYSFS_PATH/actual_brightness" ]; then
- value="`cat $HAL_PROP_LINUX_SYSFS_PATH/actual_brightness`"
- exit ${value}
-fi
-
if [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "pmu" ]; then
value="`hal-system-power-pmu getlcd`"
if [ $? -ne 0 ]; then
diff --git a/tools/linux/hal-system-lcd-set-brightness-linux b/tools/linux/hal-system-lcd-set-brightness-linux
index 4b4c2f1..57ec47b 100755
--- a/tools/linux/hal-system-lcd-set-brightness-linux
+++ b/tools/linux/hal-system-lcd-set-brightness-linux
@@ -7,12 +7,6 @@
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
-# we have /sys/class/backlight
-if [ -w "$HAL_PROP_LINUX_SYSFS_PATH/brightness" ]; then
- echo "$value" > $HAL_PROP_LINUX_SYSFS_PATH/brightness
- exit 0
-fi
-
if [ "$HAL_PROP_LAPTOP_PANEL_ACCESS_METHOD" = "pmu" ]; then
hal-system-power-pmu setlcd $value
if [ $? -ne 0 ]; then
More information about the hal-commit
mailing list