+static void cloudlog_dump(gpointer key, gpointer value, gpointer user_data)
+{
+ BlueSkyCloudLog *log = (BlueSkyCloudLog *)value;
+
+ for (int i = 0; i < sizeof(BlueSkyCloudID); i++) {
+ g_print("%02x", (uint8_t)(log->id.bytes[i]));
+ }
+ g_print(": refs=%d ty=%d inode=%"PRIu64" locs=%x log@(%d,%d) cloud@(%d,%d,%d)\n",
+ log->refcount,
+ log->type, log->inum,
+ log->location_flags | (log->data != NULL ? 0x100 : 0),
+ log->log_seq, log->log_offset, log->location.directory,
+ log->location.sequence, log->location.offset);
+}
+
+static void cache_dump(gpointer key, gpointer value, gpointer user_data)
+{
+ BlueSkyCacheFile *cache = (BlueSkyCacheFile *)value;
+
+ int64_t age = bluesky_get_current_time() - cache->atime;
+ g_print("%s addr=%p mapcount=%d refcount=%d atime_age=%f",
+ cache->filename, cache->addr, cache->mapcount, cache->refcount,
+ age / 1e6);
+ if (cache->fetching)
+ g_print(" (fetching)");
+ g_print("\n");
+}
+
+
+void inode_map_dump(GSequence *inode_map)
+{
+ GSequenceIter *i, *j;
+
+ g_print("\nInode map dump:\n");
+ for (i = g_sequence_get_begin_iter(inode_map);
+ !g_sequence_iter_is_end(i); i = g_sequence_iter_next(i))
+ {
+ InodeMapRange *range = (InodeMapRange *)g_sequence_get(i);
+
+ g_print(" Range [%"PRIu64", %"PRIu64"]\n", range->start, range->end);
+
+ for (j = g_sequence_get_begin_iter(range->map_entries);
+ !g_sequence_iter_is_end(j); j = g_sequence_iter_next(j))
+ {
+ InodeMapEntry *entry = (InodeMapEntry *)g_sequence_get(j);
+ BlueSkyCloudLog *item = entry->item;
+ if (item != NULL) {
+ char *id = bluesky_cloudlog_id_to_string(item->id);
+ g_print(" Entry %"PRIu64" id=%s\n", entry->inum, id);
+ g_free(id);
+ } else {
+ g_print(" Entry %"PRIu64" not available\n", entry->inum);
+ }
+ }
+ }
+}