On Tue, Sep 25, 2012 at 10:19:29AM +0200, Josip Rodin wrote:
> On Mon, Sep 24, 2012 at 08:35:25PM +0200, Evgeni Golov wrote:
> > Attached is a patch which applies to 2.2.0-3.1 and is pretty much the 
> > same as upstream applied in 2.5.0[1].
> 
> There was no attachment in that mail :)

Let's pretend this never happened ;)
Attached.

-- 
Bruce Schneier can read and understand Perl programs.
From: Hugo Monteiro <[email protected]>
Subject: Big quota patch (with some changes)
 Use int64_t instead of off_t for quota storage/calculation.
Bug-Debian: http://bugs.debian.org/185149

diff --git a/maildir/maildirquota.c b/maildir/maildirquota.c
index 7eb0883..a54ddbc 100644
--- a/maildir/maildirquota.c
+++ b/maildir/maildirquota.c
@@ -197,7 +197,7 @@ static int do_maildir_openquotafile(struct maildirsize 
*info,
        first=1;
        while (*p)
        {
-               off_t n=0;
+               int64_t n=0;
                int c=0;
                char    *q=p;
                int     neg;
@@ -270,7 +270,7 @@ static int do_maildir_openquotafile(struct maildirsize 
*info,
 
 static void parsequotastr(const char *quota, struct maildirquota *q)
 {
-       off_t i;
+       int64_t i;
        const char *quota_start = quota;
 
        q->nbytes=0;
@@ -321,7 +321,7 @@ void maildir_closequotafile(struct maildirsize *info)
  ** Check if size > quota, and calculate by how much
  */
 
-static int checkOneQuota(off_t size, off_t quota, int *percentage);
+static int checkOneQuota(int64_t size, int64_t quota, int *percentage);
 
 static int checkQuota(struct maildirquota *size,
                      struct maildirquota *quota, int *percentage)
@@ -347,7 +347,7 @@ static int checkQuota(struct maildirquota *size,
        return (0);
 }
 
-static int checkOneQuota(off_t size, off_t quota, int *percentage)
+static int checkOneQuota(int64_t size, int64_t quota, int *percentage)
 {
        int x=1;
 
@@ -371,20 +371,20 @@ static int checkOneQuota(off_t size, off_t quota, int 
*percentage)
 }
 
 static char *makenewmaildirsizename(const char *, int *);
-static int countcurnew(const char *, time_t *, off_t *, unsigned *);
+static int countcurnew(const char *, time_t *, int64_t *, unsigned *);
 static int countsubdir(const char *, const char *,
-               time_t *, off_t *, unsigned *);
+               time_t *, int64_t *, unsigned *);
 static int statcurnew(const char *, time_t *);
 static int statsubdir(const char *, const char *, time_t *);
 
-static int     doaddquota(struct maildirsize *, int, off_t, int, int);
+static int     doaddquota(struct maildirsize *, int, int64_t, int, int);
 
 static int docheckquota(struct maildirsize *info,
-                       off_t xtra_size,
+                       int64_t xtra_size,
                        int xtra_cnt, int *percentage);
 
 int maildir_checkquota(struct maildirsize *info,
-                      off_t xtra_size,
+                      int64_t xtra_size,
                       int xtra_cnt)
 {
        int     dummy;
@@ -401,13 +401,13 @@ int maildir_readquota(struct maildirsize *info)
 }
 
 static int docheckquota(struct maildirsize *info,
-                       off_t xtra_size,
+                       int64_t xtra_size,
                        int xtra_cnt,
                        int *percentage)
 {
        char    *newmaildirsizename;
        int     maildirsize_fd;
-       off_t   maildirsize_size;
+       int64_t maildirsize_size;
        unsigned maildirsize_cnt;
 
        time_t  tm;
@@ -560,7 +560,7 @@ static int docheckquota(struct maildirsize *info,
 }
 
 int    maildir_addquota(struct maildirsize *info,
-                        off_t maildirsize_size, int maildirsize_cnt)
+                        int64_t maildirsize_size, int maildirsize_cnt)
 {
        if (info->fd < 0)
                return (0);
@@ -570,7 +570,7 @@ int maildir_addquota(struct maildirsize *info,
 }
 
 static int doaddquota(struct maildirsize *info, int maildirsize_fd,
-                     off_t maildirsize_size, int maildirsize_cnt,
+                     int64_t maildirsize_size, int maildirsize_cnt,
                      int isnew)
 {
        char    n[NUMBUFSIZE];
@@ -589,7 +589,7 @@ static int doaddquota(struct maildirsize *info, int 
maildirsize_fd,
                        b[0]=MDQUOTA_SIZE;
                        b[1]=0;
 
-                       strcat(strcat(buf, 
libmail_str_off_t(info->quota.nbytes, n)),
+                       strcat(strcat(buf, 
libmail_str_int64_t(info->quota.nbytes, n)),
                               b);
                }
 
@@ -611,10 +611,10 @@ static int doaddquota(struct maildirsize *info, int 
maildirsize_fd,
        }
 
        sprintf(buf + strlen(buf),
-               "%12s ", libmail_str_off_t(maildirsize_size, n));
+               "%12s ", libmail_str_int64_t(maildirsize_size, n));
 
        sprintf(buf + strlen(buf),
-               "%12s\n", libmail_str_off_t(maildirsize_cnt, n));
+               "%12s\n", libmail_str_int64_t(maildirsize_cnt, n));
 
        p=buf;
        cnt=strlen(buf);
@@ -706,10 +706,10 @@ int       n;
        return (n);
 }
 
-static int docount(const char *, time_t *, off_t *, unsigned *);
+static int docount(const char *, time_t *, int64_t *, unsigned *);
 
 static int countcurnew(const char *dir, time_t *maxtime,
-       off_t *sizep, unsigned *cntp)
+       int64_t *sizep, unsigned *cntp)
 {
 char   *p=(char *)malloc(strlen(dir)+5);
 int    n;
@@ -727,7 +727,7 @@ int n;
 }
 
 static int countsubdir(const char *dir, const char *subdir, time_t *maxtime,
-       off_t *sizep, unsigned *cntp)
+       int64_t *sizep, unsigned *cntp)
 {
 char   *p;
 int    n;
@@ -746,7 +746,7 @@ int n;
 }
 
 static int docount(const char *dir, time_t *dirstamp,
-       off_t *sizep, unsigned *cntp)
+       int64_t *sizep, unsigned *cntp)
 {
 struct stat    stat_buf;
 char   *p;
@@ -850,7 +850,7 @@ int maildirquota_countfile(const char *n)
 
 int maildir_quota_add_start(const char *maildir,
                            struct maildirsize *info,
-                           off_t msgsize, int nmsgs,
+                           int64_t msgsize, int nmsgs,
                            const char *newquota)
 {
        struct maildirquota mq;
@@ -905,14 +905,14 @@ int maildir_quota_add_start(const char *maildir,
 }
 
 void maildir_quota_add_end(struct maildirsize *info,
-                          off_t msgsize, int nmsgs)
+                          int64_t msgsize, int nmsgs)
 {
        maildir_addquota(info, msgsize, nmsgs);
        maildir_closequotafile(info);
 }
 
 void maildir_quota_deleted(const char *maildir,
-                          off_t nbytes,        /* Must be negative */
+                          int64_t nbytes,      /* Must be negative */
                           int nmsgs)   /* Must be negative */
 {
        struct maildirsize info;
@@ -939,7 +939,7 @@ void maildir_quota_recalculate(const char *maildir)
 
 int maildir_quota_delundel_start(const char *maildir,
                                 struct maildirsize *info,
-                                off_t msgsize, int nmsgs)
+                                int64_t msgsize, int nmsgs)
 {
 #if TRASHQUOTA
        return (0);
@@ -955,7 +955,7 @@ int maildir_quota_delundel_start(const char *maildir,
 }
 
 void maildir_quota_delundel_end(struct maildirsize *info,
-                               off_t msgsize, int nmsgs)
+                               int64_t msgsize, int nmsgs)
 {
 #if TRASHQUOTA
        return;
diff --git a/maildir/maildirquota.h b/maildir/maildirquota.h
index 9de9adf..1583279 100644
--- a/maildir/maildirquota.h
+++ b/maildir/maildirquota.h
@@ -28,7 +28,7 @@ static const char maildirquota_h_rcsid[]="$Id: 
maildirquota.h,v 1.9 2009/09/05 2
 #define        MDQUOTA_COUNT   'C'     /* Total number of messages in maildir 
*/
 
 struct maildirquota {
-       off_t nbytes;   /* # of bytes, 0 - unlimited */
+       int64_t nbytes; /* # of bytes, 0 - unlimited */
        int nmessages;  /* # of messages, 0 - unlimited */
 };
 
@@ -76,13 +76,13 @@ void maildir_closequotafile(struct maildirsize *info);
 
 
 int maildir_checkquota(struct maildirsize *, /* Opened maildir */
-                      off_t,  /* Extra bytes planning to add/remove from
+                      int64_t,  /* Extra bytes planning to add/remove from
                                 maildir */
                       int);  /* Extra messages planning to add/remove from
                                 maildir */
 
 int maildir_addquota(struct maildirsize *, /* Opened maildir */
-                    off_t,     /* +/- bytes */
+                    int64_t,   /* +/- bytes */
                     int);      /* +/- files */
 
 int maildir_readquota(struct maildirsize *);   /* Directory */
@@ -98,16 +98,16 @@ int maildir_parsequota(const char *, unsigned long *);
 
 int maildir_quota_add_start(const char *maildir,
                            struct maildirsize *info,
-                           off_t msgsize, int nmsgs,
+                           int64_t msgsize, int nmsgs,
                            const char *newquota);
 
 void maildir_quota_add_end(struct maildirsize *info,
-                          off_t msgsize, int nmsgs);
+                          int64_t msgsize, int nmsgs);
 
 /* When we're deleting messages, we want an unconditional quota update */
 
 void maildir_quota_deleted(const char *maildir,
-                          off_t nbytes,        /* Must be negative */
+                          int64_t nbytes,      /* Must be negative */
                           int nmsgs);  /* Must be negative */
 
 
@@ -118,10 +118,10 @@ void maildir_quota_deleted(const char *maildir,
 
 int maildir_quota_delundel_start(const char *maildir,
                                 struct maildirsize *info,
-                                off_t msgsize, int nmsgs);
+                                int64_t msgsize, int nmsgs);
 
 void maildir_quota_delundel_end(struct maildirsize *info,
-                               off_t msgsize, int nmsgs);
+                               int64_t msgsize, int nmsgs);
 
        /* Set a new quota on the maildir; */
 
