Date: Tue, 6 Oct 1998 13:08:46 +0200 (CEST) From: tobez@plab.ku.dk To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: bin/8163: edquota bug with large quota sizes Message-ID: <199810061108.NAA20929@lion.plab.ku.dk>
next in thread | raw e-mail | index | archive | help
>Number: 8163 >Category: bin >Synopsis: It is impossible to assign quotas larger than 4Gbytes using edquota >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Oct 6 04:10:02 PDT 1998 >Last-Modified: >Originator: Anton Berezin >Organization: The Protein Laboratory, University of Copenhagen >Release: FreeBSD 2.2.7-RELEASE i386 >Environment: "$Id: edquota.c,v 1.4.2.4 1998/03/09 13:50:51 jkh Exp $" >Description: While trying to assign quota limits to a value greater than 4Gbytes (4194304 kbytes) edquota does not report any problems and finishes successfully; however, actually assigned limits get wrapped modulo 4Gbytes. >How-To-Repeat: Try to assign, say, hard limit to 5242880, save & exit. Run edquota again for the same user. The assigned quota will be 1048576. >Fix: --- edquota.c.orig Mon Oct 5 20:08:24 1998 +++ edquota.c Mon Oct 5 20:52:02 1998 @@ -69,6 +69,25 @@ #include <unistd.h> #include "pathnames.h" +/* Let's be paranoid about block size */ +#if 10 > DEV_BSHIFT +#define kbtodb(kbytes) \ + ((daddr_t)((unsigned long)(kbytes) << (10-DEV_BSHIFT))) + +#define dbtokb(db) \ + ((off_t)(db) >> (10-DEV_BSHIFT)) +#elif 10 < DEV_BSHIFT +#define kbtodb(kbytes) \ + ((daddr_t)((unsigned long)(kbytes) >> (DEV_BSHIFT-10))) + +#define dbtokb(db) \ + ((off_t)(db) << (DEV_BSHIFT-10)) +#else +#define kbtodb(kbytes) (kbytes) +#define dbtokb(db) (db) +#endif + + char *qfname = QUOTAFILENAME; char *qfextension[] = INITQFNAMES; char *quotagroup = QUOTAGROUP; @@ -416,9 +435,9 @@ for (qup = quplist; qup; qup = qup->next) { fprintf(fd, "%s: %s %lu, limits (soft = %lu, hard = %lu)\n", qup->fsname, "blocks in use:", - (unsigned long)(dbtob(qup->dqblk.dqb_curblocks) / 1024), - (unsigned long)(dbtob(qup->dqblk.dqb_bsoftlimit) / 1024), - (unsigned long)(dbtob(qup->dqblk.dqb_bhardlimit) / 1024)); + (unsigned long)(dbtokb(qup->dqblk.dqb_curblocks)), + (unsigned long)(dbtokb(qup->dqblk.dqb_bsoftlimit)), + (unsigned long)(dbtokb(qup->dqblk.dqb_bhardlimit))); 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); @@ -469,9 +488,9 @@ warnx("%s:%s: bad format", fsp, cp); return (0); } - dqblk.dqb_curblocks = btodb(dqblk.dqb_curblocks * 1024); - dqblk.dqb_bsoftlimit = btodb(dqblk.dqb_bsoftlimit * 1024); - dqblk.dqb_bhardlimit = btodb(dqblk.dqb_bhardlimit * 1024); + dqblk.dqb_curblocks = kbtodb(dqblk.dqb_curblocks); + dqblk.dqb_bsoftlimit = kbtodb(dqblk.dqb_bsoftlimit); + dqblk.dqb_bhardlimit = kbtodb(dqblk.dqb_bhardlimit); if ((cp = strtok(line2, "\n")) == NULL) { warnx("%s: %s: bad format", fsp, line2); return (0); >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199810061108.NAA20929>