On Mon, Feb 27, 2006 at 04:09:24PM +0000, Keith Matthews wrote:
> File offsets (i.e. pointers into the file used when scanning one) are
> normally represented as type 'int'.
Not quite that simple:
* Some functions (fseek, ftell) take arguments of type 'long', on the
platforms I've checked anyway.
* Many others take arguments of type 'off_t'. A modern 'struct stat' will
have
off_t st_size; /* file size, in bytes */
(Under Linux, depending on how the O/S is built, it could be __off_t or
__off64_t. See /usr/include/bits/stats.h)
> By default those are 32-bits long on
> 32-bit platforms.
off_t might be defined to be an int, or a long, or a long long, depending on
the O/S. There is nothing which limits an off_t to being just 'int' that I'm
aware of. It's an O/S choice as to whether to support files >2GB or not.
> Hence you must either upgrade to 64-bit hardware or use an O/s that uses
> a non-standard representation of offsets.
off_t is standard C, although I'm not sure which one (ANSI? ISO? POSIX? The
great thing about standards is there are so many to choose from :-)
What I'm trying to say is: there's nothing ugly or "non-standard" in having
64-bit offsets on a 32-bit CPU; in fact it's a perfectly reasonable thing to
do.
However, in this particular case in courier, we're not even bothered about
individual files being over 2GB; rather, it's what type we use for
accumulating the quota size into.
In courier's case, when calculating quotas, it might be reasonable to use
'long' as the accumulator type. Unfortunately, on some platforms, 'long' is
32 bit even where off_t is 64 bit; and 'long long' is not standard C, which
means having to build some autoconf cruft to define the type which we use.
If the platform has int64_t then that might be a better choice of type for
the calculation, but then there's not a printf() conversion flag which means
'int64_t', so it would still have to be cast to "%ld" (long) or "%lld" (long
long) depending on the platform's capabilities.
This is one area of C which was a total mess from day 1 and has never
properly been resolved :-(
So if you wanted to fix this yourself, you could:
- define an bigint type which is defined to be either 'long long' or
'long' (decided by autoconf)
- define a BIGINT_FMT string which is defined to be either "l" or "ll"
similarly
- then modify the quota code to use this type and printf string
However, any other program which also accesses the Maildir will have to be
modified similarly, such as any MTA which delivers into it. For comparison,
exim also uses off_t (with OFF_T_FMT as the printf format string), so on a
platform with 32-bit off_t you'd have to modify exim as well, although you
could instead configure exim to call courier's 'deliverquota' program to
perform the actual delivery and quota update.
Given that, then it may be easier to choose an operating system which
supports 64-bit off_t in the first place.
Regards,
Brian.
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Courier-imap mailing list
[email protected]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-imap