106
hf_probe_volume_get_label (const struct volume_id *vid)
108
hf_probe_volume_get_label (const blkid_probe pr)
111
char *volume_label = NULL;
110
if (vid && *vid->label)
113
if (blkid_probe_lookup_value(pr, "LABEL", &label, NULL) == 0)
112
if (g_utf8_validate(vid->label, -1, NULL))
113
label = g_strdup(vid->label);
115
if (g_utf8_validate(label, -1, NULL))
116
volume_label = g_strdup(label);
114
117
else /* assume ISO8859-1 */
115
label = g_convert(vid->label, -1, "UTF-8", "ISO8859-1", NULL, NULL, NULL);
118
volume_label = g_convert(label, -1, "UTF-8", "ISO8859-1", NULL, NULL, NULL);
385
393
if (! has_children && ! (is_cdrom && ! has_data))
387
vid = volume_id_open_fd(fd);
390
if (volume_id_probe_all(vid, 0, media_size) == 0)
394
volume_id_close(vid);
395
pr = blkid_new_probe ();
400
blkid_probe_set_request (pr, BLKID_PROBREQ_LABEL | BLKID_PROBREQ_UUID |
401
BLKID_PROBREQ_TYPE | BLKID_PROBREQ_SECTYPE |
402
BLKID_PROBREQ_USAGE | BLKID_PROBREQ_VERSION);
404
bid_ret = blkid_probe_set_device (pr, fd, 0, media_size);
407
bid_ret = blkid_do_safeprobe (pr);
408
hfp_warning ("blkid_do_safeprobe returned an error");
400
415
if (! has_children && ! is_swap && ! has_audio && ! has_data && ! is_blank)
403
418
libhal_device_add_capability(hfp_ctx, hfp_udi, "volume", &hfp_error);
507
522
hfp_cdrom_free(cdrom);
510
if (has_data && vid && (! strcmp(vid->type, "iso9660") ||
511
! strcmp(vid->type, "udf")))
512
hf_probe_volume_advanced_disc_detect(fd);
525
if (has_data && pr) {
526
const char *cdrom_fstype;
527
if (! blkid_probe_lookup_value(pr, "TYPE", &cdrom_fstype, NULL) &&
528
(! strcmp(cdrom_fstype, "iso9660") || ! strcmp(cdrom_fstype, "udf"))) {
529
hf_probe_volume_advanced_disc_detect(fd);
600
621
ufs_disk_close(&ufsdisk);
624
#endif /* HAVE_LIBUFS */
604
626
if (has_children)
605
627
usage = "partitiontable";
606
628
else if (is_swap)
609
switch (vid ? vid->usage_id : (enum volume_id_usage) -1)
611
case VOLUME_ID_FILESYSTEM: usage = "filesystem"; break;
612
case VOLUME_ID_DISKLABEL: usage = "disklabel"; break;
613
case VOLUME_ID_OTHER: usage = "other"; break;
614
case VOLUME_ID_RAID: usage = "raid"; break;
615
case VOLUME_ID_CRYPTO: usage = "crypto"; break;
616
case VOLUME_ID_UNUSED: usage = "unused"; break;
617
default: usage = "unknown"; break;
630
else if (blkid_probe_lookup_value(pr, "USAGE", &usage, NULL))
620
632
libhal_device_set_property_string(hfp_ctx, hfp_udi, "volume.fsusage", usage, &hfp_error);
621
libhal_device_set_property_string(hfp_ctx, hfp_udi, "volume.fstype", vid ? vid->type: "", &hfp_error);
622
if (vid && *vid->type_version)
623
libhal_device_set_property_string(hfp_ctx, hfp_udi, "volume.fsversion", vid->type_version, &hfp_error);
625
label = hf_probe_volume_get_label(vid);
634
if (blkid_probe_lookup_value(pr, "TYPE", &type, NULL))
636
libhal_device_set_property_string(hfp_ctx, hfp_udi, "volume.fstype", type, &hfp_error);
637
if (blkid_probe_lookup_value(pr, "VERSION", &type, NULL))
639
libhal_device_set_property_string(hfp_ctx, hfp_udi, "volume.fsversion", type_version, &hfp_error);
641
label = hf_probe_volume_get_label(pr);
626
642
libhal_device_set_property_string(hfp_ctx, hfp_udi, "volume.label", label ? label : "", &hfp_error);
629
libhal_device_set_property_string(hfp_ctx, hfp_udi, "volume.uuid", vid ? vid->uuid : "", &hfp_error);
645
if (blkid_probe_lookup_value(pr, "UUID", &uuid, NULL))
647
libhal_device_set_property_string(hfp_ctx, hfp_udi, "volume.uuid", uuid, &hfp_error);
631
649
ioctl(fd, DIOCGSECTORSIZE, §or_size);