X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=inode.c;h=1c6a083a7aeb825e10f3758859697258cb84d459;hb=69c35a771a31ff0e6b2b59b640c90d5508064c45;hp=95afc0a9cf7916da1352c64244fc2b501ed8deb2;hpb=f48181d57295355b68dffdd8fad5729bf952ba7a;p=bluesky.git diff --git a/inode.c b/inode.c index 95afc0a..1c6a083 100644 --- 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: @@ -148,5 +161,5 @@ void bluesky_file_truncate(BlueSkyInode *inode, uint64_t size) /* TODO: Zero out partial blocks if needed? */ inode->size = size; - inode->change_count++; + bluesky_inode_update_ctime(inode, 1); }