#include <unistd.h>
#include "fd-util.h"
+#include "fs-util.h"
#include "hexdecoct.h"
#include "id128-util.h"
#include "io-util.h"
return r == -EINVAL ? -EUCLEAN : r;
}
-int id128_read(const char *path, Id128Flag f, sd_id128_t *ret) {
+int id128_read_at(int dir_fd, const char *path, Id128Flag f, sd_id128_t *ret) {
_cleanup_close_ int fd = -EBADF;
+ assert(dir_fd >= 0 || dir_fd == AT_FDCWD);
assert(path);
- fd = open(path, O_RDONLY|O_CLOEXEC|O_NOCTTY);
+ fd = xopenat(dir_fd, path, O_RDONLY|O_CLOEXEC|O_NOCTTY, 0);
if (fd < 0)
- return -errno;
+ return fd;
return id128_read_fd(fd, f, ret);
}