nspkg / engine / native_space.h
21 lines · 21 sloc · 646 bytes · c01b0795d1db56c7bce2539b2c46b110637fdc1a
Raw
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2#ifndef V_ALPM_NATIVE_SPACE_H
3#define V_ALPM_NATIVE_SPACE_H
4#include <stdint.h>
5#include <sys/statvfs.h>
6typedef struct v_alpm_space_info {
7 uint64_t block_size;
8 uint64_t blocks;
9 uint64_t available;
10 uint32_t read_only;
11} v_alpm_space_info;
12static int v_alpm_space_stat(const char *path, v_alpm_space_info *result) {
13 struct statvfs info;
14 if(statvfs(path, &info) != 0) { return -1; }
15 result->block_size = info.f_bsize;
16 result->blocks = info.f_blocks;
17 result->available = info.f_bavail;
18 result->read_only = (info.f_flag & ST_RDONLY) != 0;
19 return 0;
20}
21#endif
22