+/* Blue Sky: File Systems in the Cloud
+ *
+ * Copyright (C) 2009 The Regents of the University of California
+ * Written by Michael Vrable <mvrable@cs.ucsd.edu>
+ *
+ * TODO: Licensing
+ */
+
+#include <stdint.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include <glib.h>
+#include <string.h>
+
+#include "bluesky-private.h"
+
+/* Debugging support for BlueSky. */
+
+static void inode_dump(gpointer key, gpointer value, gpointer user_data)
+{
+ BlueSkyInode *inode = (BlueSkyInode *)value;
+
+ g_print("Inode %"PRIu64":\n", inode->inum);
+
+ gboolean locked = FALSE;
+ if (g_mutex_trylock(inode->lock)) {
+ locked = TRUE;
+ g_mutex_unlock(inode->lock);
+ }
+ g_print(" Locked: %c Refcount: %d\n",
+ locked ? 'T' : 'F', inode->refcount);
+
+ g_print(" Type: %d Mode: %o\n", inode->type, inode->mode);
+ g_print(" change_count = %"PRIu64", change_commit = %"PRIu64"\n",
+ inode->change_count, inode->change_commit);
+}
+
+/* Dump a summary of filesystem state as it is cached in memory. */
+void bluesky_debug_dump(BlueSkyFS *fs)
+{
+ g_print("*** DEBUG DUMP FOR FILESYSTEM %s ***\n", fs->name);
+ g_print("Cached inodes: %u\tNext inode: %"PRIu64"\n",
+ g_hash_table_size(fs->inodes), fs->next_inum);
+
+ g_hash_table_foreach(fs->inodes, inode_dump, fs);
+}