| 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | #ifndef V_ALPM_NATIVE_ROOTFS_H |
| 3 | #define V_ALPM_NATIVE_ROOTFS_H |
| 4 | #include <stdint.h> |
| 5 | #include <fcntl.h> |
| 6 | #include <sys/stat.h> |
| 7 | |
| 8 | typedef struct v_alpm_root_info { |
| 9 | uint32_t mode; |
| 10 | int64_t size; |
| 11 | uint64_t device; |
| 12 | uint64_t inode; |
| 13 | uint64_t links; |
| 14 | } v_alpm_root_info; |
| 15 | |
| 16 | static int v_alpm_root_stat(int directory, const char *name, v_alpm_root_info *result) { |
| 17 | struct stat info; |
| 18 | if(fstatat(directory, name, &info, AT_SYMLINK_NOFOLLOW) != 0) { return -1; } |
| 19 | result->mode = info.st_mode; |
| 20 | result->size = info.st_size; |
| 21 | result->device = info.st_dev; |
| 22 | result->inode = info.st_ino; |
| 23 | result->links = info.st_nlink; |
| 24 | return 0; |
| 25 | } |
| 26 | static int v_alpm_root_duplicate(int fd) { return fcntl(fd, F_DUPFD_CLOEXEC, 0); } |
| 27 | #endif |
| 28 | |