ls3_stats_create_heap(dir_stats->lsdg_top_rating_limit);
}
+/* ls3_stats_get_dots - Generates dots to display
+ * depth in .out format reports.
+ */
+static char* ls3_stats_get_dots(int depth) {
+ int num_dots;
+ char *dots;
+ int i;
+
+ if (depth >= 0)
+ num_dots = depth * 4;
+ else
+ num_dots = 0;
+
+ dots = (char*) xcalloc(num_dots + 1, sizeof(char));
+ for (i = 0; i < num_dots; i++) {
+ if ((i + 1) % 4 == 0)
+ dots[i] = '/';
+ else
+ dots[i] = '.';
+ }
+
+ /* free(dots) will be call later after fprintf() */
+ return dots;
+}
+
+/* ls3_stats_fmt_size_units convert size in bytes to
+ * size in human readable output.
+ */
+static const char *ls3_stats_fmt_size_units(uint64_t bytes)
+{
+ const char *sizes[] = { "B", "KB", "MB", "GB", "TB", "Pb" };
+ int order = 0;
+ static char buffer[20];
+ double size = (double)bytes;
+
+ while (size >= 1024.0 && order < sizeof(sizes) / sizeof(*sizes) - 1) {
+ order++;
+ size /= 1024.0;
+ }
+
+ snprintf(buffer, sizeof(buffer), "%7.2f %2s", size, sizes[order]);
+
+ return buffer;
+}
+
/* ls3_stats_dir_incr_counters - Increases directory size */
static void ls3_stats_dir_incr_counters(struct ls3_object_attrs *loa_all,
struct ls3_stats_dir_obj *dir_ptr)
return result;
}
+/* ls3_stats_rm_first_dir - Removes the first directory from the array.
+ * Ex: ["dir1", "dir11", "dir111"] -> ["dir11", "dir111"]
+ */
+static void ls3_stats_rm_first_dir(char ***dirs, int *count)
+{
+ int i;
+
+ if ((*count) <= 0)
+ return;
+
+ free((*dirs)[0]);
+ for (i = 1; i < (*count); i++) {
+ (*dirs)[i - 1] = (*dirs)[i];
+ }
+
+ (*count)--;
+ /* free() for dirs will be later in ls3_stats_upd_dir_info() */
+ (*dirs)[(*count)] = NULL;
+}
+
void ls3_stats_dir_init(void)
{
int rc;