hal/hald/linux2 blockdev.c,1.25,1.26
Danny Kukawka
dkukawka at freedesktop.org
Wed Oct 26 11:42:04 PDT 2005
Update of /cvs/hal/hal/hald/linux2
In directory gabe:/tmp/cvs-serv10601/hald/linux2
Modified Files:
blockdev.c
Log Message:
2005-10-26 Danny Kukawka <danny.kukawka at web.de>
* hald/linux2/blockdev.c: (update_mount_point): Added, to workaround
kernel problem with announce mounted device in /proc/mounts before
send netlink event (currently reported for gentoo kernel, see:
http://lists.freedesktop.org/archives/hal/2005-October/003634.html),
one retry after 0.3 seconds to check /proc/mounts.
This is specially for voluntary preemption kernel.
Index: blockdev.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/blockdev.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- blockdev.c 28 Sep 2005 16:35:05 -0000 1.25
+++ blockdev.c 26 Oct 2005 18:42:02 -0000 1.26
@@ -169,7 +169,8 @@
const char *device_file;
char buf[512];
unsigned int major, minor;
-
+ gboolean retry = FALSE;
+
if ((device_file = hal_device_property_get_string (d, "block.device")) == NULL)
goto out;
@@ -178,27 +179,45 @@
HAL_INFO (("Update mount point for %s (device_file %s)", d->udi, device_file));
- snprintf (buf, sizeof (buf), "%s/mounts", get_hal_proc_path ());
- if ((f = setmntent (buf, "r")) == NULL) {
- HAL_ERROR (("Could not open /proc/mounts"));
- goto out;
- }
- while ((mnte = getmntent_r (f, &mnt, buf, sizeof(buf))) != NULL) {
- struct stat statbuf;
+ do {
+ snprintf (buf, sizeof (buf), "%s/mounts", get_hal_proc_path ());
+ if ((f = setmntent (buf, "r")) == NULL) {
+ HAL_ERROR (("Could not open /proc/mounts"));
+ goto out;
+ }
- if (stat (mnt.mnt_fsname, &statbuf) != 0)
- continue;
+ while ((mnte = getmntent_r (f, &mnt, buf, sizeof(buf))) != NULL) {
+ struct stat statbuf;
- if ((major (statbuf.st_rdev) == major) && (minor (statbuf.st_rdev) == minor)) {
- device_property_atomic_update_begin ();
- hal_device_property_set_bool (d, "volume.is_mounted", TRUE);
- hal_device_property_set_string (d, "volume.mount_point", mnt.mnt_dir);
- device_property_atomic_update_end ();
- HAL_INFO (("Setting mount point %s for %s", mnt.mnt_dir, device_file));
- goto found;
+ if (stat (mnt.mnt_fsname, &statbuf) != 0)
+ continue;
+
+ if ((major (statbuf.st_rdev) == major) && (minor (statbuf.st_rdev) == minor)) {
+ device_property_atomic_update_begin ();
+ hal_device_property_set_bool (d, "volume.is_mounted", TRUE);
+ hal_device_property_set_string (d, "volume.mount_point", mnt.mnt_dir);
+ device_property_atomic_update_end ();
+ HAL_INFO (("Setting mount point %s for %s", mnt.mnt_dir, device_file));
+ goto found;
+ }
}
- }
+
+ /* to workaround http://lists.freedesktop.org/archives/hal/2005-October/003634.html
+ * If device is not in proc: sleep 0.3 seconds and retry _one time_ to check again.
+ *
+ * NOTE: This workaround is for voluntary preemption kernel and should be removed if
+ * the problem is fixed in the kernel.
+ */
+ if (retry) {
+ HAL_WARNING (("Could not find %s in %s/mounts, no second retry.", device_file, get_hal_proc_path ()));
+ retry = FALSE;
+ } else {
+ retry = TRUE;
+ usleep (300000);
+ HAL_WARNING (("Could not find %s in %s/mounts retry to find.", device_file, get_hal_proc_path ()));
+ }
+ } while (retry);
device_property_atomic_update_begin ();
hal_device_property_set_bool (d, "volume.is_mounted", FALSE);
More information about the hal-commit
mailing list