Merge pull request #25558 from poettering/fdisk-id128
add generic uuid/id128 helpers for libfdisk too
This commit is contained in:
@@ -26,4 +26,35 @@ 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);
|
||||
}
|
||||
|
||||
int fdisk_partition_get_type_as_id128(struct fdisk_partition *p, sd_id128_t *ret) {
|
||||
struct fdisk_parttype *pt;
|
||||
const char *pts;
|
||||
|
||||
assert(p);
|
||||
assert(ret);
|
||||
|
||||
pt = fdisk_partition_get_type(p);
|
||||
if (!pt)
|
||||
return -ENXIO;
|
||||
|
||||
pts = fdisk_parttype_get_string(pt);
|
||||
if (!pts)
|
||||
return -ENXIO;
|
||||
|
||||
return sd_id128_from_string(pts, 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,7 @@ 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);
|
||||
int fdisk_partition_get_type_as_id128(struct fdisk_partition *p, sd_id128_t *ret);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user