Switch to 31-bit directory cookies and a separate hashtable for lookups.
[bluesky.git] / inode.c
diff --git a/inode.c b/inode.c
index 95afc0a..aa822b7 100644 (file)
--- a/inode.c
+++ b/inode.c
@@ -24,6 +24,18 @@ int64_t bluesky_get_current_time()
     return (int64_t)t.tv_sec * 1000000 + t.tv_usec;
 }
 
+/* Update an inode to indicate that a modification was made.  This increases
+ * the change counter, updates the ctime to the current time, and optionally
+ * updates the mtime. */
+void bluesky_inode_update_ctime(BlueSkyInode *inode, gboolean update_mtime)
+{
+    int64_t now = bluesky_get_current_time();
+    inode->change_count++;
+    inode->ctime = now;
+    if (update_mtime)
+        inode->mtime = now;
+}
+
 /* Unfortunately a glib hash table is only guaranteed to be able to store
  * 32-bit keys if we use the key directly.  If we want 64-bit inode numbers,
  * we'll have to allocate memory to store the 64-bit inumber, and use a pointer
@@ -85,6 +97,7 @@ BlueSkyInode *bluesky_new_inode(uint64_t inum, BlueSkyFileType type)
         break;
     case BLUESKY_DIRECTORY:
         i->dirents = g_sequence_new(bluesky_dirent_destroy);
+        i->dirhash = g_hash_table_new(g_str_hash, g_str_equal);
         break;
     case BLUESKY_BLOCK:
     case BLUESKY_CHARACTER: