fstrim: Pretty-print the trimmed size in addition to showing raw byte counts.

Also do not bother printing sizes if we are exiting without success
and nothing was reported as trimmed.
This commit is contained in:
Augustin Cavalier
2023-02-15 16:11:35 -05:00
parent 1572bf59b7
commit 06cf64e90c
2 changed files with 14 additions and 4 deletions
+5 -1
View File
@@ -35,7 +35,6 @@ StdBinCommands
error.c
fortune.c
finddir.c
fstrim.cpp
get_driver_settings.cpp
hd.c
listarea.c
@@ -113,6 +112,11 @@ if $(TARGET_PLATFORM) = libbe_test {
: tests!apps ;
}
# standard commands that need libbe.so, libshared.a
StdBinCommands
fstrim.cpp
: shared be : $(haiku-utils_rsrc) ;
# standard commands that need libbe.so and libsupc++.so
StdBinCommands
alert.cpp
+9 -3
View File
@@ -19,6 +19,7 @@
#include <Drivers.h>
#include <AutoDeleter.h>
#include <StringForSize.h>
static struct option const kLongOptions[] = {
@@ -262,9 +263,14 @@ main(int argc, char** argv)
retval = EXIT_FAILURE;
}
printf("Trimmed %" B_PRIu64 " bytes from device%s.\n",
trimData.trimmed_size,
retval == EXIT_SUCCESS ? "" : " (number may be inaccurate)");
if (retval == EXIT_SUCCESS || trimData.trimmed_size > 0) {
char trimmedSize[128];
string_for_size(trimData.trimmed_size, trimmedSize, 128);
printf("Trimmed %" B_PRIu64 " bytes (%s) from device%s.\n",
trimData.trimmed_size, trimmedSize,
retval == EXIT_SUCCESS ? "" : " (number may be inaccurate)");
}
return retval;
}