Reintroduce a workaround for docker on macOS accidentally removed in bd266d6589

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2024-03-30 20:14:15 +01:00
parent f7cd4fb406
commit 27ff979ef8
No known key found for this signature in database
GPG Key ID: 00135ACBD90B28DD
1 changed files with 5 additions and 4 deletions

View File

@ -269,11 +269,12 @@ unsigned int get_path_usage(const char *path, char buffer[64])
// If size is 0, we return 0% to avoid division by zero below
if(size == 0)
return 0;
// If used is larger than size, we return 100%
if(used > size)
return 100;
// Return percentage of used memory at this path (rounded down)
return (used*100)/(size + 1);
// If the used size is larger than the total size, this intentionally
// returns more than 100% so that the caller can handle this case
// (this can happen with docker on macOS)
return (used * 100) / size;
}
// Get the filesystem where the given path is located