Implemented size measures
This commit is contained in:
parent
ee79d7c87d
commit
ecb9a595ca
19
src/entry.c
19
src/entry.c
@ -8,6 +8,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/statvfs.h>
|
||||||
|
|
||||||
char* get_entries_path(void) {
|
char* get_entries_path(void) {
|
||||||
return format("%s/%s", MASTER_DIRECTORY, ENTRIES_DIRECTORY);
|
return format("%s/%s", MASTER_DIRECTORY, ENTRIES_DIRECTORY);
|
||||||
@ -68,3 +69,21 @@ bool entry_exists(const char* entry) {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t get_available_space(void) {
|
||||||
|
char* entries_path = get_entries_path();
|
||||||
|
if (entries_path == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
// Get the available space in the entries directory
|
||||||
|
struct statvfs statbuf;
|
||||||
|
int result = statvfs(entries_path, &statbuf);
|
||||||
|
|
||||||
|
// Free the entries path
|
||||||
|
free(entries_path);
|
||||||
|
|
||||||
|
if (result != 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return statbuf.f_bsize * statbuf.f_bavail;
|
||||||
|
}
|
||||||
|
@ -12,4 +12,5 @@
|
|||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
|
log_msg(LOG_INFO, "Available space : %lld", get_available_space());
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user