Lines Matching defs:id
37 #include "machine-id-setup.h"
76 static int read_machine_id(int fd, char id[34]) {
81 assert(id);
98 memcpy(id, id_to_validate, 32);
99 id[32] = '\n';
100 id[33] = 0;
104 static int write_machine_id(int fd, char id[34]) {
106 assert(id);
111 return loop_write(fd, id, 33, false);
114 static int generate_machine_id(char id[34], const char *root) {
121 assert(id);
124 dbus_machine_id = "/var/lib/dbus/machine-id";
126 dbus_machine_id = strjoina(root, "/var/lib/dbus/machine-id");
128 /* First, try reading the D-Bus machine id, unless it is a symlink */
131 r = read_machine_id(fd, id);
150 r = shorten_uuid(id, e);
165 fd = open("/sys/class/dmi/id/product_uuid", O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW);
171 r = shorten_uuid(id, uuid);
181 /* If that didn't work, generate a random machine id */
186 for (p = buf.bytes, q = id; p < buf.bytes + sizeof(buf); p++, q += 2) {
191 id[32] = '\n';
192 id[33] = 0;
203 char id[34]; /* 32 + \n + \0 */
207 etc_machine_id = "/etc/machine-id";
208 run_machine_id = "/run/machine-id";
212 x = strjoina(root, "/etc/machine-id");
215 x = strjoina(root, "/run/machine-id");
234 "System cannot boot: Missing /etc/machine-id and /etc is mounted read-only.\n"
236 "1) /etc/machine-id exists and is populated.\n"
237 "2) /etc/machine-id exists and is empty.\n"
238 "3) /etc/machine-id is missing and /etc is writable.\n");
249 /* A machine id argument overrides all other machined-ids */
251 sd_id128_to_string(machine_id, id);
252 id[32] = '\n';
253 id[33] = 0;
255 if (read_machine_id(fd, id) >= 0)
258 /* Hmm, so, the id currently stored is not useful, then let's
261 r = generate_machine_id(id, root);
267 if (write_machine_id(fd, id) >= 0)
273 * /run/machine-id as a replacement */
276 r = write_string_file(run_machine_id, id, WRITE_STRING_FILE_CREATE);
301 char id[34]; /* 32 + \n + \0 */
305 etc_machine_id = "/etc/machine-id";
309 x = strjoina(root, "/etc/machine-id");
321 /* Read existing machine-id */
326 r = read_machine_id(fd, id);
358 return log_error_errno(errno, "Cannot open for writing %s. This is mandatory to get a persistent machine-id: %m", etc_machine_id);
360 r = write_machine_id(fd, id);