From owner-freebsd-bugs Tue Oct 6 04:10:11 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id EAA25799 for freebsd-bugs-outgoing; Tue, 6 Oct 1998 04:10:11 -0700 (PDT) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id EAA25711 for ; Tue, 6 Oct 1998 04:10:05 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id EAA25832; Tue, 6 Oct 1998 04:10:04 -0700 (PDT) Received: from lion.plab.ku.dk (lion.plab.ku.dk [130.225.105.49]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id EAA25530 for ; Tue, 6 Oct 1998 04:08:59 -0700 (PDT) (envelope-from tobez@lion.plab.ku.dk) Received: (from tobez@localhost) by lion.plab.ku.dk (8.8.8/8.8.8) id NAA20929; Tue, 6 Oct 1998 13:08:46 +0200 (CEST) (envelope-from tobez) Message-Id: <199810061108.NAA20929@lion.plab.ku.dk> Date: Tue, 6 Oct 1998 13:08:46 +0200 (CEST) From: tobez@plab.ku.dk Reply-To: tobez@plab.ku.dk To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: bin/8163: edquota bug with large quota sizes Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >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 #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