static LibHalVolume *pusb_volume_probe(t_pusb_options *opts, LibHalContext *ctx) { LibHalVolume *volume = NULL; int maxtries = 0; int i; if (!*(opts->device.volume_uuid)) { log_debug("No UUID configured for device\n"); return (NULL); } log_debug("Searching for volume with uuid %s\n", opts->device.volume_uuid); maxtries = ((opts->probe_timeout * 1000000) / 250000); for (i = 0; i < maxtries; ++i) { char *udi = NULL; if (i == 1) log_info("Probing volume (this could take a while)...\n"); udi = pusb_hal_find_item(ctx, "volume.uuid", opts->device.volume_uuid, NULL); if (!udi) { usleep(250000); continue; } volume = libhal_volume_from_udi(ctx, udi); libhal_free_string(udi); if (!libhal_volume_should_ignore(volume)) return (volume); libhal_volume_free(volume); usleep(250000); } return (NULL); }
static void thunar_vfs_volume_manager_hal_device_added (LibHalContext *context, const gchar *udi) { ThunarVfsVolumeManagerHal *manager_hal = libhal_ctx_get_user_data (context); ThunarVfsVolumeHal *volume_hal; LibHalVolume *hv; LibHalDrive *hd; const gchar *drive_udi; _thunar_vfs_return_if_fail (THUNAR_VFS_IS_VOLUME_MANAGER_HAL (manager_hal)); _thunar_vfs_return_if_fail (manager_hal->context == context); /* check if we have a volume here */ hv = libhal_volume_from_udi (context, udi); /* HAL might want us to ignore this volume for some reason */ if (G_UNLIKELY (hv != NULL && libhal_volume_should_ignore (hv))) { libhal_volume_free (hv); return; } /* emit the "device-added" signal (to support thunar-volman) */ g_signal_emit_by_name (G_OBJECT (manager_hal), "device-added", udi); if (G_LIKELY (hv != NULL)) { /* check if we have a mountable file system here */ if (libhal_volume_get_fsusage (hv) == LIBHAL_VOLUME_USAGE_MOUNTABLE_FILESYSTEM) { /* determine the UDI of the drive to which this volume belongs */ drive_udi = libhal_volume_get_storage_device_udi (hv); if (G_LIKELY (drive_udi != NULL)) { /* determine the drive for the volume */ hd = libhal_drive_from_udi (context, drive_udi); if (G_LIKELY (hd != NULL)) { /* check if we already have a volume object for the UDI */ volume_hal = thunar_vfs_volume_manager_hal_get_volume_by_udi (manager_hal, udi); if (G_LIKELY (volume_hal == NULL)) { /* otherwise, we allocate a new volume object */ volume_hal = g_object_new (THUNAR_VFS_TYPE_VOLUME_HAL, NULL); volume_hal->udi = g_strdup (udi); } /* update the volume object with the new data from the HAL volume/drive */ thunar_vfs_volume_hal_update (volume_hal, context, hv, hd); /* add the volume object to our list if we allocated a new one */ if (g_list_find (THUNAR_VFS_VOLUME_MANAGER (manager_hal)->volumes, volume_hal) == NULL) { /* add the volume to the volume manager */ thunar_vfs_volume_manager_add (THUNAR_VFS_VOLUME_MANAGER (manager_hal), THUNAR_VFS_VOLUME (volume_hal)); /* release the reference on the volume */ g_object_unref (G_OBJECT (volume_hal)); } /* release the HAL drive */ libhal_drive_free (hd); } } } /* release the HAL volume */ libhal_volume_free (hv); } else { /* but maybe we have a floppy disk drive here */ hd = libhal_drive_from_udi (context, udi); if (G_UNLIKELY (hd == NULL)) return; /* check if we have a floppy disk drive */ if (G_LIKELY (libhal_drive_get_type (hd) == LIBHAL_DRIVE_TYPE_FLOPPY)) { /* check if we already have a volume object for the UDI */ volume_hal = thunar_vfs_volume_manager_hal_get_volume_by_udi (manager_hal, udi); if (G_LIKELY (volume_hal == NULL)) { /* otherwise, we allocate a new volume object */ volume_hal = g_object_new (THUNAR_VFS_TYPE_VOLUME_HAL, NULL); volume_hal->udi = g_strdup (udi); } /* update the volume object with the new data from the HAL volume/drive */ thunar_vfs_volume_hal_update (volume_hal, context, NULL, hd); /* add the volume object to our list if we allocated a new one */ if (g_list_find (THUNAR_VFS_VOLUME_MANAGER (manager_hal)->volumes, volume_hal) == NULL) { /* add the volume to the volume manager */ thunar_vfs_volume_manager_add (THUNAR_VFS_VOLUME_MANAGER (manager_hal), THUNAR_VFS_VOLUME (volume_hal)); /* release the reference on the volume */ g_object_unref (G_OBJECT (volume_hal)); } } /* release the HAL drive */ libhal_drive_free (hd); } }