Re: [exim] Quota over 2GB supported?

Inizio della pagina
Delete this message
Reply to this message
Autore: Michael Haardt
Data:  
To: exim-users
Oggetto: Re: [exim] Quota over 2GB supported?
On Tue, Jun 07, 2005 at 04:33:55PM +0100, Philip Hazel wrote:
> This contains my version of Michael's patch, plus the necessary changes
> to handle large directories of maildir files, maildirsize, etc. I found
> a better way of converting off_t values for printing, namely
>
> printf("%.30g", (double)off_t_value);
>
> This, I hope, will work in all environments.


It won't work correctly in those environments, where the number of
mantissa bits in a double is less than the number of bits in an off_t.
On many systems, both types have the same size, so you lose as much
accuracy as sign and offset take. Since you have Linux on ia32, try:

#define _FILE_OFFSET_BITS 64

#include <sys/types.h>
#include <stdio.h>

const unsigned char *offtostr(off_t n)
{
static unsigned char buf[128];
unsigned char *t;
size_t size,capacity;

size=capacity=0;
t=buf+sizeof(buf)-1;
*t='\0';
if (n==0) *--t='0';
else while (n) { *--t=n%10+'0'; n/=10; }
return t;
}

int main(int argc, char *argv[])
{
off_t o;
char buf[128];

o=1;
o<<=53;

snprintf(buf,sizeof(buf),"%.30g",(double)o);
printf("%s ",buf);
printf("%s\n",offtostr(o));

++o;

snprintf(buf,sizeof(buf),"%.30g",(double)o);
printf("%s ",buf);
printf("%s\n",offtostr(o));

exit(0);
}

Indeed, C sucks when it comes to off_t and time_t. There is no way to
express literals for those types, either. I don't know if C99 changes
any of that.

Michael