[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

quotas over 4G, patch for edquota + repquota



Hi,
I sent the following patch as a follow-up to a bugreport (system/1534)
to the developer who originally answered the bugreport, but I haven't
gotten a response yet.  So now it's at least in the mailing list
archives. (I remember spending 2 days looking for a solution on MLs and
such when I first met the problem under Linux because I couldn't believe
there really was no fix for this yet). And I don't think quotas over 4G
are very uncommon nowadays.

the problem is simply that the number of blocks are converted to bytes,
where they overflow, and only after this they are converted back to
kilobytes. Also replaced %d with %lu in the printf format strings.

also, maybe dbtokb should be incorporated into some system header file,
since it's already used in both edquota and repquota. 

the diff to the cvs versions of edquota and repquota is attached. It's
possible that there are more quota tools that need to be fixed.


Index: edquota/edquota.c
===================================================================
RCS file: /cvs/src/usr.sbin/edquota/edquota.c,v
retrieving revision 1.25
diff -u -r1.25 edquota.c
--- edquota/edquota.c	2000/12/21 09:48:05	1.25
+++ edquota/edquota.c	2001/01/12 19:37:16
@@ -66,6 +66,12 @@
 #include <unistd.h>
 #include "pathnames.h"
 
+#if DEV_BSHIFT < 10
+#define dbtokb(x) ((x) >> (10 - DEV_BSHIFT))
+#else
+#define dbtokb(x) ((x) << (DEV_BSHIFT - 10))
+#endif
+
 char *qfname = QUOTAFILENAME;
 char *qfextension[] = INITQFNAMES;
 char *quotagroup = QUOTAGROUP;
@@ -431,12 +437,12 @@
 		err(1, "%s", tmpfil);
 	(void)fprintf(fd, "Quotas for %s %s:\n", qfextension[quotatype], name);
 	for (qup = quplist; qup; qup = qup->next) {
-		(void)fprintf(fd, "%s: %s %d, limits (soft = %d, hard = %d)\n",
+		(void)fprintf(fd, "%s: %s %lu, limits (soft = %lu, hard = %lu)\n",
 		    qup->fsname, "blocks in use:",
-		    (int)(dbtob((u_quad_t)qup->dqblk.dqb_curblocks) / 1024),
-		    (int)(dbtob((u_quad_t)qup->dqblk.dqb_bsoftlimit) / 1024),
-		    (int)(dbtob((u_quad_t)qup->dqblk.dqb_bhardlimit) / 1024));
-		(void)fprintf(fd, "%s %d, limits (soft = %d, hard = %d)\n",
+		    (int)(dbtokb((u_quad_t)qup->dqblk.dqb_curblocks)),
+		    (int)(dbtokb((u_quad_t)qup->dqblk.dqb_bsoftlimit)),
+		    (int)(dbtokb((u_quad_t)qup->dqblk.dqb_bhardlimit)));
+		(void)fprintf(fd, "%s %lu, limits (soft = %lu, hard = %lu)\n",
 		    "\tinodes in use:", qup->dqblk.dqb_curinodes,
 		    qup->dqblk.dqb_isoftlimit, qup->dqblk.dqb_ihardlimit);
 	}
Index: repquota/repquota.c
===================================================================
RCS file: /cvs/src/usr.sbin/repquota/repquota.c,v
retrieving revision 1.12
diff -u -r1.12 repquota.c
--- repquota/repquota.c	2000/12/21 09:50:00	1.12
+++ repquota/repquota.c	2001/01/12 19:37:16
@@ -59,6 +59,12 @@
 #include <string.h>
 #include <errno.h>
 
+#if DEV_BSHIFT < 10
+#define dbtokb(x) ((x) >> (10 - DEV_BSHIFT))
+#else
+#define dbtokb(x) ((x) << (DEV_BSHIFT - 10))
+#endif
+
 char *qfname = QUOTAFILENAME;
 char *qfextension[] = INITQFNAMES;
 
@@ -226,19 +232,16 @@
 		    fup->fu_dqblk.dqb_curblocks == 0)
 			continue;
 		printf("%-10s", fup->fu_name);
-		printf("%c%c%8d%8d%8d%7s",
+		printf("%c%c%8lu%8lu%8lu%7s",
 			fup->fu_dqblk.dqb_bsoftlimit && 
 			    fup->fu_dqblk.dqb_curblocks >= 
 			    fup->fu_dqblk.dqb_bsoftlimit ? '+' : '-',
 			fup->fu_dqblk.dqb_isoftlimit &&
 			    fup->fu_dqblk.dqb_curinodes >=
 			    fup->fu_dqblk.dqb_isoftlimit ? '+' : '-',
-			(int)(dbtob((u_quad_t)fup->fu_dqblk.dqb_curblocks)
-			    / 1024),
-			(int)(dbtob((u_quad_t)fup->fu_dqblk.dqb_bsoftlimit)
-			    / 1024),
-			(int)(dbtob((u_quad_t)fup->fu_dqblk.dqb_bhardlimit)
-			    / 1024),
+			(int)(dbtokb((u_quad_t)fup->fu_dqblk.dqb_curblocks)),
+			(int)(dbtokb((u_quad_t)fup->fu_dqblk.dqb_bsoftlimit)),
+			(int)(dbtokb((u_quad_t)fup->fu_dqblk.dqb_bhardlimit)),
 			fup->fu_dqblk.dqb_bsoftlimit && 
 			    fup->fu_dqblk.dqb_curblocks >= 
 			    fup->fu_dqblk.dqb_bsoftlimit ?

Visit your host, monkey.org