]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Added back compat_data[]. It wasn't so simple to access data portably in
authorTimo Sirainen <tss@iki.fi>
Sun, 24 Aug 2003 07:06:06 +0000 (10:06 +0300)
committerTimo Sirainen <tss@iki.fi>
Sun, 24 Aug 2003 07:06:06 +0000 (10:06 +0300)
index files after all..

--HG--
branch : HEAD

src/lib-index/mail-index-open.c
src/lib-index/mail-index.h

index 7af82bb2c1d962154329a7ca7a4c53c6cb8bf7a7..de946d76b79cd0229b28ceafe817169b3a3caeef 100644 (file)
@@ -196,6 +196,16 @@ static int mail_index_init_file(struct mail_index *index,
        return TRUE;
 }
 
+static void get_compat_data(unsigned char compat_data[4])
+{
+#ifndef WORDS_BIGENDIAN
+       compat_data[0] = MAIL_INDEX_COMPAT_LITTLE_ENDIAN;
+#endif
+       compat_data[1] = sizeof(uoff_t);
+       compat_data[2] = sizeof(time_t);
+       compat_data[3] = 0;
+}
+
 void mail_index_init_header(struct mail_index_header *hdr)
 {
        i_assert(sizeof(struct mail_index_header) < 256);
@@ -204,6 +214,7 @@ void mail_index_init_header(struct mail_index_header *hdr)
        hdr->major_version = MAIL_INDEX_MAJOR_VERSION;
        hdr->minor_version = MAIL_INDEX_MINOR_VERSION;
        hdr->header_size = (uint8_t)sizeof(struct mail_index_header);
+       get_compat_data(hdr->compat_data);
 
        hdr->indexid = ioloop_time;
 
@@ -278,6 +289,7 @@ static int mail_index_open_index(struct mail_index *index,
                                 enum mail_index_open_flags flags)
 {
        struct mail_index_header hdr;
+       unsigned char compat_data[4];
        int ret;
 
        if ((flags & _MAIL_INDEX_OPEN_FLAG_CREATING) == 0)
@@ -299,8 +311,10 @@ static int mail_index_open_index(struct mail_index *index,
                return FALSE;
        index->indexid = hdr.indexid;
 
+       get_compat_data(compat_data);
        if (ret == 0 || hdr.major_version != MAIL_INDEX_MAJOR_VERSION ||
            (hdr.flags & MAIL_INDEX_HDR_FLAG_REBUILD) != 0 ||
+           memcmp(compat_data, hdr.compat_data, sizeof(compat_data)) != 0 ||
            !mail_index_mmap_update(index)) {
                if ((flags & MAIL_INDEX_OPEN_FLAG_CREATE) == 0)
                        return FALSE;
index 2c4c7158e9f4b707a0b1787a70d2068879a3e632..a217a5113a901544218178fcefc047cb2beca4ff 100644 (file)
@@ -24,6 +24,10 @@ enum mail_index_open_flags {
        _MAIL_INDEX_OPEN_FLAG_CREATING          = 0x100
 };
 
+enum mail_index_header_compat_flags {
+       MAIL_INDEX_COMPAT_LITTLE_ENDIAN         = 0x01
+};
+
 enum mail_index_header_flag {
        /* Rebuild flag is set while index is being rebuilt or when
           some error is noticed in the index file. If this flag is set,
@@ -104,6 +108,12 @@ struct mail_index_header {
        uint8_t header_size;
        uint8_t reserved;
 
+       /* 0 = flags
+          1 = sizeof(uoff_t)
+          2 = sizeof(time_t)
+          3 = reserved, 0 for now */
+       uint8_t compat_data[4];
+
        uint32_t indexid;
 
        uint32_t used_file_size;