diff --git a/numlib/config.h.in b/numlib/config.h.in
index 989b0da..2d4b822 100644
--- a/numlib/config.h.in
+++ b/numlib/config.h.in
@@ -61,6 +61,9 @@
 /* Define to `int' if <sys/types.h> doesn't define. */
 #undef gid_t
 
+/* default definition of int64_t */
+#undef int64_t
+
 /* Define to `int' if <sys/types.h> does not define. */
 #undef pid_t
 
diff --git a/numlib/configure b/numlib/configure
index f06c291..20ccf58 100755
diff --git a/numlib/configure.in b/numlib/configure.in
index 0c52a01..a45dee3 100644
--- a/numlib/configure.in
+++ b/numlib/configure.in
@@ -29,7 +29,12 @@ dnl Checks for libraries.
 
 dnl Checks for header files.
 
-AC_CHECK_HEADERS(unistd.h)
+AC_CHECK_HEADERS(unistd.h stdint.h)
+
+AC_CHECK_TYPE(int64_t, [ : ],
+                      [
+                      AC_DEFINE_UNQUOTED(int64_t,long long,[default definition 
of int64_t])
+                      ])
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_TYPE_UID_T
diff --git a/numlib/numlib.h b/numlib/numlib.h
index d356c6d..3eba884 100644
--- a/numlib/numlib.h
+++ b/numlib/numlib.h
@@ -16,6 +16,10 @@ static const char numlib_h_rcsid[]="$Id: numlib.h,v 1.10 
2004/01/11 02:47:33 mrs
 #include       "../numlib/config.h" /* VPATH build */
 #endif
 
