View | Details | Raw Unified
Collapse All | Expand All

(-) hal-0.5.7-orig/hald/linux2/blockdev.c (-1 / +54 lines)
 Lines 185-190    Link Here 
	dev_t devt = makedev(0, 0);
	dev_t devt = makedev(0, 0);
	GSList *volumes = NULL;
	GSList *volumes = NULL;
	GSList *volume;
	GSList *volume;
        GSList *autofs_mounts = NULL;
	/* open /proc/mounts */
	/* open /proc/mounts */
	g_snprintf (buf, sizeof (buf), "%s/mounts", get_hal_proc_path ());
	g_snprintf (buf, sizeof (buf), "%s/mounts", get_hal_proc_path ());
 Lines 205-210    Link Here 
	while ((mnte = getmntent_r (f, &mnt, buf, sizeof(buf))) != NULL) {
	while ((mnte = getmntent_r (f, &mnt, buf, sizeof(buf))) != NULL) {
		struct stat statbuf;
		struct stat statbuf;
		/* If this is a nfs mount or autofs 
		 * (fstype == 'nfs' || fstype == 'autofs') 
		 * ignore the mount. Reason:
		 *  1. we don't list nfs devices in HAL
  		 *  2. more problematic: stat on mountpoints with 
		 *     'stale nfs handle' never come
  		 *     back and block complete HAL and all applications 
		 *     using HAL fail.
		 *  3. autofs and HAL butt heads causing drives to never
		 *     be unmounted
  		 */
		if (strcmp(mnt.mnt_type, "nfs") == 0)
			continue;
		/* If this is an autofs mount (fstype == 'autofs' or fstype == 'subfs') 
		 * store the mount in a list for later use. 
		 * On mounts managed by autofs or subfs accessing files below the mount
		 * point cause the mount point to be remounted after an 
		 * unmount.  We keep the list so we do not check for
		 * the .created-by-hal file on mounts under autofs or subfs mount points
		 */
		if (strcmp(mnt.mnt_type, "autofs") == 0 ||
		    strcmp(mnt.mnt_type, "subfs") == 0) {
			char *mnt_dir;
			if (mnt.mnt_dir[strlen (mnt.mnt_dir) - 1] != '/')
				mnt_dir = g_strdup_printf ("%s/", mnt.mnt_dir);
			else
				mnt_dir = g_strdup (mnt.mnt_dir);
			autofs_mounts = g_slist_append (autofs_mounts,
							mnt_dir);
			continue;
		}
		/* check the underlying device of the mount point */
		/* check the underlying device of the mount point */
		if (stat (mnt.mnt_dir, &statbuf) != 0)
		if (stat (mnt.mnt_dir, &statbuf) != 0)
			continue;
			continue;
 Lines 242-247    Link Here 
		HalDevice *dev;
		HalDevice *dev;
		char *mount_point;
		char *mount_point;
		char *mount_point_hal_file;
		char *mount_point_hal_file;
		GSList *autofs_node;
		dev = HAL_DEVICE (volume->data);
		dev = HAL_DEVICE (volume->data);
		mount_point = g_strdup (hal_device_property_get_string (dev, "volume.mount_point"));
		mount_point = g_strdup (hal_device_property_get_string (dev, "volume.mount_point"));
 Lines 251-258    Link Here 
		device_property_atomic_update_end ();
		device_property_atomic_update_end ();
		HAL_INFO (("set %s to unmounted", hal_device_get_udi (dev)));
		HAL_INFO (("set %s to unmounted", hal_device_get_udi (dev)));
		/* check to see if mount point falls under autofs */
		autofs_node = autofs_mounts;
		while (autofs_node != NULL) {
			char *am = (char *)autofs_node->data;
			if (strncmp (am, mount_point, strlen (am)) == 0);
				break;
			autofs_node = autofs_node->next;
		}
		mount_point_hal_file = g_strdup_printf ("%s/.created-by-hal", mount_point);
		mount_point_hal_file = g_strdup_printf ("%s/.created-by-hal", mount_point);
		if (g_file_test (mount_point_hal_file, G_FILE_TEST_EXISTS)) {
		if (!autofs_node && 
		     g_file_test (mount_point_hal_file, G_FILE_TEST_EXISTS)) {
			char *cleanup_stdin;
			char *cleanup_stdin;
			char *extra_env[2];
			char *extra_env[2];
 Lines 279-284    Link Here 
		g_free (mount_point);
		g_free (mount_point);
	}
	}
	g_slist_free (volumes);
	g_slist_free (volumes);
	g_slist_foreach (autofs_mounts, (GFunc) g_free, NULL);
	g_slist_free (autofs_mounts);
exit:
exit:
	endmntent (f);
	endmntent (f);
}
}