Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/bouyer-quota2]: src/usr.sbin/edquota Handle humanized numbers for -h/-s
details: https://anonhg.NetBSD.org/src/rev/b87dfe2fb5dd
branches: bouyer-quota2
changeset: 761087:b87dfe2fb5dd
user: bouyer <bouyer%NetBSD.org@localhost>
date: Sun Jan 30 12:38:32 2011 +0000
description:
Handle humanized numbers for -h/-s
diffstat:
usr.sbin/edquota/edquota.c | 29 +++++++++++++++++++----------
1 files changed, 19 insertions(+), 10 deletions(-)
diffs (71 lines):
diff -r 2cdf04d78798 -r b87dfe2fb5dd usr.sbin/edquota/edquota.c
--- a/usr.sbin/edquota/edquota.c Sun Jan 30 12:37:34 2011 +0000
+++ b/usr.sbin/edquota/edquota.c Sun Jan 30 12:38:32 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: edquota.c,v 1.29.16.1 2011/01/30 00:26:03 bouyer Exp $ */
+/* $NetBSD: edquota.c,v 1.29.16.2 2011/01/30 12:38:32 bouyer Exp $ */
/*
* Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "from: @(#)edquota.c 8.3 (Berkeley) 4/27/95";
#else
-__RCSID("$NetBSD: edquota.c,v 1.29.16.1 2011/01/30 00:26:03 bouyer Exp $");
+__RCSID("$NetBSD: edquota.c,v 1.29.16.2 2011/01/30 12:38:32 bouyer Exp $");
#endif
#endif /* not lint */
@@ -200,18 +200,29 @@
}
if (soft || hard) {
struct quotause *lqup;
- u_int32_t softb, hardb, softi, hardi;
+ u_int64_t softb, hardb, softi, hardi;
+ char *str;
if (tflag)
usage();
if (soft) {
- if (sscanf(soft, "%d/%d", &softb, &softi) != 2)
+ str = strsep(&soft, "/");
+ if (str[0] == '\0' || soft == NULL || soft[0] == '\0')
usage();
- softb = btodb((u_quad_t)softb * 1024);
+
+ if (intrd(str, &softb, HN_B) != 0)
+ errx(1, "%s: bad number", str);
+ if (intrd(soft, &softi, 0) != 0)
+ errx(1, "%s: bad number", soft);
}
if (hard) {
- if (sscanf(hard, "%d/%d", &hardb, &hardi) != 2)
+ str = strsep(&hard, "/");
+ if (str[0] == '\0' || hard == NULL || hard[0] == '\0')
usage();
- hardb = btodb((u_quad_t)hardb * 1024);
+
+ if (intrd(str, &hardb, HN_B) != 0)
+ errx(1, "%s: bad number", str);
+ if (intrd(hard, &hardi, 0) != 0)
+ errx(1, "%s: bad number", hard);
}
if (dflag) {
curprivs = getprivs(0, quotatype, fs, 1);
@@ -653,7 +664,7 @@
(void)lseek(outfd, (off_t)0, SEEK_SET);
if ((fd = fdopen(dup(outfd), "w")) == NULL)
errx(1, "fdopen `%s'", tmpfil);
- if (quplist->flags & DEFAULT) {
+ if (dflag) {
fprintf(fd, "Default %s quotas:\n", qfextension[quotatype]);
} else {
fprintf(fd, "Quotas for %s %s:\n",
@@ -776,8 +787,6 @@
for (qup = quplist; qup; qup = qup->next) {
if (strcmp(fsp, qup->fsname))
continue;
- printf("%" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 "\n",
- softb, hardb, softi, hardi);
if (strcmp(intprt(qup->q2e.q2e_val[Q2V_BLOCK].q2v_cur,
HN_NOSPACE | HN_B | HN_PRIV_UNLIMITED, Hflag),
scurb) != 0 ||
Home |
Main Index |
Thread Index |
Old Index