+#if    HAVE_STDINT_H
+#include       <stdint.h>
+#endif
+
 #include       <sys/types.h>
 #include       <time.h>
 
@@ -25,6 +29,7 @@ static const char numlib_h_rcsid[]="$Id: numlib.h,v 1.10 
2004/01/11 02:47:33 mrs
 
 char   *libmail_str_time_t(time_t, char *);
 char   *libmail_str_off_t(off_t, char *);
+char   *libmail_str_int64_t(int64_t, char *);
 char   *libmail_str_pid_t(pid_t, char *);
 char   *libmail_str_dev_t(dev_t, char *);
 char   *libmail_str_ino_t(ino_t, char *);
diff --git a/numlib/strofft.c b/numlib/strofft.c
index d93edcb..99e8fbf 100644
--- a/numlib/strofft.c
+++ b/numlib/strofft.c
@@ -35,3 +35,31 @@ char *libmail_str_off_t(off_t t, char *arg)
 
        return (strcpy(arg, p));
 }
+
+char *libmail_str_int64_t(int64_t t, char *arg)
+{
+       char    buf[NUMBUFSIZE];
+       char    *p=buf+sizeof(buf)-1;
+       int     isneg=0;
+
+       if (t < 0)
+       {
+               t= -t;
+               isneg=1;
+       }
+
+       *p=0;
+       do
+       {
+               *--p= '0' + (t % 10);
+               t=t / 10;
+       } while(t);
+
+       if (isneg)
+               *--p='-';
+
+       return (strcpy(arg, p));
+}
+
+
+

Reply via email to