Add new locate command with --tail option.

Co-authored-by: Andrea Mazzoleni <amadvance@gmail.com>
This commit is contained in:
Ralf 2026-02-02 11:19:51 +01:00 • committed by Andrea Mazzoleni
parent 1c4f9870fb
commit c09bdc572e
8 changed files with 291 additions and 21 deletions

View file

@ -19,6 +19,7 @@
#include "elem.h"
#include "support.h"
#include "state.h"
#include "util.h"
/****************************************************************************/
@ -1461,3 +1462,19 @@ const char* fmt_term(const struct snapraid_disk* disk, const char* str, char* bu
}
}
const char* fmt_size(uint64_t size, char* buffer, size_t buffer_size)
{
if (size >= 10UL * TERA)
snprintf(buffer, buffer_size, "%" PRIu64 " T", size / TERA);
else if (size >= 10UL * GIGA)
snprintf(buffer, buffer_size, "%" PRIu64 " G", size / GIGA);
else if (size >= 10UL * MEGA)
snprintf(buffer, buffer_size, "%" PRIu64 " M", size / MEGA);
else if (size >= 10UL * KILO)
snprintf(buffer, buffer_size, "%" PRIu64 " k", size / KILO);
else
snprintf(buffer, buffer_size, "%" PRIu64 " ", size);
return buffer;
}