assert(ret);
- if (root) {
- _cleanup_close_ int fd = -EBADF;
-
- fd = chase_and_open("/etc/machine-id", root, CHASE_PREFIX_ROOT, O_RDONLY|O_CLOEXEC|O_NOCTTY, NULL);
- if (fd < 0)
- /* Translate error for missing os-release file to EUNATCH. */
- return fd == -ENOENT ? -EUNATCH : fd;
-
- r = id128_read_fd(fd, ID128_FORMAT_PLAIN, &id);
- } else
- r = sd_id128_get_machine(&id);
- if (r < 0)
- return r;
+ r = id128_get_machine(root, &id);
+ if (r < 0) /* Translate error for missing /etc/machine-id file to EUNATCH. */
+ return r == -ENOENT ? -EUNATCH : r;
return specifier_id128(specifier, &id, root, userdata, ret);
}
xsprintf(spec, "%%%c", s->specifier);
r = specifier_printf(spec, SIZE_MAX, specifier_table, NULL, NULL, &resolved);
- if (s->specifier == 'm' && IN_SET(r, -ENOENT, -ENOMEDIUM)) /* machine-id might be missing in build chroots */
+ if (s->specifier == 'm' && IN_SET(r, -EUNATCH, -ENOMEDIUM)) /* machine-id might be missing in build chroots */
continue;
assert_se(r >= 0);