X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;ds=sidebyside;f=extras%2Fvolume_id%2Fudev_volume_id.c;h=d3c3fcd505dab49a01a1fc47d967522d0bbcea66;hb=bce52be81ec679bf080bb11f292c899d9fde084e;hp=7b6985680414837457996c4a298be3a930487c43;hpb=61b24e5e19fb189cfce7ff323c58e1bb1d7cce4d;p=elogind.git diff --git a/extras/volume_id/udev_volume_id.c b/extras/volume_id/udev_volume_id.c index 7b6985680..d3c3fcd50 100644 --- a/extras/volume_id/udev_volume_id.c +++ b/extras/volume_id/udev_volume_id.c @@ -31,8 +31,8 @@ #include "../../libsysfs/sysfs/libsysfs.h" #include "../../udev_utils.h" #include "../../logging.h" -#include "volume_id.h" -#include "dasdlabel.h" +#include "volume_id/volume_id.h" +#include "volume_id/dasd/dasd.h" #define BLKGETSIZE64 _IOR(0x12,114,size_t) @@ -74,26 +74,6 @@ static struct volume_id *open_classdev(struct sysfs_class_device *class_dev) return vid; } -static char *usage_id_name(enum volume_id_usage usage) -{ - switch(usage) { - case VOLUME_ID_UNUSED: - return "unused"; - case VOLUME_ID_UNPROBED: - return "unprobed"; - case VOLUME_ID_OTHER: - return "other"; - case VOLUME_ID_PARTITIONTABLE: - return "partitiontable"; - case VOLUME_ID_FILESYSTEM: - return "filesystem"; - case VOLUME_ID_RAID: - return "raid"; - default: - return "unknown type_id"; - } -} - int main(int argc, char *argv[]) { const char help[] = "usage: udev_volume_id [-t|-l|-u|-d]\n" @@ -109,9 +89,8 @@ int main(int argc, char *argv[]) struct sysfs_class_device *class_dev_parent = NULL; struct volume_id *vid = NULL; char *devpath; - char probe = 'p'; + char probe_disk_label = 0; char print = 'a'; - char dasd_label[7]; static char name[VOLUME_ID_LABEL_SIZE]; int len, i, j; unsigned long long size; @@ -137,7 +116,7 @@ int main(int argc, char *argv[]) print = 'u'; continue; case 'd': - probe = 'd'; + probe_disk_label = 1; continue; case 'h': case '?': @@ -167,9 +146,7 @@ int main(int argc, char *argv[]) goto exit; } - switch(probe) { - case 'p' : - /* open block device */ + if (probe_disk_label == 0) { vid = open_classdev(class_dev); if (vid == NULL) goto exit; @@ -177,10 +154,9 @@ int main(int argc, char *argv[]) if (ioctl(vid->fd, BLKGETSIZE64, &size) != 0) size = 0; - if (volume_id_probe(vid, VOLUME_ID_ALL, 0, size) == 0) + if (volume_id_probe_all(vid, 0, size) == 0) goto print; - break; - case 'd' : + } else { /* if we are on a partition, open main block device instead */ class_dev_parent = sysfs_get_classdev_parent(class_dev); if (class_dev_parent != NULL) @@ -190,13 +166,8 @@ int main(int argc, char *argv[]) if (vid == NULL) goto exit; - if (probe_ibm_partition(vid->fd, dasd_label) == 0) { - vid->type = "dasd"; - strncpy(vid->label, dasd_label, 6); - vid->label[6] = '\0'; + if (volume_id_probe_dasd_partition(vid) == 0) goto print; - } - break; } printf("unknown volume type\n"); @@ -233,7 +204,8 @@ print: printf("%s\n", vid->type); break; case 'l': - if (name[0] == '\0' || vid->usage_id != VOLUME_ID_FILESYSTEM) { + if (name[0] == '\0' || + (vid->usage_id != VOLUME_ID_FILESYSTEM && vid->usage_id != VOLUME_ID_DISKLABEL)) { rc = 2; goto exit; } @@ -247,7 +219,7 @@ print: printf("%s\n", vid->uuid); break; case 'a': - printf("F:%s\n", usage_id_name(vid->usage_id)); + printf("F:%s\n", vid->usage); printf("T:%s\n", vid->type); printf("V:%s\n", vid->type_version); printf("L:%s\n", vid->label);