X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;ds=sidebyside;f=bluesky.h;h=5571db61edca13bce778d41aed01e70a288a8f77;hb=386250b1e7b69e1050b8eb96402ea764dbc77b25;hp=c85fd708f0fe5f5c18b03925ddfdfab6e5e16c39;hpb=f48181d57295355b68dffdd8fad5729bf952ba7a;p=bluesky.git diff --git a/bluesky.h b/bluesky.h index c85fd70..5571db6 100644 --- a/bluesky.h +++ b/bluesky.h @@ -12,6 +12,19 @@ #include #include +/* Reference-counted blocks of memory, used for passing data in and out of + * storage backends and in other places. */ +typedef struct { + gint refcount; + gpointer data; + gsize len; +} BlueSkyRCStr; + +BlueSkyRCStr *bluesky_string_new(gpointer data, gsize len); +void bluesky_string_ref(BlueSkyRCStr *string); +void bluesky_string_unref(BlueSkyRCStr *string); +BlueSkyRCStr *bluesky_string_dup(BlueSkyRCStr *string); + /* File types. The numeric values are chosen to match with those used in * NFSv3. */ typedef enum { @@ -68,17 +81,19 @@ typedef struct { GArray *blocks; /* Directory-specific fields */ - GSequence *dirents; + GSequence *dirents; /* List of entries for READDIR */ + GHashTable *dirhash; /* Hash table by name for LOOKUP */ uint64_t parent_inum; /* inode for ".."; 0 if the root directory */ } 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). */ + * Each directory entry is listed in two indices: dirents is indexed by cookie + * and dirhash by name. The cookie is a randomly-assigned 32-bit value, unique + * within the directory, that remains unchanged until the entry is deleted. It + * is used to provide a stable key for restarting a READDIR call. */ typedef struct { gchar *name; - uint64_t hash; + uint32_t cookie; uint64_t inum; } BlueSkyDirent; @@ -103,6 +118,7 @@ typedef struct { BlueSkyFS *bluesky_new_fs(gchar *name); int64_t bluesky_get_current_time(); +void bluesky_inode_update_ctime(BlueSkyInode *inode, gboolean update_mtime); uint64_t bluesky_fs_alloc_inode(BlueSkyFS *fs); BlueSkyInode *bluesky_new_inode(uint64_t inum, BlueSkyFileType type); @@ -116,6 +132,12 @@ gboolean bluesky_directory_insert(BlueSkyInode *dir, gchar *name, uint64_t inum); void bluesky_directory_dump(BlueSkyInode *dir); +void bluesky_block_touch(BlueSkyInode *inode, uint64_t i); +void bluesky_block_flush(BlueSkyBlock *block); void bluesky_file_truncate(BlueSkyInode *inode, uint64_t size); +void bluesky_file_write(BlueSkyInode *inode, uint64_t offset, + const char *data, gint len); +void bluesky_file_read(BlueSkyInode *inode, uint64_t offset, + char *buf, gint len); #endif