hal/hald/linux2 blockdev.c,1.15,1.16
David Zeuthen
david at freedesktop.org
Fri Apr 29 14:40:00 PDT 2005
Update of /cvs/hal/hal/hald/linux2
In directory gabe:/tmp/cvs-serv11114/hald/linux2
Modified Files:
blockdev.c
Log Message:
2005-04-29 David Zeuthen <davidz at redhat.com>
* hald/linux2/blockdev.c (update_mount_point): Fix the TODO about
using major:minor to check for whether something is mounted. Now
it works with e.g. 'mount /dev/dvd /mnt/tmp' where /dev/dvd is
a symlink to the real device and /mnt/tmp nor /dev/dvd is mentioned
in the /etc/fstab file.
(force_unmount): Use mount point, not device name (from Rohan
McGovern <rohan.pm at gmail.com>).
Index: blockdev.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/blockdev.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- blockdev.c 16 Mar 2005 20:09:47 -0000 1.15
+++ blockdev.c 29 Apr 2005 21:39:58 -0000 1.16
@@ -162,10 +162,14 @@
struct mntent *mnte;
const char *device_file;
char buf[512];
+ unsigned int major, minor;
if ((device_file = hal_device_property_get_string (d, "block.device")) == NULL)
goto out;
+ major = hal_device_property_get_int (d, "block.major");
+ minor = hal_device_property_get_int (d, "block.minor");
+
HAL_INFO (("Update mount point for %s (device_file %s)", d->udi, device_file));
snprintf (buf, sizeof (buf), "%s/mounts", get_hal_proc_path ());
@@ -174,9 +178,13 @@
goto out;
}
- /* TODO: should use major:minor numbers to catch /dev/root */
while ((mnte = getmntent_r (f, &mnt, buf, sizeof(buf))) != NULL) {
- if (strcmp (mnt.mnt_fsname, device_file) == 0) {
+ struct stat statbuf;
+
+ 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);
@@ -971,14 +979,14 @@
}
}
- umount_argv[2] = device_file;
+ umount_argv[2] = device_mount_point;
if (hal_device_has_property (d, "block.is_volume") &&
hal_device_property_get_bool (d, "block.is_volume") &&
hal_device_property_get_bool (d, "volume.is_mounted") &&
device_mount_point != NULL &&
strlen (device_mount_point) > 0) {
- HAL_INFO (("attempting /bin/umount -l %s", device_file));
+ HAL_INFO (("attempting /bin/umount -l %s", device_mount_point));
/* TODO: this is a bit dangerous; rather spawn async and do some timout on it */
More information about the hal-commit
mailing list