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
19 BLUESKY_DIRECTORY = 2,
21 BLUESKY_CHARACTER = 4,
27 /* Filesystem state. Each filesystem which is exported is represented by a
28 * single bluesky_fs structure in memory. */
32 gchar *name; /* Descriptive name for the filesystem */
33 GHashTable *inodes; /* Cached inodes */
34 uint64_t next_inum; /* Next available inode for allocation */
37 /* Inode number of the root directory. */
38 #define BLUESKY_ROOT_INUM 1
40 /* Timestamp, measured in microseconds since the Unix epoch. */
41 typedef int64_t bluesky_time;
43 /* In-memory representation of an inode within a Blue Sky server. This
44 * corresponds roughly with information that is committed to persistent
47 gint refcnt; /* May be accessed atomically without lock */
55 /* Rather than track an inode number and generation number, we will simply
56 * never re-use a fileid after a file is deleted. 64 bits should be enough
57 * that we don't exhaust the identifier space. */
60 uint64_t change_count; /* Incremented each with each change made */
61 int64_t atime; /* Microseconds since the Unix epoch */
64 int64_t ntime; /* "new time": time object was created */
66 /* File-specific fields */
69 /* Directory-specific fields */
71 uint64_t parent_inum; /* inode for ".."; 0 if the root directory */
74 /* A directory entry. The name is UTF-8 and is a freshly-allocated string.
75 * The name is hashed to a 64-bit value, and the directory entries are sorted
76 * by hash value (the hash value can then be used as a cookie for resuming a
84 BlueSkyFS *bluesky_new_fs(gchar *name);
85 int64_t bluesky_get_current_time();
86 uint64_t bluesky_fs_alloc_inode(BlueSkyFS *fs);
87 BlueSkyInode *bluesky_new_inode(uint64_t inum, BlueSkyFileType type);
89 BlueSkyInode *bluesky_get_inode(BlueSkyFS *fs, uint64_t inum);
90 void bluesky_insert_inode(BlueSkyFS *fs, BlueSkyInode *inode);
92 void bluesky_dirent_destroy(gpointer dirent);
93 uint64_t bluesky_directory_hash(gchar *name);
94 uint64_t bluesky_directory_lookup(BlueSkyInode *inode, gchar *name);
95 gboolean bluesky_directory_insert(BlueSkyInode *dir, gchar *name,
97 void bluesky_directory_dump(BlueSkyInode *dir);