From: Lennart Poettering Date: Fri, 6 Jul 2012 15:50:00 +0000 (+0200) Subject: man: document libsystemd-id128 X-Git-Tag: v187~161 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=12355095821fc17529af5b6eaefa31c3c520be39 man: document libsystemd-id128 --- diff --git a/Makefile.am b/Makefile.am index 3b7ec0b7b..540eb80f1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -501,7 +501,10 @@ MANPAGES = \ man/systemd-getty-generator.8 \ man/systemd-system-update-generator.8 \ man/systemd-fstab-generator.8 \ - man/systemd.preset.5 + man/systemd.preset.5 \ + man/sd-id128.7 \ + man/sd_id128_to_string.3 \ + man/sd_id128_randomize.3 MANPAGES_ALIAS = \ man/reboot.8 \ @@ -530,7 +533,15 @@ MANPAGES_ALIAS = \ man/systemd-ask-password-wall.path.8 \ man/systemd-tmpfiles-setup.service.8 \ man/systemd-tmpfiles-clean.service.8 \ - man/systemd-tmpfiles-clean.timer.8 + man/systemd-tmpfiles-clean.timer.8 \ + man/sd_id128_t.7 \ + man/SD_ID128_MAKE.7 \ + man/SD_ID128_FORMAT_STR.7 \ + man/SD_ID128_FORMAT_VAL.7 \ + man/sd_id128_equal.7 \ + man/sd_id128_from_string.3 \ + man/sd_id128_get_machine.3 \ + man/sd_id128_get_boot.3 man/reboot.8: man/halt.8 man/poweroff.8: man/halt.8 @@ -559,6 +570,14 @@ man/systemd-ask-password-wall.path.8: man/systemd-ask-password-console.service.8 man/systemd-tmpfiles-setup.service.8: man/systemd-tmpfiles.8 man/systemd-tmpfiles-clean.service.8: man/systemd-tmpfiles.8 man/systemd-tmpfiles-clean.timer.8: man/systemd-tmpfiles.8 +man/sd_id128_t.7: man/sd-id128.7 +man/SD_ID128_MAKE.7: man/sd-id128.7 +man/SD_ID128_FORMAT_STR.7: man/sd-id128.7 +man/SD_ID128_FORMAT_VAL.7: man/sd-id128.7 +man/sd_id128_equal.7: man/sd-id128.7 +man/sd_id128_from_string.3: man/sd_id128_to_string.3 +man/sd_id128_get_machine.3: man/sd_id128_randomize.3 +man/sd_id128_get_boot.3: man/sd_id128_randomize.3 XML_FILES = \ ${patsubst %.1,%.xml,${patsubst %.3,%.xml,${patsubst %.5,%.xml,${patsubst %.7,%.xml,${patsubst %.8,%.xml,$(MANPAGES)}}}}} diff --git a/TODO b/TODO index 5748289c4..5efd11b2e 100644 --- a/TODO +++ b/TODO @@ -22,6 +22,10 @@ Bugfixes: Features: +* journalctl highlight reboots + +* Merge KillUnit()'s mode and who params into one + * load-fragment: when loading a unit file via a chain of symlinks verify that it isn't masked via any of the names traversed. diff --git a/man/machine-id.xml b/man/machine-id.xml index 73f0926c0..a42c7bb5a 100644 --- a/man/machine-id.xml +++ b/man/machine-id.xml @@ -136,7 +136,9 @@ id[8] = (id[8] & 0x3F) | 0x80; gethostid3, hostname5, machine-info5, - os-release5 + os-release5, + sd-id1287, + sd_id128_get_machine3 diff --git a/man/sd-id128.xml b/man/sd-id128.xml new file mode 100644 index 000000000..cbc130d75 --- /dev/null +++ b/man/sd-id128.xml @@ -0,0 +1,168 @@ + + + + + + + + + sd-id128 + systemd + + + + Developer + Lennart + Poettering + lennart@poettering.net + + + + + + sd-id128 + 7 + + + + sd-id128 + sd_id128_t + SD_ID128_MAKE + SD_ID128_FORMAT_STR + SD_ID128_FORMAT_VAL + sd_id128_equal + APIs for processing 128 bit IDs + + + + + #include <systemd/sd-id128.h> + + + + pkg-config --cflags --libs libsystemd-id128 + + + + + + Description + + sd-id128.h provides APIs to + process and generate 128 bit ID values. The 128 bit ID + values processed and generated by these APIs are a + generalization of OSF UUIDs as defined by RFC + 4122, though use a simpler string + formatting. These functions impose no structure on the + used IDs, much unlike OSF UUIDs or Microsoft GUIDs, + but are fully compatible with those types of IDs. + + + See + sd_id128_to_string3 and + sd_id128_randomize3 + for more information about the functions + implemented. + + A 128 bit ID is implemented as the following + union type: + + typedef union sd_id128 { + uint8_t bytes[16]; + uint64_t qwords[2]; +} sd_id128_t; + + This union type allows accessing the 128 bit ID + as 16 separate bytes or 2 64 bit words. It is generally + safer to access the ID components by their 8 bit array + to avoid endianess issues. This union is intended to + be passed call-by-value (as opposed to + call-by-reference) and may be directly manipulated by + clients. + + A couple of macros are defined to denote and + decode 128 bit IDs: + + SD_ID128_MAKE() may be used + to write a 128 bit ID in source code. A commonly used + idiom is to give 128 bit IDs names using this macro: + + #define SD_MESSAGE_COREDUMP SD_ID128_MAKE(fc,2e,22,bc,6e,e6,47,b6,b9,07,29,ab,34,a2,50,b1) + + SD_ID128_FORMAT_STR and + SD_ID128_FORMAT_VAL() may be used + to format a 128 bit ID in a + printf3 + format string, as shown in the following + example: + + int main(int argc, char *argv[]) { + sd_id128_t id; + id = SD_ID128_MAKE(ee,89,be,71,bd,6e,43,d6,91,e6,c5,5d,eb,03,02,07); + printf("The ID encoded in this C file is " SD_ID128_FORMAT_STR ".\n", SD_ID128_FORMAT_VAL(id)); + return 0; +} + + Use sd_id128_equal() to compare two 128 bit IDs: + + int main(int argc, char *argv[]) { + sd_id128_t a, b, c; + a = SD_ID128_MAKE(ee,89,be,71,bd,6e,43,d6,91,e6,c5,5d,eb,03,02,07); + b = SD_ID128_MAKE(f2,28,88,9c,5f,09,44,15,9d,d7,04,77,58,cb,e7,3e); + c = a; + assert(sd_id128_equal(a, c)); + assert(!sd_id128_equal(a, b)); + return 0; +} + + Note that new, randomized IDs may be generated + with + journalctl1's + --new-id command. + + + + Notes + + These APIs are implemented as shared library, + which can be compiled and linked to with the + libsystemd-id128 + pkg-config1 + file. + + + + + See Also + + systemd1, + sd_id128_to_string3, + sd_id128_randomize3, + printf3, + journalctl1, + sd-journal7, + pkg-config1, + machine-id5 + + + + diff --git a/man/sd_id128_randomize.xml b/man/sd_id128_randomize.xml new file mode 100644 index 000000000..499c55fb6 --- /dev/null +++ b/man/sd_id128_randomize.xml @@ -0,0 +1,157 @@ + + + + + + + + + sd_id128_randomize + systemd + + + + Developer + Lennart + Poettering + lennart@poettering.net + + + + + + sd_id128_randomize + 3 + + + + sd_id128_randomize + sd_id128_get_machine + sd_id128_get_boot + Generate or retrieve 128 bit IDs + + + + + #include <systemd/sd-id128.h> + + + int sd_id128_randomize + sd_id128_t* ret + + + + int sd_id128_get_machine + sd_id128_t* ret + + + + int sd_id128_get_boot + sd_id128_t* ret + + + + + + + Description + + sd_id128_randomize() + generates a new randomized 128 bit ID and returns it + in ret. Every invocation + returns a new randomly generated ID. This uses the + /dev/urandom kernel random number + generator. + + sd_id128_get_machine() + returns the machine ID of the executing host. This + reads and parses the + machine-id5 + file. This function caches the machine ID internally + to make retrieving the machine ID a cheap + operation. + + sd_id128_get_boot() returns + the boot ID of the executing kernel. This reads and + parses the + /proc/sys/kernel/random/boot_id + file exposed by the kernel. It is randomly generated + early at boot and is unique for every running kernel + instance. See + random4 + for more information. This function also internally + caches the returned ID to make this call a cheap + operation. + + Note that + sd_id128_randomize() and + sd_id128_get_boot() always return + a UUID v4 compatible + ID. sd_id128_get_machine() will + also return a UUID v4 compatible ID on new + installations, but might not on older. It is possible + to convert the machine ID into an UUID v4 compatible + one. For more information see + machine-id5. + + For more information about the + sd_id128_t type see + sd-id1287. + + journalctl1's + --new-id command may be used as + command line front-end for + sd_id128_randomize(). + + + + Return Value + + The three calls returns 0 on success (in which + case ret is filled in), or a + negative errno-style error code. + + + + Notes + + The sd_id128_randomize(), + sd_id128_get_machine() and + sd_id128_get_boot() interfaces + are available as shared library, which can be compiled + and linked to with the + libsystemd-id128 + pkg-config1 + file. + + + + See Also + + + systemd1, + sd-id1287, + machine-id5, + random4 + + + + diff --git a/man/sd_id128_to_string.xml b/man/sd_id128_to_string.xml new file mode 100644 index 000000000..3a171550e --- /dev/null +++ b/man/sd_id128_to_string.xml @@ -0,0 +1,131 @@ + + + + + + + + + sd_id128_to_string + systemd + + + + Developer + Lennart + Poettering + lennart@poettering.net + + + + + + sd_id128_to_string + 3 + + + + sd_id128_to_string + sd_id128_from_string + Format or parse 128 bit IDs as strings + + + + + #include <systemd/sd-id128.h> + + + char* sd_id128_to_string + sd_id128_t id, char s[33] + + + + int sd_id128_from_string + const char s[33], sd_id128_t* ret + + + + + + + Description + + sd_id128_to_string() + formats a 128 bit ID as character string. It expects + the ID and a string array capable of storing 33 + characters. The ID will be formatted as 32 lowercase + hexadecimal digits and be terminated by a NUL + byte. + + sd_id128_from_string() + implements the reverse operation: it takes a 33 + character array with 32 hexadecimial digits + (terminated by NUL) and parses them back into an + 128 bit ID returned in + ret. + + For more information about the + sd_id128_t type see + sd-id1287. + + When formatting a 128 bit ID into a string it is + often easier to use a format string for + printf3. This + is easly done using the + SD_ID128_FORMAT_STR and + SD_ID128_FORMAT_VAL() macros. For + more information see + sd-id1287. + + + + Return Value + + sd_id128_to_string() always + succeeds and returns a pointer to the string array + passed in. sd_id128_from_string + returns 0 on success (in which case + ret is filled in), or a negative + errno-style error code. + + + + Notes + + The sd_id128_to_string() + and sd_id128_from_string() interfaces are + available as shared library, which can be compiled and + linked to with the libsystemd-id128 + pkg-config1 + file. + + + + See Also + + + systemd1, + sd-id1287, + printf3 + + + +