X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=extras%2Fvolume_id%2Flibvolume_id%2Fvolume_id.c;h=1daf1cbd74c4e0685fc4c6eb8e3402ae5fee0556;hp=09d1e317257f66b9bc7291b2ae3f8201feaa3b5a;hb=ab925d69d5d38e851ae3b71523fb70a75f7b16de;hpb=467546b586e9ae29ac168967f5cdaac696cadcfb diff --git a/extras/volume_id/libvolume_id/volume_id.c b/extras/volume_id/libvolume_id/volume_id.c index 09d1e3172..1daf1cbd7 100644 --- a/extras/volume_id/libvolume_id/volume_id.c +++ b/extras/volume_id/libvolume_id/volume_id.c @@ -31,7 +31,7 @@ #include "util.h" -int volume_id_probe_all(struct volume_id *id, uint64_t off, uint64_t size) +int volume_id_probe_raid(struct volume_id *id, uint64_t off, uint64_t size) { if (id == NULL) return -EINVAL; @@ -72,6 +72,17 @@ int volume_id_probe_all(struct volume_id *id, uint64_t off, uint64_t size) if (volume_id_probe_highpoint_37x_raid(id, off) == 0) goto exit; +exit: + /* If recognized, we free the allocated buffers */ + volume_id_free_buffer(id); + return 0; +} + +int volume_id_probe_filesystem(struct volume_id *id, uint64_t off, uint64_t size) +{ + if (id == NULL) + return -EINVAL; + if (volume_id_probe_luks(id, off) == 0) goto exit; @@ -139,13 +150,25 @@ int volume_id_probe_all(struct volume_id *id, uint64_t off, uint64_t size) return -1; exit: - /* If the filestystem in recognized, we free the allocated buffers, - otherwise they will stay in place for the possible next probe call */ + /* If recognized, we free the allocated buffers */ volume_id_free_buffer(id); - return 0; } +int volume_id_probe_all(struct volume_id *id, uint64_t off, uint64_t size) +{ + if (id == NULL) + return -EINVAL; + + if (volume_id_probe_raid(id, off, size) == 0) + return 0; + + if (volume_id_probe_filesystem(id, off, size) == 0) + return 0; + + return -1; +} + /* open volume by already open file descriptor */ struct volume_id *volume_id_open_fd(int fd) {