return fs;
}
-void bluesky_serialize_inode(GString *out, BlueSkyInode *inode)
+BlueSkyCloudLog *bluesky_serialize_inode(BlueSkyInode *inode)
{
+ BlueSkyFS *fs = inode->fs;
+ GString *out = g_string_new("");
struct serialized_inode buf;
+ BlueSkyCloudLog *cloudlog = bluesky_cloudlog_new(fs);
+ cloudlog->type = LOGTYPE_INODE;
+ cloudlog->inum = inode->inum;
+
buf.signature = GUINT64_TO_LE(INODE_MAGIC);
buf.type = GUINT32_TO_LE(inode->type);
buf.mode = GUINT32_TO_LE(inode->mode);
g_string_append_len(out, (gchar *)&size, sizeof(uint64_t));
for (int i = 0; i < inode->blocks->len; i++) {
BlueSkyBlock *b = &g_array_index(inode->blocks, BlueSkyBlock, i);
- if (b->ref != NULL)
- g_string_append(out, b->ref);
- g_string_append_c(out, '\0');
+ BlueSkyCloudLog *ref = NULL;
+ if (b->type == BLUESKY_BLOCK_REF)
+ ref = b->ref;
+ bluesky_cloudlog_ref(ref);
+ g_array_append_val(cloudlog->links, ref);
}
break;
}
g_warning("Serialization for inode type %d not implemented!\n",
inode->type);
}
+
+ cloudlog->data = bluesky_string_new_from_gstring(out);
+ bluesky_cloudlog_insert(cloudlog);
+ bluesky_cloudlog_stats_update(cloudlog, 1);
+
+ return cloudlog;
}
/* Deserialize an inode into an in-memory representation. Returns a boolean
g_array_set_size(inode->blocks,
(inode->size + BLUESKY_BLOCK_SIZE - 1)
/ BLUESKY_BLOCK_SIZE);
+ // TODO
+#if 0
for (int i = 0; i < inode->blocks->len; i++) {
BlueSkyBlock *b = &g_array_index(inode->blocks, BlueSkyBlock, i);
b->type = BLUESKY_BLOCK_REF;
b->ref = g_strdup(buf);
buf += strlen(b->ref) + 1;
}
+#endif
break;
case BLUESKY_DIRECTORY: