fdisk-util: add fdisk_partition_get_uuid_as_id128() helper
Inspired by: #25534
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user