1 /* Blue Sky: File Systems in the Cloud
3 * Copyright (C) 2009 The Regents of the University of California
4 * Written by Michael Vrable <mvrable@cs.ucsd.edu>
15 /* File types. The numeric values are chosen to match with those used in
17 enum BlueSkyFileType {
20 BLUESKY_DIRECTORY = 2,
22 BLUESKY_CHARACTER = 4,
28 /* Filesystem state. Each filesystem which is exported is represented by a
29 * single bluesky_fs structure in memory. */
33 gchar *name; /* Descriptive name for the filesystem */
34 GHashTable *inodes; /* Cached inodes */
35 uint64_t next_inum; /* Next available inode for allocation */
38 /* Timestamp, measured in microseconds since the Unix epoch. */
39 typedef int64_t bluesky_time;
41 /* In-memory representation of an inode within a Blue Sky server. This
42 * corresponds roughly with information that is committed to persistent
45 gint refcnt; /* May be accessed atomically without lock */
53 /* Rather than track an inode number and generation number, we will simply
54 * never re-use a fileid after a file is deleted. 64 bits should be enough
55 * that we don't exhaust the identifier space. */
58 uint64_t change_count; /* Incremented each with each change made */
59 int64_t atime; /* Microseconds since the Unix epoch */
62 int64_t ntime; /* "new time": time object was created */
64 /* File-specific fields */
67 /* Directory-specific fields */
71 /* A directory entry. The name is UTF-8 and is a freshly-allocated string.
72 * The name is hashed to a 64-bit value, and the directory entries are sorted
73 * by hash value (the hash value can then be used as a cookie for resuming a
81 int64_t bluesky_get_current_time();
82 uint64_t bluesky_fs_alloc_inode(BlueSkyFS *fs);
83 BlueSkyInode *bluesky_new_inode(uint64_t inum);
85 void bluesky_dirent_destroy(gpointer dirent);
86 uint64_t bluesky_directory_hash(gchar *name);
87 uint64_t bluesky_directory_lookup(BlueSkyInode *inode, gchar *name);
88 gboolean bluesky_directory_insert(BlueSkyInode *dir, gchar *name,
90 void bluesky_directory_dump(BlueSkyInode *dir);