fdisk-util: add fdisk_partition_get_uuid_as_id128() helper

Inspired by: #25534
This commit is contained in:
Lennart Poettering
2022-11-29 12:07:15 +01:00
parent 0ccfd3564b
commit 02e32aa629
4 changed files with 23 additions and 14 deletions
+13
View File
@@ -26,4 +26,17 @@ int fdisk_new_context_fd(int fd, bool read_only, struct fdisk_context **ret) {
return 0;
}
int fdisk_partition_get_uuid_as_id128(struct fdisk_partition *p, sd_id128_t *ret) {
const char *ids;
assert(p);
assert(ret);
ids = fdisk_partition_get_uuid(p);
if (!ids)
return -ENXIO;
return sd_id128_from_string(ids, ret);
}
#endif
+4
View File
@@ -5,6 +5,8 @@
#include <libfdisk.h>
#include "sd-id128.h"
#include "macro.h"
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_context*, fdisk_unref_context, NULL);
@@ -14,4 +16,6 @@ DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_table*, fdisk_unref_table, NULL);
int fdisk_new_context_fd(int fd, bool read_only, struct fdisk_context **ret);
int fdisk_partition_get_uuid_as_id128(struct fdisk_partition *p, sd_id128_t *ret);
#endif