Skip to content
Snippets Groups Projects
Commit 2a23b2e8 authored by Arie Peterson's avatar Arie Peterson
Browse files

Remove debugging flag from filesystem_fits_in_memory

parent 240c878a
No related branches found
No related tags found
No related merge requests found
......@@ -38,7 +38,7 @@ int callback_encryption_get(const struct _u_request * request,
"mounting root device failed");
}
bool fits = filesystem_fits_in_memory(UNENCRYPTED_MOUNTPOINT,
MEMORY_USAGE, true);
MEMORY_USAGE);
umount(UNENCRYPTED_MOUNTPOINT);
if (! fits)
{
......
......@@ -64,7 +64,7 @@ int callback_encryption_init_post(const struct _u_request * request,
// Determine the filesystem usage of the device to be encrypted.
bool fits = filesystem_fits_in_memory(UNENCRYPTED_MOUNTPOINT,
MEMORY_USAGE, true);
MEMORY_USAGE);
if (! fits)
{
// Projected memory usage is really high, so abort.
......
......@@ -116,11 +116,9 @@ unsigned long filesystem_usage(const char * path)
* @param path Path of the mounted filesystem.
* @param safety_margin Fraction (between zero and one) of free memory to
deem available for containing the files.
* @param debug Whether to print debug messages.
* @return Whether the filesystem seems to fit into memory.
*/
bool filesystem_fits_in_memory(const char * path, double safety_margin,
bool debug)
bool filesystem_fits_in_memory(const char * path, double safety_margin)
{
// Determine the filesystem usage of the device to be encrypted.
unsigned long size = filesystem_usage(path);
......@@ -128,25 +126,16 @@ bool filesystem_fits_in_memory(const char * path, double safety_margin,
{
// Something went wrong in determining the filesystem usage.
// Return false as a precaution.
if (debug)
{
printf("Determining file system usage failed (size: %lu)\n", size);
}
printf("Determining file system usage failed (size: %lu)\n", size);
return false;
}
if (debug)
{
printf("file system usage: %lu bytes\n", size);
}
printf("file system usage: %lu bytes\n", size);
// Determine the available memory.
unsigned long memory = available_memory();
double projected_usage = (double)size / (double)memory;
if (debug)
{
printf("projected memory usage: %.3f\n", projected_usage);
}
printf("projected memory usage: %.3f\n", projected_usage);
return (projected_usage <= safety_margin);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment