Implemented the creation of backing disks
This commit is contained in:
17
src/entry.c
17
src/entry.c
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user