--- /dev/null
+/* 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
+ */
+
+#ifndef _BLUESKY_H
+#define _BLUESKY_H
+
+#include <stdint.h>
+#include <glib.h>
+
+/* File types. The numeric values are chosen to match with those used in
+ * NFSv3. */
+enum BlueSkyFileType {
+ BLUESKY_INVALID = 0,
+ BLUESKY_REGULAR = 1,
+ BLUESKY_DIRECTORY = 2,
+ BLUESKY_BLOCK = 3,
+ BLUESKY_CHARACTER = 4,
+ BLUESKY_SYMLINK = 5,
+ BLUESKY_SOCKET = 6,
+ BLUESKY_FIFO = 7,
+};
+
+/* Filesystem state. Each filesystem which is exported is represented by a
+ * single bluesky_fs structure in memory. */
+typedef struct {
+ GMutex *lock;
+
+ gchar *name; /* Descriptive name for the filesystem */
+ GHashTable *inodes; /* Cached inodes */
+ uint64_t next_inum; /* Next available inode for allocation */
+} BlueSkyFS;
+
+/* Timestamp, measured in microseconds since the Unix epoch. */
+typedef int64_t bluesky_time;
+
+/* In-memory representation of an inode within a Blue Sky server. This
+ * corresponds roughly with information that is committed to persistent
+ * storage. */
+typedef struct {
+ gint refcnt; /* May be accessed atomically without lock */
+ GMutex *lock;
+
+ int type;
+ uint32_t mode;
+ uint32_t uid, gid;
+ uint32_t nlink;
+
+ /* Rather than track an inode number and generation number, we will simply
+ * never re-use a fileid after a file is deleted. 64 bits should be enough
+ * that we don't exhaust the identifier space. */
+ uint64_t inum;
+
+ uint64_t change_count; /* Incremented each with each change made */
+ int64_t atime; /* Microseconds since the Unix epoch */
+ int64_t ctime;
+ int64_t mtime;
+ int64_t ntime; /* "new time": time object was created */
+
+ /* File-specific fields */
+ uint64_t size;
+
+ /* Directory-specific fields */
+ GSequence *dirents;
+} BlueSkyInode;
+
+/* A directory entry. The name is UTF-8 and is a freshly-allocated string.
+ * The name is hashed to a 64-bit value, and the directory entries are sorted
+ * by hash value (the hash value can then be used as a cookie for resuming a
+ * READDIR call). */
+typedef struct {
+ gchar *name;
+ uint64_t hash;
+ uint64_t inum;
+} BlueSkyDirent ;
+
+int64_t bluesky_get_current_time();
+uint64_t bluesky_fs_alloc_inode(BlueSkyFS *fs);
+BlueSkyInode *bluesky_new_inode(uint64_t inum);
+
+void bluesky_dirent_destroy(gpointer dirent);
+uint64_t bluesky_directory_hash(gchar *name);
+uint64_t bluesky_directory_lookup(BlueSkyInode *inode, gchar *name);
+gboolean bluesky_directory_insert(BlueSkyInode *dir, gchar *name,
+ uint64_t inum);
+void bluesky_directory_dump(BlueSkyInode *dir);
+
+#endif