return ret;
}
-void mail_index_header_init(struct mail_index_header *hdr)
-{
- time_t now = time(NULL);
-
- memset(hdr, 0, sizeof(*hdr));
-
- hdr->major_version = MAIL_INDEX_MAJOR_VERSION;
- hdr->minor_version = MAIL_INDEX_MINOR_VERSION;
- hdr->header_size = sizeof(*hdr);
-
-#ifndef WORDS_BIGENDIAN
- hdr->compat_data[0] = MAIL_INDEX_COMPAT_LITTLE_ENDIAN;
-#endif
- hdr->compat_data[1] = sizeof(uoff_t);
- hdr->compat_data[2] = sizeof(time_t);
- hdr->compat_data[3] = sizeof(keywords_mask_t);
-
- hdr->indexid = now;
-
- hdr->next_uid = 1;
-}
-
int mail_index_write_header(struct mail_index *index,
const struct mail_index_header *hdr)
{
return 1;
}
+static void mail_index_header_init(struct mail_index_header *hdr)
+{
+ time_t now = time(NULL);
+
+ memset(hdr, 0, sizeof(*hdr));
+
+ hdr->major_version = MAIL_INDEX_MAJOR_VERSION;
+ hdr->minor_version = MAIL_INDEX_MINOR_VERSION;
+ hdr->header_size = sizeof(*hdr);
+
+#ifndef WORDS_BIGENDIAN
+ hdr->compat_data[0] = MAIL_INDEX_COMPAT_LITTLE_ENDIAN;
+#endif
+ hdr->compat_data[1] = sizeof(uoff_t);
+ hdr->compat_data[2] = sizeof(time_t);
+ hdr->compat_data[3] = sizeof(keywords_mask_t);
+
+ hdr->indexid = now;
+
+ hdr->next_uid = 1;
+}
+
static int mail_index_open_files(struct mail_index *index,
enum mail_index_open_flags flags)
{
file->filepath);
return 0;
}
- if (file->hdr.indexid != file->log->index->indexid &&
- file->log->index->indexid != 0) {
- /* either index was just recreated, or transaction has wrong
- indexid. we don't know here which one is the case, so we'll
- just fail. If index->indexid == 0, we're rebuilding it and
- we just want to lock the transaction log. */
+ if (file->hdr.indexid != file->log->index->indexid) {
+ if (file->log->index->fd == -1) {
+ /* creating index file, silently rebuild
+ transaction log as well */
+ return 0;
+ }
+
mail_index_set_error(file->log->index,
"Transaction log file %s: invalid indexid (%u != %u)",
file->filepath, file->hdr.indexid,