mail-index-map.c revision 3e559edb905bb57d1f1fbfda3431b339f45ea791
1516N/A/* Copyright (c) 2003-2007 Dovecot authors, see the included COPYING file */ 2639N/A /* try to use the existing pool's size for initial_count so 39N/A we don't grow it unneededly */ 39N/A /* Update index ext_id -> map ext_id mapping. Fill non-used 39N/A ext_ids with (uint32_t)-1 */ 2073N/A /* Extension header contains: 2073N/A - struct mail_index_ext_header 39N/A - name (not 0-terminated) 2639N/A - extension header contents 315N/A /* we allow only plain ASCII names, so this extension 39N/A is most likely broken */ 1352N/A /* finally make sure that the hdr_size is small enough. 1431N/A do this last so that we could return a usable name. */ 1045N/A "outside record size (%u+%u > %u)",
2842N/A /* extension headers always start from 64bit offsets, so if base header 2842N/A doesn't happen to be 64bit aligned we'll skip some bytes */ 59N/A /* nothing to do, skip allocatations and all */ 2639N/A "Header extension #%d (%s) goes outside header",
2240N/A "Broken extension #%d (%s): %s",
2240N/A "Duplicate header extension %s",
2284N/A /* Extension header contains: 838N/A - struct mail_index_keyword_header 838N/A - struct mail_index_keyword_header_rec * keywords_count 838N/A - const char names[] * keywords_count 838N/A /* Keywords can only be added into same mapping. Removing requires a 838N/A new mapping (recreating the index file) */ 845N/A /* make sure the header is valid */ 838N/A "Keywords removed unexpectedly",
838N/A "keywords_count larger than header size",
203N/A "name_offset points outside allocated header",
46N/A "Keyword header doesn't end with NUL",
2453N/A /* create file -> index mapping */ 2453N/A /* Check that existing headers are still the same. It's behind DEBUG 2453N/A since it's pretty useless waste of CPU normally. */ 2453N/A "Keywords changed unexpectedly",
2453N/A /* Register the newly seen keywords */ 2453N/A "Empty keyword name in header",
2453N/A /* major version change - handle silently(?) */ 2453N/A /* we've already complained about it */ 2453N/A "CPU architecture changed",
2453N/A "Corrupted header sizes (base %u, full %u)",
2453N/A "indexid changed: %u -> %u",
2453N/A /* following some extra checks that only take a bit of CPU */ 2453N/A /* upgrade silently from v1.0 */ 2453N/A /* last message's UID must be smaller than next_uid. 2453N/A also make sure it's not zero. */ 2608N/A /* header smaller than ours, make a copy so our newer headers 2608N/A won't have garbage in them */ 342N/A /* FIXME: backwards compatibility, remove later. In case this index is 926N/A accessed with Dovecot v1.0, avoid recent message counter errors. */ 2453N/A /* too large file to map into memory */ 111N/A /* major version change - handle silently */ 113N/A /* Can't use this file */ 2073N/A "messages_count too large (%u > %u)",
1970N/A /* try to read the whole header, but it's not necessarily an error to 1970N/A read less since the older versions of the index format could be 591N/A smaller. Request reading up to buf_size, but accept if we only got 2613N/A /* major version change - handle silently */ 1890N/A /* place the base header into memory. */ 1500N/A /* @UNSAFE: read the rest of the header into memory */ 2608N/A /* header read, read the records now. */ 1500N/A "messages_count too large (%u > %u)",
1500N/A /* a new index file was renamed over this one. */ 39N/A "Corrupted index file %s: File too small",
1007N/A /* notify all "sync lost" handlers */ 1100N/A /* ESTALE - reopen index file */ 1007N/A /* a bit kludgy way to do this, but it initializes everything 1890N/A build it from the transaction log. */ 1472N/A /* the index file is still open, lock it */ 1636N/A /* mmaping seems to be slower than just reading the file, so even if 1636N/A mmap isn't disabled don't use it unless the file is large enough */ 2284N/A /* make sure the header is ok before using this mapping */ 315N/A /* fsck and try again */ 2073N/A /* fsck replaced the map */ 1461N/A /* first try updating the existing mapping from transaction log. */ 1461N/A /* we're not creating the index, or opening transaction log. 1461N/A sync this as a view from transaction log. */ 1044N/A /* try to open and read the latest index. if it fails for 1044N/A any reason, we'll fallback to updating the existing mapping 1044N/A from transaction logs (which we'll also do even if the 1044N/A /* if we're creating the index file, we don't have any 2639N/A /* and update the map with the latest changes from 2073N/A /* if the map is ever written back to disk, we need to keep track of 956N/A /* use src->hdr copy directly, because if we got here 2073N/A from syncing it has the latest changes. */ 956N/A /* fix the name pointers to use our own pool */