return RET_NERRNO(ioctl(fd, FS_IOC_GETFLAGS, ret));
}
-int read_attr_path(const char *p, unsigned *ret) {
+int read_attr_at(int dir_fd, const char *path, unsigned *ret) {
_cleanup_close_ int fd = -EBADF;
- assert(p);
+ assert(dir_fd >= 0 || dir_fd == AT_FDCWD);
assert(ret);
- fd = open(p, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW);
+ fd = xopenat(dir_fd, path, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW);
if (fd < 0)
- return -errno;
+ return fd;
return read_attr_fd(fd, ret);
}
}
int read_attr_fd(int fd, unsigned *ret);
-int read_attr_path(const char *p, unsigned *ret);
+int read_attr_at(int dir_fd, const char *path, unsigned *ret);
/* Combination of chattr flags, that should be appropriate for secrets stored on disk: Secure Remove +
* Exclusion from Dumping + Synchronous Writing (i.e. not caching in memory) + In-Place Updating (i.e. not
case IMAGE_DIRECTORY:
/* Turn of the immutable bit while we rename the image, so that we can rename it */
- (void) read_attr_path(i->path, &file_attr);
+ (void) read_attr_at(AT_FDCWD, i->path, &file_attr);
if (file_attr & FS_IMMUTABLE_FL)
(void) chattr_path(i->path, 0, FS_IMMUTABLE_FL, NULL);