Regardless, it's still a good idea to properly support sizes >2GB. Michael, perhaps you could take a look at the latest 5.4 version and send me a patch against that?
Yes i can, but looking at the new code (5.4.3) there are some new features i don't know about yet (per domain quotas i guess) which also need some testing for >2GB compliance. I'm afraid i can't talk my admin into testing this new stuff, and i don't have access to a vpopmail installation. I personally use a very different setup for my emailserver.
NOTE: I changed the code how i think it should work (including the new features) - please test it before you merge it, especially the new features. And don't forget the CFLAGS for 64bit ;)
Also what about the %lld issue in scanf and printf? for printf you could use a function like the one that the courier guys have (called libmail_str_off_t() found in numlib/strofft.c), for reading the 2 columns there's probably a totally new parser needed to replace scanf (or not, if you decide %lld is ok).
btw - there are probably some more fixes ahead, because there are issues with race-conditions and the use of off_t i'm currently discussing with the courier-imap developers.
Mike
--- vpopmail-5.4.3/maildirquota.c 2003-12-19 06:16:36.000000000 +0100 +++ vpopmail-5.4.3_2gbfix/maildirquota.c 2004-05-16 19:10:20.725856816 +0200 @@ -43,18 +43,18 @@ time_t *, off_t *, unsigned *); static int statcurnew(const char *, time_t *); static int statsubdir(const char *, const char *, time_t *); -static int doaddquota(const char *, int, const char *, long, int, int); +static int doaddquota(const char *, int, const char *, off_t, int, int); static int docheckquota(const char *dir, int *maildirsize_fdptr, - const char *quota_type, long xtra_size, int xtra_cnt, int *percentage); + const char *quota_type, off_t xtra_size, int xtra_cnt, int *percentage); static int docount(const char *, time_t *, off_t *, unsigned *); static int maildir_checkquota(const char *dir, int *maildirsize_fdptr, - const char *quota_type, long xtra_size, int xtra_cnt); + const char *quota_type, off_t xtra_size, int xtra_cnt); static int maildir_addquota(const char *dir, int maildirsize_fd, - const char *quota_type, long maildirsize_size, int maildirsize_cnt); + const char *quota_type, off_t maildirsize_size, int maildirsize_cnt); static int maildir_safeopen(const char *path, int mode, int perm); static char *str_pid_t(pid_t t, char *arg); static char *str_time_t(time_t t, char *arg); -static int maildir_parsequota(const char *n, unsigned long *s); +static int maildir_parsequota(const char *n, off_t *s); #define NUMBUFSIZE 60 @@ -71,8 +71,8 @@ char domdir[MAX_PW_DIR]; char *p; char domain[256]; -unsigned long size = 0; -unsigned long maxsize = 0; +off_t size = 0; +off_t maxsize = 0; int cnt = 0; int maxcnt = 0; struct vlimits limits; @@ -110,7 +110,7 @@ return 0; } -int readdomainquota(const char *dir, long *sizep, int *cntp) +int readdomainquota(const char *dir, off_t *sizep, int *cntp) { int tries; char checkdir[256]; @@ -239,14 +239,14 @@ return 0; } -int readuserquota(const char* dir, long *sizep, int *cntp) +int readuserquota(const char* dir, off_t *sizep, int *cntp) { int retval; off_t s; - s = (off_t) *sizep; + s = *sizep; retval = wrapreaduserquota(dir, &s, cntp); - *sizep = (long) s; + *sizep = s; return retval; } @@ -308,7 +308,7 @@ int f; char *p; unsigned l; - int n; + off_t n; int first; if ((f=maildir_safeopen(filename, O_RDWR|O_APPEND, 0)) < 0) @@ -340,9 +340,10 @@ *p=0; p=buf; first=1; + while (*p) { - long n=0; + off_t n=0; int c=0; char *q=p; @@ -358,9 +359,11 @@ first=0; continue; } - sscanf(q, "%ld %d", &n, &c); - *sizeptr += n; - *cntptr += c; + if (sscanf(q, "%lld %d", &n, &c) == 2) + { + *sizeptr += n; + *cntptr += c; + } ++ *nlines; } *fdptr=f; @@ -430,7 +433,7 @@ static int maildir_checkquota(const char *dir, int *maildirsize_fdptr, const char *quota_type, - long xtra_size, + off_t xtra_size, int xtra_cnt) { int dummy; @@ -453,7 +456,7 @@ static int docheckquota(const char *dir, int *maildirsize_fdptr, const char *quota_type, - long xtra_size, + off_t xtra_size, int xtra_cnt, int *percentage) { @@ -615,7 +618,7 @@ } static int maildir_addquota(const char *dir, int maildirsize_fd, - const char *quota_type, long maildirsize_size, int maildirsize_cnt) + const char *quota_type, off_t maildirsize_size, int maildirsize_cnt) { if (!quota_type || !*quota_type) return (0); return (doaddquota(dir, maildirsize_fd, quota_type, maildirsize_size, @@ -623,7 +626,7 @@ } static int doaddquota(const char *dir, int maildirsize_fd, - const char *quota_type, long maildirsize_size, int maildirsize_cnt, + const char *quota_type, off_t maildirsize_size, int maildirsize_cnt, int isnew) { union { @@ -687,7 +690,7 @@ } - sprintf(u.buf, "%ld %d\n", maildirsize_size, maildirsize_cnt); + snprintf(u.buf, 100, "%lld %d\n", maildirsize_size, maildirsize_cnt); iov[niov].iov_base=u.buf; iov[niov].iov_len=strlen(u.buf); @@ -852,7 +855,7 @@ char *p; DIR *dirp; struct dirent *de; -unsigned long s; +off_t s; if (stat(dir, &stat_buf)) return (0); /* Ignore */ if (stat_buf.st_mtime > *dirstamp) *dirstamp=stat_buf.st_mtime; @@ -882,7 +885,7 @@ if (maildir_parsequota(n, &s) == 0) - stat_buf.st_size=s; + stat_buf.st_size = s; else { p=(char *)malloc(strlen(dir)+strlen(n)+2); @@ -970,7 +973,7 @@ return (strcpy(arg, p)); } -static int maildir_parsequota(const char *n, unsigned long *s) +static int maildir_parsequota(const char *n, off_t *s) { const char *o; int yes; --- vpopmail-5.4.3/maildirquota.h 2003-10-20 20:59:57.000000000 +0200 +++ vpopmail-5.4.3_2gbfix/maildirquota.h 2004-05-16 19:00:27.060107728 +0200 @@ -12,8 +12,8 @@ I"ve made the courier functions static. - Brian Kolaci */ -int readdomainquota(const char *dir, long *sizep, int *cntp); -int readuserquota(const char* dir, long *sizep, int *cntp); +int readdomainquota(const char *dir, off_t *sizep, int *cntp); +int readuserquota(const char* dir, off_t *sizep, int *cntp); int domain_over_maildirquota(const char *userdir); int user_over_maildirquota(const char *dir, const char *quota); void add_warningsize_to_quota( const char *dir, const char *quota); @@ -45,19 +45,19 @@ int maildir_checkquota(const char *, /* Pointer to directory */ int *, /* Initialized to -1, or opened descriptor for maildirsize */ const char *, /* The quota */ - long, /* Extra bytes planning to add/remove from maildir */ + off_t, /* Extra bytes planning to add/remove from maildir */ int); /* Extra messages planning to add/remove from maildir */ int maildir_addquota(const char *, /* Pointer to the maildir */ int, /* Must be the int pointed to by 2nd arg to checkquota */ const char *, /* The quota */ - long, /* +/- bytes */ + off_t, /* +/- bytes */ int); /* +/- files */ int maildir_readquota(const char *, /* Directory */ const char *); /* Quota, from getquota */ -int maildir_parsequota(const char *, unsigned long *); +int maildir_parsequota(const char *, off_t *); /* Attempt to parse file size encoded in filename. Returns 0 if ** parsed, non-zero if we didn't parse. */