[Imap-protocol] 2Gb size limit

Mark Crispin mrc+uw at panda.com
Wed May 5 12:20:21 PDT 2010

On Wed, 5 May 2010, Eduardo Luís wrote:

> No, it's not a 32bit OS feature.

Actually, it is your OS.

UW IMAP uses unsigned longs (it was largely written before off_t was
universally defined) which would support at least 4GB.

The problem is that off_t is defined on many systems as an int32, and the
lseek() call takes an off_t. This is the cause of the 2GB limit.

On other systems, off_t is defined as an int64. The limit should be 4GB,
not 2GB, on those system.

If you have a int32 off_t, then you need to do one of the following:

On some systems, you must change everything to use lseek64() call and

On other systems, it is possible to fix lseek() and off_t by defining
_FILE_OFFSET_BITS to 64. That will make off_t be an int64. If ulong on
your system is a uint32, that should give you up to a 4GB limit; if ulong
on your system is a uint64 then you win big.

Personally, I think that it is completely, utterly, insane to have a flat
mailbox file greater than 2GB; or for that matter much greater than 100MB.
Flat file formats were never intended to scale to such sizes.

You should use the mix format instead, which breaks the mailbox into
multiple files that are either 1MB or the size of a single message,
whichever is larger.

Now, if you have a single message which is greater than 2GB (or 4GB), then
you have other problems.

-- Mark --

Democracy is two wolves and a sheep deciding what to eat for lunch.
Liberty is a well-armed sheep contesting the vote.

More information about the Imap-protocol mailing list