fdisk-util: add fdisk_partition_get_type_as_id128() helper

Let's also add an easy accessor for the other per-partition UUID.
This commit is contained in:
Lennart Poettering
2022-11-29 12:07:15 +01:00
parent 02e32aa629
commit 63b96eb9b3
4 changed files with 25 additions and 24 deletions
+18
View File
@@ -39,4 +39,22 @@ int fdisk_partition_get_uuid_as_id128(struct fdisk_partition *p, sd_id128_t *ret
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
+1
View File
@@ -17,5 +17,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);
int fdisk_partition_get_type_as_id128(struct fdisk_partition *p, sd_id128_t *ret);
#endif