View | Details | Raw Unified | Return to bug 113005
Collapse All | Expand All

(-)libgnomevfs/gnome-vfs-hal-mounts.c (+60 lines)
Lines 32-37 Link Here
32
#include <sys/sysmacros.h>
32
#include <sys/sysmacros.h>
33
#include <sys/types.h>
33
#include <sys/types.h>
34
#include <unistd.h>
34
#include <unistd.h>
35
#include <limits.h>
35
36
36
#include <glib.h>
37
#include <glib.h>
37
#include <glib/gi18n-lib.h>
38
#include <glib/gi18n-lib.h>
Lines 49-54 Link Here
49
50
50
#define PATH_GCONF_GNOME_VFS_STORAGE "/system/storage"
51
#define PATH_GCONF_GNOME_VFS_STORAGE "/system/storage"
51
52
53
#ifndef PATHNAME_MAX
54
# define PATHNAME_MAX	1024
55
#endif
56
52
typedef struct {
57
typedef struct {
53
	GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon;
58
	GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon;
54
	gboolean display_internal_hard_drives;
59
	gboolean display_internal_hard_drives;
Lines 1425-1430 Link Here
1425
	GnomeVFSDrive *result;
1430
	GnomeVFSDrive *result;
1426
	LibHalContext *hal_ctx; 
1431
	LibHalContext *hal_ctx; 
1427
	LibHalDrive *hal_drive;
1432
	LibHalDrive *hal_drive;
1433
	char path[PATH_MAX] = "/dev/";
1434
	char *target = path + 5;
1435
	int ret;
1428
1436
1429
	hal_drive = NULL;
1437
	hal_drive = NULL;
1430
1438
Lines 1445-1450 Link Here
1445
		/* ok, this device file is in HAL and thus managed by this backend */
1453
		/* ok, this device file is in HAL and thus managed by this backend */
1446
		gnome_vfs_drive_unref (drive);
1454
		gnome_vfs_drive_unref (drive);
1447
		result = NULL;
1455
		result = NULL;
1456
		goto out;
1457
	}
1458
1459
	/* No luck? Let's see if device_path is a symlink and check its target, too */
1460
	ret = readlink (drive->priv->device_path, target, PATH_MAX - 1);
1461
	if (ret < 0)
1462
		goto out;
1463
	target[ret] = '\0';
1464
	/* Save some prepending and store the "/dev/" needed for relative links */
1465
	if (target[0] != '/')
1466
		target = path;
1467
	hal_drive = libhal_drive_from_device_file (hal_ctx, target);
1468
	if (hal_drive != NULL) {
1469
		/* ok, this device file is in HAL and thus managed by this backend */
1470
		gnome_vfs_drive_unref (drive);
1471
		result = NULL;
1448
	}
1472
	}
1449
1473
1450
out:
1474
out:
Lines 1460-1465 Link Here
1460
	GnomeVFSVolume *result;
1484
	GnomeVFSVolume *result;
1461
	LibHalContext *hal_ctx; 
1485
	LibHalContext *hal_ctx; 
1462
	LibHalDrive *hal_drive;
1486
	LibHalDrive *hal_drive;
1487
	char path[PATH_MAX] = "/dev/";
1488
	char *target = path + 5;
1489
	int ret;
1463
1490
1464
	hal_drive = NULL;
1491
	hal_drive = NULL;
1465
1492
Lines 1478-1483 Link Here
1478
	hal_drive = libhal_drive_from_device_file (hal_ctx, volume->priv->device_path);
1505
	hal_drive = libhal_drive_from_device_file (hal_ctx, volume->priv->device_path);
1479
	if (hal_drive != NULL) {
1506
	if (hal_drive != NULL) {
1480
1507
1508
		/* handle drives that HAL can't poll and the user can still mount */
1509
		if (libhal_device_get_property_bool (hal_ctx, 
1510
						     libhal_drive_get_udi (hal_drive),
1511
						     "storage.media_check_enabled",
1512
						     NULL) == FALSE) {
1513
			GnomeVFSDrive *drive;
1514
1515
			if ((drive = _gnome_vfs_volume_monitor_find_drive_by_hal_udi (
1516
				     GNOME_VFS_VOLUME_MONITOR (volume_monitor_daemon),
1517
				     libhal_drive_get_udi (hal_drive))) != NULL) {
1518
				volume->priv->drive = drive;
1519
				_gnome_vfs_drive_add_mounted_volume (drive, volume);
1520
				
1521
				goto out;
1522
			}
1523
		}
1524
1525
		/* ok, this device file is in HAL and thus managed by this backend */
1526
		gnome_vfs_volume_unref (volume);
1527
		result = NULL;
1528
		goto out;
1529
	}
1530
1531
	/* No luck? Let's see if device_path is a symlink and check its target, too */
1532
	ret = readlink (volume->priv->device_path, target, PATH_MAX - 1);
1533
	if (ret < 0)
1534
		goto out;
1535
	target[ret] = '\0';
1536
	/* Save some prepending and store the "/dev/" needed for relative links */
1537
	if (target[0] != '/')
1538
		target = path;
1539
	hal_drive = libhal_drive_from_device_file (hal_ctx, target);
1540
	if (hal_drive != NULL) {
1481
		/* handle drives that HAL can't poll and the user can still mount */
1541
		/* handle drives that HAL can't poll and the user can still mount */
1482
		if (libhal_device_get_property_bool (hal_ctx, 
1542
		if (libhal_device_get_property_bool (hal_ctx, 
1483
						     libhal_drive_get_udi (hal_drive),
1543
						     libhal_drive_get_udi (hal_drive),

Return to bug 113005