diff --git a/src/entry.c b/src/entry.c index 3b49cde..0c20bbf 100644 --- a/src/entry.c +++ b/src/entry.c @@ -8,6 +8,7 @@ #include #include #include +#include char* get_entries_path(void) { return format("%s/%s", MASTER_DIRECTORY, ENTRIES_DIRECTORY); @@ -68,3 +69,21 @@ bool entry_exists(const char* entry) { 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; +} diff --git a/src/sandbox.c b/src/sandbox.c index c82bea0..027de13 100644 --- a/src/sandbox.c +++ b/src/sandbox.c @@ -12,4 +12,5 @@ #include int main(int argc, char* argv[]) { + log_msg(LOG_INFO, "Available space : %lld", get_available_space()); } \ No newline at end of file