#define HEADER_MAGIC 0x676f4c0a
#define FOOTER_MAGIC 0x2e435243
-struct log_header {
- uint32_t magic; // HEADER_MAGIC
- uint8_t type; // Object type + '0'
- uint32_t offset; // Starting byte offset of the log header
- uint32_t size1; // Size of the data item (bytes)
- uint32_t size2; //
- uint32_t size3; //
- uint64_t inum; // Inode which owns this data, if any
- BlueSkyCloudID id; // Object identifier
-} __attribute__((packed));
-
-struct log_footer {
- uint32_t magic; // FOOTER_MAGIC
- uint32_t crc; // Computed from log_header to log_footer.magic
-} __attribute__((packed));
-
static void writebuf(int fd, const char *buf, size_t len)
{
while (len > 0) {
writebuf(log->fd, (const char *)&footer, sizeof(footer));
item->log_seq = log->seq_num;
- item->log_offset = offset + sizeof(header);
- item->log_size = item->data->len;
+ item->log_offset = offset;
+ item->log_size = size;
+ item->data_size = item->data->len;
- offset += sizeof(header) + sizeof(footer) + item->data->len;
+ offset += size;
g_string_free(data1, TRUE);
g_string_free(data2, TRUE);
+ GUINT32_FROM_LE(header->size2)
+ GUINT32_FROM_LE(header->size3);
- g_mutex_lock(fs->lock);
- BlueSkyCloudLog *log_item;
- log_item = g_hash_table_lookup(fs->locations, &header->id);
- if (log_item == NULL) {
- log_item = bluesky_cloudlog_new(fs, &header->id);
- g_hash_table_insert(fs->locations, &log_item->id, log_item);
- g_mutex_lock(log_item->lock);
- } else {
- bluesky_cloudlog_ref(log_item);
- g_mutex_lock(log_item->lock);
- }
- g_mutex_unlock(fs->lock);
+ BlueSkyCloudLog *log_item = bluesky_cloudlog_get(fs, header->id);
+ g_mutex_lock(log_item->lock);
*objects = g_list_prepend(*objects, log_item);
log_item->inum = GUINT64_FROM_LE(header->inum);