Implemented the creation of backing disks

This commit is contained in:
2024-02-15 13:06:21 +01:00
parent f64f39c9c8
commit e6bc757343
6 changed files with 130 additions and 5 deletions

View File

@@ -237,3 +237,20 @@ uint64_t get_available_space(void) {
return statbuf.f_bsize * statbuf.f_bavail;
}
bool reserve_space(uint64_t space) {
// While the available space is not enough, delete the oldest entry
while (get_available_space() < space) {
char* oldest_entry = find_oldest_entry();
if (oldest_entry == NULL)
return false;
bool result = delete_entry(oldest_entry);
free(oldest_entry);
if (!result)
return false;
}
return true;
}