[patch] some fixes for is_mounted detection
Sjoerd Simons
sjoerd at luon.net
Mon Jun 28 13:37:33 PDT 2004
Hi,
There were two little problems with mount detection, which caused it to be
not work properly on my machines.
First in read_etc_fstab, the number of num_mount_points is reset at the start
of the function, while it could still decide not to reread the mtab. Causing
the mount_points array to be emptied every time something in /etc changed..
Second at the end of block_class_pre_process both detect_media and
etc_mtab_process_all_block_devices are called, but these only work on devices
in the gdl and at that time the device is still in the tdl. So they're
basically nops there. To solve this i've adjusted the ClassDeviceHandler
stuff to also call the post_merge function. And let the one for block devices
call detect_media and etc_mtab_process_all_block_devices..
Sjoerd
--
Long were the days of pain I have spent within its walls, and
long were the nights of aloneness; and who can depart from his
pain and his aloneness without regret?
-- Kahlil Gibran, "The Prophet"
-------------- next part --------------
Index: hald/linux/block_class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/block_class_device.c,v
retrieving revision 1.33
diff -u -r1.33 block_class_device.c
--- hald/linux/block_class_device.c 24 Jun 2004 21:47:49 -0000 1.33
+++ hald/linux/block_class_device.c 28 Jun 2004 19:09:28 -0000
@@ -1419,11 +1419,11 @@
"storage.", propname);
}
}
+}
- /* check for media on the device */
- detect_media (d, FALSE);
-
- /* Check the mtab to see if the device is mounted */
+static void
+block_class_post_merge(ClassDeviceHandler *handler, HalDevice *device) {
+ detect_media(device, FALSE);
etc_mtab_process_all_block_devices (TRUE);
}
@@ -1464,7 +1464,7 @@
static struct mount_point_s mount_points[MOUNT_POINT_MAX];
/** Number of elements in #mount_points array */
-static int num_mount_points;
+static int num_mount_points = 0;
static int etc_fd = -1;
@@ -1570,7 +1570,6 @@
FILE *f;
struct stat stat_buf;
- num_mount_points = 0;
fd = open ("/etc/mtab", O_RDONLY);
@@ -1592,6 +1591,7 @@
}
etc_mtab_mtime = stat_buf.st_mtime;
+ num_mount_points = 0;
/*printf("Modification, etc_mtab_mtime=%d\n", etc_mtab_mtime); */
@@ -2032,7 +2032,7 @@
class_device_udev_event, /**< handle udev event */
class_device_get_device_file_target,/**< where to store devfile name */
block_class_pre_process, /**< add more properties */
- class_device_post_merge, /**< post merge function */
+ block_class_post_merge, /**< post merge function */
block_class_got_udi, /**< got UDI */
block_class_compute_udi, /**< UDI computation */
"block", /**< sysfs class name */
Index: hald/linux/class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/class_device.c,v
retrieving revision 1.16
diff -u -r1.16 class_device.c
--- hald/linux/class_device.c 9 Jun 2004 18:11:59 -0000 1.16
+++ hald/linux/class_device.c 28 Jun 2004 19:09:28 -0000
@@ -391,6 +391,18 @@
class_device_final (self, d, merge_or_add);
}
+void
+class_device_callout_done(HalDevice *device, gpointer user_data) {
+ ClassDeviceHandler *handler = (ClassDeviceHandler *) user_data;
+ g_object_ref(device);
+ g_signal_handlers_disconnect_by_func (device,
+ class_device_callout_done,
+ user_data);
+ device_move_from_tdl_to_gdl(device, NULL);
+ handler->post_merge(handler, device);
+ g_object_unref(device);
+}
+
static void
class_device_final (ClassDeviceHandler* self, HalDevice *d,
gboolean merge_or_add)
@@ -464,8 +476,8 @@
g_signal_connect (device_to_add,
"callouts_finished",
- G_CALLBACK (device_move_from_tdl_to_gdl),
- NULL);
+ G_CALLBACK (class_device_callout_done),
+ self);
hal_callout_device (device_to_add, TRUE);
} else {
@@ -516,8 +528,7 @@
}
/** Called when an inferior HalDevice is merged. This is the
- * last step when merging in devices. This is only invoked if
- * merge_or_add is TRUE.
+ * last step when merging in devices.
*
* @param self Pointer to the class members
* @param d The HalDevice object recently merged
Index: hald/linux/class_device.h
===================================================================
RCS file: /cvs/hal/hal/hald/linux/class_device.h,v
retrieving revision 1.8
diff -u -r1.8 class_device.h
--- hald/linux/class_device.h 25 May 2004 20:09:29 -0000 1.8
+++ hald/linux/class_device.h 28 Jun 2004 19:09:28 -0000
@@ -160,8 +160,7 @@
struct sysfs_class_device *class_device);
/** Called when an inferior HalDevice is merged. This is the
- * last step when merging in devices. This is only invoked if
- * merge_or_add is TRUE.
+ * last step when merging in devices.
*
* @param self Pointer to the class members
* @param d The HalDevice object recently merged
-------------- next part --------------
_______________________________________________
hal mailing list
hal at freedesktop.org
http://freedesktop.org/mailman/listinfo/hal
More information about the Hal
mailing list