From: Zbigniew Jędrzejewski-Szmek Date: Fri, 11 Jun 2021 16:17:00 +0000 (+0200) Subject: sd-id128: add SD_ID128_MAKE_UUID_STR X-Git-Tag: v249-rc1~2^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c7683f36ccaf6080fb7cb10b52de4ae2791ea32;p=thirdparty%2Fsystemd.git sd-id128: add SD_ID128_MAKE_UUID_STR It's like SD_ID128_MAKE_STR, but with hyphens. --- diff --git a/man/rules/meson.build b/man/rules/meson.build index 1cfb54723ae..0f6519106a4 100644 --- a/man/rules/meson.build +++ b/man/rules/meson.build @@ -125,6 +125,7 @@ manpages = [ 'SD_ID128_FORMAT_VAL', 'SD_ID128_MAKE', 'SD_ID128_MAKE_STR', + 'SD_ID128_MAKE_UUID_STR', 'SD_ID128_NULL', 'SD_ID128_UUID_FORMAT_STR', 'sd_id128_equal', diff --git a/man/sd-id128.xml b/man/sd-id128.xml index 716c62522dd..891a4585c61 100644 --- a/man/sd-id128.xml +++ b/man/sd-id128.xml @@ -24,6 +24,7 @@ SD_ID128_FORMAT_VAL SD_ID128_MAKE SD_ID128_MAKE_STR + SD_ID128_MAKE_UUID_STR SD_ID128_NULL SD_ID128_UUID_FORMAT_STR sd_id128_equal @@ -121,10 +122,12 @@ int main(int argc, char **argv) { return 0; } - SD_ID128_UUID_FORMAT_STR is similar to - SD_ID128_FORMAT_STR but includes separating hyphens to conform to the "canonical - representation". This formats the string based on SD_ID128_UUID_FORMAT_STR and SD_ID128_MAKE_UUID_STR() + are similar to + SD_ID128_FORMAT_STR and SD_ID128_MAKE_STR(), + but include separating hyphens to conform to the + "canonical representation". + They format the string based on RFC4122 Variant 1 rules, i.e. converting from Big Endian byte order. This matches behaviour of most other Linux userspace infrastructure. It's probably best to avoid UUIDs of other variants, in order to avoid unnecessary ambiguities. All 128-bit IDs diff --git a/src/systemd/sd-id128.h b/src/systemd/sd-id128.h index 90d4bbf14ef..f2dd7357f86 100644 --- a/src/systemd/sd-id128.h +++ b/src/systemd/sd-id128.h @@ -107,6 +107,9 @@ int sd_id128_get_boot_app_specific(sd_id128_t app_id, sd_id128_t *ret); #define SD_ID128_MAKE_STR(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) \ #a #b #c #d #e #f #g #h #i #j #k #l #m #n #o #p +#define SD_ID128_MAKE_UUID_STR(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) \ + #a #b #c #d "-" #e #f "-" #g #h "-" #i #j "-" #k #l #m #n #o #p + _sd_pure_ static __inline__ int sd_id128_equal(sd_id128_t a, sd_id128_t b) { return memcmp(&a, &b, 16) == 0; }