hal/hald/linux2 blockdev.c,1.13,1.14 coldplug.c,1.12,1.13
David Zeuthen
david at freedesktop.org
Mon Mar 14 21:47:45 PST 2005
Update of /cvs/hal/hal/hald/linux2
In directory gabe:/tmp/cvs-serv21565/hald/linux2
Modified Files:
blockdev.c coldplug.c
Log Message:
2005-03-12 W. Michael Petullo <mike at flyn.org>
* hald/linux2/blockdev.c: s/sesame/luks.
* hald/linux2/coldplug.c: Ensure that device mapper devices are
processed after all other block devices.
Index: blockdev.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/blockdev.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- blockdev.c 4 Mar 2005 17:48:47 -0000 1.13
+++ blockdev.c 15 Mar 2005 05:47:43 -0000 1.14
@@ -453,10 +453,10 @@
* we can ask about the name for /dev/dm-0; as e.g. given by
* 'dmsetup info'
*
- * Our assumption is that sesame-setup have invoked
+ * Our assumption is that luks-setup have invoked
* dmsetup; e.g. the naming convention is
*
- * sesame_crypto_<luks_uuid>
+ * luks_crypto_<luks_uuid>
*
* where <luks_uuid> is the UUID encoded in the luks
* metadata.
@@ -469,15 +469,15 @@
char devpath[256];
struct stat statbuf;
while ((f = g_dir_read_name (dir)) != NULL) {
- char sesame_prefix[] = "sesame_crypto_";
+ char luks_prefix[] = "luks_crypto_";
HAL_INFO (("looking at /dev/mapper/%s", f));
g_snprintf (devpath, sizeof (devpath), "/dev/mapper/%s", f);
if (stat (devpath, &statbuf) == 0) {
if (S_ISBLK (statbuf.st_mode) &&
MAJOR(statbuf.st_rdev) == major &&
MINOR(statbuf.st_rdev) == minor &&
- strncmp (f, sesame_prefix, sizeof (sesame_prefix) - 1) == 0) {
- luks_uuid = f + sizeof (sesame_prefix) - 1;
+ strncmp (f, luks_prefix, sizeof (luks_prefix) - 1) == 0) {
+ luks_uuid = f + sizeof (luks_prefix) - 1;
HAL_INFO (("found %s; luks_uuid='%s'!", devpath, luks_uuid));
break;
}
@@ -510,7 +510,7 @@
parent = hal_device_store_find (hald_get_gdl (), backing_volume_stordev_udi);
if (parent != NULL) {
HAL_INFO (("parent='%s'!", parent->udi));
- hal_device_property_set_string (device, "volume.crypto_sesame.clear.backing_volume", backing_volume->udi);
+ hal_device_property_set_string (device, "volume.crypto_luks.clear.backing_volume", backing_volume->udi);
}
}
}
Index: coldplug.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/coldplug.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- coldplug.c 28 Feb 2005 04:53:15 -0000 1.12
+++ coldplug.c 15 Mar 2005 05:47:43 -0000 1.13
@@ -50,6 +50,10 @@
#include "coldplug.h"
#include "hotplug.h"
+#define DMPREFIX "dm-"
+
+static gboolean
+coldplug_synthesize_block_event(const gchar *f);
static void
coldplug_compute_visit_device (const gchar *path,
@@ -134,6 +138,14 @@
*/
GSList *sysfs_other_class_dev = NULL;
+ /* Device mapper devices that should be added after all other block devices
+ *
+ * Example:
+ *
+ * (/sys/block/dm-0)
+ */
+ GSList *sysfs_dm_dev = NULL;
+
/* build bus map */
sysfs_to_bus_map = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
g_snprintf (path, HAL_PATH_MAX, "%s/bus", get_hal_sysfs_path ());
@@ -305,74 +317,102 @@
goto error;
}
while ((f = g_dir_read_name (dir)) != NULL) {
- GDir *dir1;
- gsize flen;
- HotplugEvent *hotplug_event;
- gchar *target;
- gchar *normalized_target;
+ if (g_str_has_prefix (f, DMPREFIX)) {
+ /* defer dm devices */
+ sysfs_dm_dev = g_slist_append(sysfs_dm_dev, g_strdup(f));
+ continue;
+ }
+ if (coldplug_synthesize_block_event(f) == FALSE)
+ goto error;
+ }
+ /* process all dm devices last so that their backing devices exist */
+ for (li = sysfs_dm_dev; li != NULL; li = g_slist_next (g_slist_next (li))) {
+ if (coldplug_synthesize_block_event(li->data) == FALSE)
+ goto error;
+ g_free (li->data);
+ }
+ g_slist_free (sysfs_dm_dev);
+ g_dir_close (dir);
+
+ return TRUE;
+error:
+ HAL_ERROR (("Error building the orderered list of sysfs paths"));
+ return FALSE;
+}
- g_snprintf (path, HAL_PATH_MAX, "%s/block/%s", get_hal_sysfs_path (), f);
+static gboolean
+coldplug_synthesize_block_event(const gchar *f)
+{
+ GDir *dir1;
+ gsize flen;
+ HotplugEvent *hotplug_event;
+ gchar *target;
+ gchar *normalized_target;
+ GError *err = NULL;
+ gchar path[HAL_PATH_MAX];
+ gchar path1[HAL_PATH_MAX];
+ const gchar *f1;
+
+ g_snprintf (path, HAL_PATH_MAX, "%s/block/%s", get_hal_sysfs_path (), f);
#ifdef HAL_COLDPLUG_VERBOSE
- printf ("block: %s (block)\n", path);
+ printf ("block: %s (block)\n", path);
#endif
- g_snprintf (path1, HAL_PATH_MAX, "%s/block/%s/device", get_hal_sysfs_path (), f);
- if (((target = g_file_read_link (path1, NULL)) != NULL)) {
- normalized_target = hal_util_get_normalized_path (path1, target);
- g_free (target);
- } else {
- normalized_target = NULL;
- }
+ g_snprintf (path1, HAL_PATH_MAX, "%s/block/%s/device", get_hal_sysfs_path (), f);
+ if (((target = g_file_read_link (path1, NULL)) != NULL)) {
+ normalized_target = hal_util_get_normalized_path (path1, target);
+ g_free (target);
+ } else {
+ normalized_target = NULL;
+ }
- hotplug_event = g_new0 (HotplugEvent, 1);
- hotplug_event->is_add = TRUE;
- hotplug_event->type = HOTPLUG_EVENT_SYSFS;
- g_strlcpy (hotplug_event->sysfs.subsystem, "block", sizeof (hotplug_event->sysfs.subsystem));
- g_strlcpy (hotplug_event->sysfs.sysfs_path, path, sizeof (hotplug_event->sysfs.sysfs_path));
- hal_util_get_device_file (path, hotplug_event->sysfs.device_file, sizeof (hotplug_event->sysfs.device_file));
- if (normalized_target != NULL)
- g_strlcpy (hotplug_event->sysfs.wait_for_sysfs_path, normalized_target, sizeof (hotplug_event->sysfs.wait_for_sysfs_path));
- else
- hotplug_event->sysfs.wait_for_sysfs_path[0] = '\0';
- hotplug_event->sysfs.net_ifindex = -1;
- hotplug_event_enqueue (hotplug_event);
- g_free (normalized_target);
+ hotplug_event = g_new0 (HotplugEvent, 1);
+ hotplug_event->is_add = TRUE;
+ hotplug_event->type = HOTPLUG_EVENT_SYSFS;
+ g_strlcpy (hotplug_event->sysfs.subsystem, "block", sizeof (hotplug_event->sysfs.subsystem));
+ g_strlcpy (hotplug_event->sysfs.sysfs_path, path, sizeof (hotplug_event->sysfs.sysfs_path));
+ hal_util_get_device_file (path, hotplug_event->sysfs.device_file, sizeof (hotplug_event->sysfs.device_file));
+ if (normalized_target != NULL)
+ g_strlcpy (hotplug_event->sysfs.wait_for_sysfs_path, normalized_target, sizeof (hotplug_event->sysfs.wait_for_sysfs_path));
+ else
+ hotplug_event->sysfs.wait_for_sysfs_path[0] = '\0';
+ hotplug_event->sysfs.net_ifindex = -1;
+ hotplug_event_enqueue (hotplug_event);
+ g_free (normalized_target);
- flen = strlen (f);
+ flen = strlen (f);
- if ((dir1 = g_dir_open (path, 0, &err)) == NULL) {
- HAL_ERROR (("Unable to open %s: %s", path, err->message));
- g_error_free (err);
- goto error;
- }
- while ((f1 = g_dir_read_name (dir1)) != NULL) {
- if (strncmp (f, f1, flen) == 0) {
- g_snprintf (path1, HAL_PATH_MAX, "%s/%s", path, f1);
+ if ((dir1 = g_dir_open (path, 0, &err)) == NULL) {
+ HAL_ERROR (("Unable to open %s: %s", path, err->message));
+ g_error_free (err);
+ goto error;
+ }
+ while ((f1 = g_dir_read_name (dir1)) != NULL) {
+ if (strncmp (f, f1, flen) == 0) {
+ g_snprintf (path1, HAL_PATH_MAX, "%s/%s", path, f1);
#ifdef HAL_COLDPLUG_VERBOSE
- printf ("block: %s (block)\n", path1);
+ printf ("block: %s (block)\n", path1);
#endif
- hotplug_event = g_new0 (HotplugEvent, 1);
- hotplug_event->is_add = TRUE;
- hotplug_event->type = HOTPLUG_EVENT_SYSFS;
- g_strlcpy (hotplug_event->sysfs.subsystem, "block", sizeof (hotplug_event->sysfs.subsystem));
- g_strlcpy (hotplug_event->sysfs.sysfs_path, path1, sizeof (hotplug_event->sysfs.sysfs_path));
- g_strlcpy (hotplug_event->sysfs.wait_for_sysfs_path, path, sizeof (hotplug_event->sysfs.wait_for_sysfs_path));
- hal_util_get_device_file (path1, hotplug_event->sysfs.device_file, sizeof (hotplug_event->sysfs.device_file));
- hotplug_event->sysfs.net_ifindex = -1;
- hotplug_event_enqueue (hotplug_event);
- }
+ hotplug_event = g_new0 (HotplugEvent, 1);
+ hotplug_event->is_add = TRUE;
+ hotplug_event->type = HOTPLUG_EVENT_SYSFS;
+ g_strlcpy (hotplug_event->sysfs.subsystem, "block", sizeof (hotplug_event->sysfs.subsystem));
+ g_strlcpy (hotplug_event->sysfs.sysfs_path, path1, sizeof (hotplug_event->sysfs.sysfs_path));
+ g_strlcpy (hotplug_event->sysfs.wait_for_sysfs_path, path, sizeof (hotplug_event->sysfs.wait_for_sysfs_path));
+ hal_util_get_device_file (path1, hotplug_event->sysfs.device_file, sizeof (hotplug_event->sysfs.device_file));
+ hotplug_event->sysfs.net_ifindex = -1;
+ hotplug_event_enqueue (hotplug_event);
}
- g_dir_close (dir1);
}
- g_dir_close (dir);
+ g_dir_close (dir1);
return TRUE;
error:
- HAL_ERROR (("Error building the orderered list of sysfs paths"));
return FALSE;
}
+
static void
coldplug_compute_visit_device (const gchar *path,
GHashTable *sysfs_to_bus_map,
More information about the hal-commit
mailing list