On Wed, 2005-07-13 at 15:00 +0100, Chris Wakelin wrote:
- offset = *((const uint64_t *)data); +/* CDW, see - http://dovecot.org/pipermail/dovecot/2005-January/005926.html */ +/* offset = *((const uint64_t *)data); CDW */ + memcpy(&offset,data,sizeof(uint64_t));
Although this works, this wasn't really how I wanted to fix this. I think this should work (indexes need to be recreated afterwards): Index: lib-index/mail-index-sync-ext.c =================================================================== RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-sync-ext.c,v retrieving revision 1.9 diff -u -r1.9 mail-index-sync-ext.c --- lib-index/mail-index-sync-ext.c 4 Jul 2005 11:32:20 -0000 1.9 +++ lib-index/mail-index-sync-ext.c 13 Jul 2005 15:50:14 -0000 @@ -169,7 +169,7 @@ struct mail_index_map *new_map; struct mail_index_ext *ext, **sorted; struct mail_index_ext_header *ext_hdr; - uint16_t *old_offsets, min_align; + uint16_t *old_offsets, min_align, max_align; uint32_t offset, old_records_count, rec_idx; unsigned int i, count; const void *src; @@ -192,9 +192,13 @@ requirement first. FIXME: if the extension sizes don't match alignmentation, this may not give the minimal layout. */ offset = sizeof(struct mail_index_record); + max_align = sizeof(uint32_t); for (;;) { min_align = (uint16_t)-1; for (i = 0; i < count; i++) { + if (sorted[i]->record_align > max_align) + max_align = sorted[i]->record_align; + if (sorted[i]->record_offset == 0) { if ((offset % sorted[i]->record_align) == 0) break; @@ -218,9 +222,9 @@ i_assert(offset < (uint16_t)-1); } - if ((offset % sizeof(uint32_t)) != 0) { - /* keep 32bit alignment */ - offset += sizeof(uint32_t) - (offset % sizeof(uint32_t)); + if ((offset % max_align) != 0) { + /* keep record size divisible with maximum alignment */ + offset += max_align - (offset % max_align); } /* create a new mapping without records. a bit kludgy. */