sd128: export sd_id128_to_uuid_string()
We expose various other forms of UUID helpers already, i.e. SD_ID128_UUID_FORMAT_STR and SD_ID128_MAKE_UUID_STR(), and we parse UUIDs, hence add a high-level helper for formatting UUIDs too. This doesn't add any new code, it just moves some helpers id128-util.[ch] → sd-id128.[ch], to make them public.
This commit is contained in:
@@ -1699,11 +1699,11 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
|
||||
case TABLE_UUID: {
|
||||
char *p;
|
||||
|
||||
p = new(char, ID128_UUID_STRING_MAX);
|
||||
p = new(char, SD_ID128_UUID_STRING_MAX);
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
d->formatted = id128_to_uuid_string(d->id128, p);
|
||||
d->formatted = sd_id128_to_uuid_string(d->id128, p);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2562,7 +2562,7 @@ static int table_data_to_json(TableData *d, JsonVariant **ret) {
|
||||
return json_variant_new_string(ret, SD_ID128_TO_STRING(d->id128));
|
||||
|
||||
case TABLE_UUID:
|
||||
return json_variant_new_string(ret, ID128_TO_UUID_STRING(d->id128));
|
||||
return json_variant_new_string(ret, SD_ID128_TO_UUID_STRING(d->id128));
|
||||
|
||||
case TABLE_UID:
|
||||
if (!uid_is_valid(d->uid))
|
||||
|
||||
+2
-2
@@ -75,7 +75,7 @@ const char *gpt_partition_type_uuid_to_string(sd_id128_t id) {
|
||||
|
||||
const char *gpt_partition_type_uuid_to_string_harder(
|
||||
sd_id128_t id,
|
||||
char buffer[static ID128_UUID_STRING_MAX]) {
|
||||
char buffer[static SD_ID128_UUID_STRING_MAX]) {
|
||||
|
||||
const char *s;
|
||||
|
||||
@@ -85,7 +85,7 @@ const char *gpt_partition_type_uuid_to_string_harder(
|
||||
if (s)
|
||||
return s;
|
||||
|
||||
return id128_to_uuid_string(id, buffer);
|
||||
return sd_id128_to_uuid_string(id, buffer);
|
||||
}
|
||||
|
||||
int gpt_partition_type_uuid_from_string(const char *s, sd_id128_t *ret) {
|
||||
|
||||
+1
-1
@@ -286,7 +286,7 @@
|
||||
const char *gpt_partition_type_uuid_to_string(sd_id128_t id);
|
||||
const char *gpt_partition_type_uuid_to_string_harder(
|
||||
sd_id128_t id,
|
||||
char buffer[static ID128_UUID_STRING_MAX]);
|
||||
char buffer[static SD_ID128_UUID_STRING_MAX]);
|
||||
int gpt_partition_type_uuid_from_string(const char *s, sd_id128_t *ret);
|
||||
|
||||
Architecture gpt_partition_type_uuid_to_arch(sd_id128_t id);
|
||||
|
||||
@@ -1510,7 +1510,7 @@ int add_matches_for_user_unit(sd_journal *j, const char *unit, uid_t uid) {
|
||||
static int get_boot_id_for_machine(const char *machine, sd_id128_t *boot_id) {
|
||||
_cleanup_close_pair_ int pair[2] = { -1, -1 };
|
||||
_cleanup_close_ int pidnsfd = -1, mntnsfd = -1, rootfd = -1;
|
||||
char buf[ID128_UUID_STRING_MAX];
|
||||
char buf[SD_ID128_UUID_STRING_MAX];
|
||||
pid_t pid, child;
|
||||
ssize_t k;
|
||||
int r;
|
||||
|
||||
@@ -94,7 +94,7 @@ int make_filesystem(
|
||||
bool discard) {
|
||||
|
||||
_cleanup_free_ char *mkfs = NULL, *mangled_label = NULL;
|
||||
char vol_id[CONST_MAX(ID128_UUID_STRING_MAX, 8 + 1)] = {};
|
||||
char vol_id[CONST_MAX(SD_ID128_UUID_STRING_MAX, 8U + 1U)] = {};
|
||||
int r;
|
||||
|
||||
assert(node);
|
||||
@@ -144,7 +144,7 @@ int make_filesystem(
|
||||
}
|
||||
|
||||
if (isempty(vol_id))
|
||||
id128_to_uuid_string(uuid, vol_id);
|
||||
assert_se(sd_id128_to_uuid_string(uuid, vol_id));
|
||||
|
||||
r = safe_fork("(mkfs)", FORK_RESET_SIGNALS|FORK_RLIMIT_NOFILE_SAFE|FORK_DEATHSIG|FORK_LOG|FORK_WAIT|FORK_STDOUT_TO_STDERR, NULL);
|
||||
if (r < 0)
|
||||
|
||||
@@ -351,7 +351,7 @@ void log_device_uevent(sd_device *device, const char *str) {
|
||||
strempty(str), isempty(str) ? "" : " ",
|
||||
seqnum, strna(device_action_to_string(action)),
|
||||
sd_id128_is_null(event_id) ? "" : ", UUID=",
|
||||
sd_id128_is_null(event_id) ? "" : id128_to_uuid_string(event_id, (char[ID128_UUID_STRING_MAX]){}));
|
||||
sd_id128_is_null(event_id) ? "" : SD_ID128_TO_UUID_STRING(event_id));
|
||||
}
|
||||
|
||||
int udev_rule_parse_value(char *str, char **ret_value, char **ret_endpos) {
|
||||
|
||||
Reference in New Issue
Block a user