Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Explicitely cast to (u_quad_t) calls to btodb() and dbtob() ...
details: https://anonhg.NetBSD.org/src/rev/57d59226dd7d
branches: trunk
changeset: 479631:57d59226dd7d
user: bouyer <bouyer%NetBSD.org@localhost>
date: Thu Dec 16 17:29:52 1999 +0000
description:
Explicitely cast to (u_quad_t) calls to btodb() and dbtob() to avoid
int overflow. It's now possible to add/display quotas of more than
4G.
XXX I'm sure there is a PR open on this but I couln't find it with the
usual search engines. If someone knows it's number ...
diffstat:
usr.bin/quota/quota.c | 64 ++++++++++++++++++++++++---------------------
usr.sbin/edquota/edquota.c | 17 +++++++-----
2 files changed, 44 insertions(+), 37 deletions(-)
diffs (148 lines):
diff -r 04c90d99768d -r 57d59226dd7d usr.bin/quota/quota.c
--- a/usr.bin/quota/quota.c Thu Dec 16 17:15:48 1999 +0000
+++ b/usr.bin/quota/quota.c Thu Dec 16 17:29:52 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: quota.c,v 1.21 1998/08/25 20:59:39 ross Exp $ */
+/* $NetBSD: quota.c,v 1.22 1999/12/16 17:29:52 bouyer Exp $ */
/*
* Copyright (c) 1980, 1990, 1993
@@ -46,7 +46,7 @@
#if 0
static char sccsid[] = "@(#)quota.c 8.4 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: quota.c,v 1.21 1998/08/25 20:59:39 ross Exp $");
+__RCSID("$NetBSD: quota.c,v 1.22 1999/12/16 17:29:52 bouyer Exp $");
#endif
#endif /* not lint */
@@ -190,9 +190,9 @@
{
fprintf(stderr, "%s\n%s\n%s\n",
- "Usage: quota [-guqv]",
- "\tquota [-qv] -u username ...",
- "\tquota [-qv] -g groupname ...");
+ "Usage: quota [-guqv]",
+ "\tquota [-qv] -u username ...",
+ "\tquota [-qv] -g groupname ...");
exit(1);
}
@@ -350,7 +350,8 @@
>= qup->dqblk.dqb_bsoftlimit) {
if (qup->dqblk.dqb_btime > now)
msgb = "In block grace period on";
- else msgb = "Over block quota on";
+ else
+ msgb = "Over block quota on";
}
}
if (qflag) {
@@ -373,21 +374,24 @@
printf("%s\n", qup->fsname);
nam = "";
}
- printf("%15s%8d%c%7d%8d%8s"
- , nam
- , dbtob(qup->dqblk.dqb_curblocks) / 1024
- , (msgb == (char *)0) ? ' ' : '*'
- , dbtob(qup->dqblk.dqb_bsoftlimit) / 1024
- , dbtob(qup->dqblk.dqb_bhardlimit) / 1024
- , (msgb == (char *)0) ? ""
- : timeprt(qup->dqblk.dqb_btime));
+ printf("%12s%9d%c%8d%9d%8s"
+ , nam
+ , (int)(dbtob((u_quad_t)qup->dqblk.dqb_curblocks)
+ / 1024)
+ , (msgb == (char *)0) ? ' ' : '*'
+ , (int)(dbtob((u_quad_t)qup->dqblk.dqb_bsoftlimit)
+ / 1024)
+ , (int)(dbtob((u_quad_t)qup->dqblk.dqb_bhardlimit)
+ / 1024)
+ , (msgb == (char *)0) ? ""
+ : timeprt(qup->dqblk.dqb_btime));
printf("%8d%c%7d%8d%8s\n"
- , qup->dqblk.dqb_curinodes
- , (msgi == (char *)0) ? ' ' : '*'
- , qup->dqblk.dqb_isoftlimit
- , qup->dqblk.dqb_ihardlimit
- , (msgi == (char *)0) ? ""
- : timeprt(qup->dqblk.dqb_itime)
+ , qup->dqblk.dqb_curinodes
+ , (msgi == (char *)0) ? ' ' : '*'
+ , qup->dqblk.dqb_isoftlimit
+ , qup->dqblk.dqb_ihardlimit
+ , (msgi == (char *)0) ? ""
+ : timeprt(qup->dqblk.dqb_itime)
);
continue;
}
@@ -406,16 +410,16 @@
printf("Disk quotas for %s %s (%cid %ld): %s\n", qfextension[type],
name, *qfextension[type], (u_long)id, tag);
if (!qflag && tag[0] == '\0') {
- printf("%15s%8s %7s%8s%8s%8s %7s%8s%8s\n"
- , "Filesystem"
- , "blocks"
- , "quota"
- , "limit"
- , "grace"
- , "files"
- , "quota"
- , "limit"
- , "grace"
+ printf("%12s%9s %8s%9s%8s%8s %7s%8s%8s\n"
+ , "Filesystem"
+ , "blocks"
+ , "quota"
+ , "limit"
+ , "grace"
+ , "files"
+ , "quota"
+ , "limit"
+ , "grace"
);
}
}
diff -r 04c90d99768d -r 57d59226dd7d usr.sbin/edquota/edquota.c
--- a/usr.sbin/edquota/edquota.c Thu Dec 16 17:15:48 1999 +0000
+++ b/usr.sbin/edquota/edquota.c Thu Dec 16 17:29:52 1999 +0000
@@ -44,7 +44,7 @@
#if 0
static char sccsid[] = "from: @(#)edquota.c 8.3 (Berkeley) 4/27/95";
#else
-__RCSID("$NetBSD: edquota.c,v 1.18 1999/08/16 03:12:31 simonb Exp $");
+__RCSID("$NetBSD: edquota.c,v 1.19 1999/12/16 17:29:53 bouyer Exp $");
#endif
#endif /* not lint */
@@ -405,9 +405,9 @@
for (qup = quplist; qup; qup = qup->next) {
fprintf(fd, "%s: %s %d, limits (soft = %d, hard = %d)\n",
qup->fsname, "blocks in use:",
- dbtob(qup->dqblk.dqb_curblocks) / 1024,
- dbtob(qup->dqblk.dqb_bsoftlimit) / 1024,
- dbtob(qup->dqblk.dqb_bhardlimit) / 1024);
+ (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));
fprintf(fd, "%s %d, limits (soft = %d, hard = %d)\n",
"\tinodes in use:", qup->dqblk.dqb_curinodes,
qup->dqblk.dqb_isoftlimit, qup->dqblk.dqb_ihardlimit);
@@ -460,9 +460,12 @@
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 = btodb((u_quad_t)
+ dqblk.dqb_curblocks * 1024);
+ dqblk.dqb_bsoftlimit = btodb((u_quad_t)
+ dqblk.dqb_bsoftlimit * 1024);
+ dqblk.dqb_bhardlimit = btodb((u_quad_t)
+ dqblk.dqb_bhardlimit * 1024);
if ((cp = strtok(line2, "\n")) == NULL) {
warnx("%s: %s: bad format", fsp, line2);
return (0);
Home |
Main Index |
Thread Index |
Old Index