CVS commit: [bouyer-quota2] src/usr.bin/quota
Module Name:src Committed By: bouyer Date: Mon Feb 14 20:38:57 UTC 2011 Modified Files: src/usr.bin/quota [bouyer-quota2]: quota.c Log Message: With quota2 semantic, we may be overquota even if usage is 0. Print quota in default output in this case. To generate a diff of this commit: cvs rdiff -u -r1.33.2.8 -r1.33.2.9 src/usr.bin/quota/quota.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/quota/quota.c diff -u src/usr.bin/quota/quota.c:1.33.2.8 src/usr.bin/quota/quota.c:1.33.2.9 --- src/usr.bin/quota/quota.c:1.33.2.8 Mon Feb 14 20:35:24 2011 +++ src/usr.bin/quota/quota.c Mon Feb 14 20:38:56 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: quota.c,v 1.33.2.8 2011/02/14 20:35:24 bouyer Exp $ */ +/* $NetBSD: quota.c,v 1.33.2.9 2011/02/14 20:38:56 bouyer Exp $ */ /* * Copyright (c) 1980, 1990, 1993 @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)quota.c 8.4 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: quota.c,v 1.33.2.8 2011/02/14 20:35:24 bouyer Exp $"); +__RCSID("$NetBSD: quota.c,v 1.33.2.9 2011/02/14 20:38:56 bouyer Exp $"); #endif #endif /* not lint */ @@ -393,7 +393,7 @@ printf("\t%s %s\n", msgb, qup->fsname); continue; } - if (vflag || dflag || + if (vflag || dflag || msgi || msgb || qup->q2e.q2e_val[QL_BLOCK].q2v_cur || qup->q2e.q2e_val[QL_FILE].q2v_cur) { if (lines++ == 0)
CVS commit: [bouyer-quota2] src/usr.bin/quota
Module Name:src Committed By: bouyer Date: Wed Feb 9 10:21:36 UTC 2011 Modified Files: src/usr.bin/quota [bouyer-quota2]: getvfsquota.c Log Message: Use prop_array_add_and_rel() To generate a diff of this commit: cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/usr.bin/quota/getvfsquota.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/quota/getvfsquota.c diff -u src/usr.bin/quota/getvfsquota.c:1.1.2.2 src/usr.bin/quota/getvfsquota.c:1.1.2.3 --- src/usr.bin/quota/getvfsquota.c:1.1.2.2 Sun Jan 30 19:38:45 2011 +++ src/usr.bin/quota/getvfsquota.c Wed Feb 9 10:21:36 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: getvfsquota.c,v 1.1.2.2 2011/01/30 19:38:45 bouyer Exp $ */ +/* $NetBSD: getvfsquota.c,v 1.1.2.3 2011/02/09 10:21:36 bouyer Exp $ */ /*- * Copyright (c) 2011 Manuel Bouyer @@ -29,7 +29,7 @@ */ #include -__RCSID("$NetBSD: getvfsquota.c,v 1.1.2.2 2011/01/30 19:38:45 bouyer Exp $"); +__RCSID("$NetBSD: getvfsquota.c,v 1.1.2.3 2011/02/09 10:21:36 bouyer Exp $"); #include #include @@ -75,9 +75,8 @@ if (!ret) err(1, "prop_dictionary_set(id)"); - if (!prop_array_add(datas, data)) + if (!prop_array_add_and_rel(datas, data)) err(1, "prop_array_add(data)"); - prop_object_release(data); if (!quota2_prop_add_command(cmds, "get", qfextension[type], datas)) err(1, "prop_add_command"); if (!quota2_prop_add_command(cmds, "get version", qfextension[type],
CVS commit: [bouyer-quota2] src/usr.bin/quota
Module Name:src Committed By: bouyer Date: Sun Jan 30 21:37:39 UTC 2011 Modified Files: src/usr.bin/quota [bouyer-quota2]: printquota.c printquota.h Log Message: Revert to previous format for timeprt, which is less precise but more user-friendly. Introduce timepprt for cases where we want human-readable but precise time display. To generate a diff of this commit: cvs rdiff -u -r1.1.2.5 -r1.1.2.6 src/usr.bin/quota/printquota.c \ src/usr.bin/quota/printquota.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/quota/printquota.c diff -u src/usr.bin/quota/printquota.c:1.1.2.5 src/usr.bin/quota/printquota.c:1.1.2.6 --- src/usr.bin/quota/printquota.c:1.1.2.5 Sun Jan 30 20:54:22 2011 +++ src/usr.bin/quota/printquota.c Sun Jan 30 21:37:39 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: printquota.c,v 1.1.2.5 2011/01/30 20:54:22 bouyer Exp $ */ +/* $NetBSD: printquota.c,v 1.1.2.6 2011/01/30 21:37:39 bouyer Exp $ */ /* * Copyright (c) 1980, 1990, 1993 @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)quota.c 8.4 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: printquota.c,v 1.1.2.5 2011/01/30 20:54:22 bouyer Exp $"); +__RCSID("$NetBSD: printquota.c,v 1.1.2.6 2011/01/30 21:37:39 bouyer Exp $"); #endif #endif /* not lint */ @@ -95,16 +95,64 @@ } /* - * Calculate the grace period and return a printable string for it. + * Calculate the grace period and return a user-friendly string for it. */ -const char * -timeprt(time_t now, time_t seconds, int space) -{ #define MINUTE 60 #define HOUR (MINUTE * 60) #define DAY (HOUR * 24) #define WEEK (DAY * 7) +#define MONTH (DAY * 30) +#define YEAR (DAY * 355) + +const char * +timeprt(time_t now, time_t seconds, int space) +{ + time_t years, months, weeks, days, hours, minutes; + static char buf[20]; + + if (now > seconds) + return ("none"); + + seconds -= now; + + minutes = (seconds + MINUTE / 2) / MINUTE; + hours = (seconds + HOUR / 2) / HOUR; + days = (seconds + DAY / 2) / DAY; + years = (seconds + YEAR / 2) / YEAR; + months = (seconds + MONTH / 2) / MONTH; + weeks = (seconds + WEEK / 2) / WEEK; + + if (years >= 2) { + (void)snprintf(buf, space+1, "%" PRId64 "years", years); + return buf; + } + if (weeks > 9) { + (void)snprintf(buf, space+1, "%" PRId64 "months", months); + return buf; + } + if (days > 9) { + (void)snprintf(buf, space+1, "%" PRId64 "weeks", weeks); + return buf; + } + if (hours > 36) { + (void)snprintf(buf, space+1, "%" PRId64 "days", days); + return buf; + } + if (minutes > 60) { + (void)snprintf(buf, space+1, "%2d:%d", + (int)(minutes / 60), (int)(minutes % 60)); + return buf; + } + (void)snprintf(buf, sizeof buf, "%2d", (int)minutes); + return buf; +} +/* + * Calculate the grace period and return a precise string for it. + */ +const char * +timepprt(time_t now, time_t seconds, int space) +{ static char buf[20], *append; int i, remain = space + 1; Index: src/usr.bin/quota/printquota.h diff -u src/usr.bin/quota/printquota.h:1.1.2.5 src/usr.bin/quota/printquota.h:1.1.2.6 --- src/usr.bin/quota/printquota.h:1.1.2.5 Sun Jan 30 20:54:22 2011 +++ src/usr.bin/quota/printquota.h Sun Jan 30 21:37:39 2011 @@ -1,6 +1,7 @@ -/* $NetBSD: printquota.h,v 1.1.2.5 2011/01/30 20:54:22 bouyer Exp $ */ +/* $NetBSD: printquota.h,v 1.1.2.6 2011/01/30 21:37:39 bouyer Exp $ */ const char *intprt(uint64_t, u_int, int, int); const char *timeprt(time_t, time_t, int space); +const char *timepprt(time_t, time_t, int space); int intrd(char *str, uint64_t *val, u_int);
CVS commit: [bouyer-quota2] src/usr.bin/quota
Module Name:src Committed By: bouyer Date: Sun Jan 30 00:21:08 UTC 2011 Modified Files: src/usr.bin/quota [bouyer-quota2]: printquota.c Log Message: intprt() can be called up to 3 times for a single printf(); make sure to return 3 different static buffers in such a case. To generate a diff of this commit: cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/usr.bin/quota/printquota.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/quota/printquota.c diff -u src/usr.bin/quota/printquota.c:1.1.2.2 src/usr.bin/quota/printquota.c:1.1.2.3 --- src/usr.bin/quota/printquota.c:1.1.2.2 Sat Jan 29 17:42:37 2011 +++ src/usr.bin/quota/printquota.c Sun Jan 30 00:21:08 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: printquota.c,v 1.1.2.2 2011/01/29 17:42:37 bouyer Exp $ */ +/* $NetBSD: printquota.c,v 1.1.2.3 2011/01/30 00:21:08 bouyer Exp $ */ /* * Copyright (c) 1980, 1990, 1993 @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)quota.c 8.4 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: printquota.c,v 1.1.2.2 2011/01/29 17:42:37 bouyer Exp $"); +__RCSID("$NetBSD: printquota.c,v 1.1.2.3 2011/01/30 00:21:08 bouyer Exp $"); #endif #endif /* not lint */ @@ -67,8 +67,15 @@ const char * intprt(uint64_t val, u_int flags, int hflag) { - static char buf[21]; - +#define NBUFS 3 + static char bufs[NBUFS][21]; + char *buf; + static int i = 0; + + buf = bufs[i++]; + if (i == NBUFS) + i = 0; +#undef NBUFS if (val == UQUAD_MAX) return((flags & HN_PRIV_UNLIMITED) ? "unlimited" : "-");
CVS commit: [bouyer-quota2] src/usr.bin/quota
Module Name:src Committed By: bouyer Date: Sat Jan 29 17:42:38 UTC 2011 Modified Files: src/usr.bin/quota [bouyer-quota2]: printquota.c printquota.h Log Message: Allow to pass HN_PRIV_UNLIMITED flag (private to printquota consumers), which cause it to return "unlimited" instead of "-" of UQUAD_MAX. Introduce intrd(), which parses a string and return a value appropriate for quota limits. The string can be a decimal number, a value in understandable by dehumanize_number(), "-" or "unlimited". To generate a diff of this commit: cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/usr.bin/quota/printquota.c cvs rdiff -u -r1.1.2.2 -r1.1.2.3 src/usr.bin/quota/printquota.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/quota/printquota.c diff -u src/usr.bin/quota/printquota.c:1.1.2.1 src/usr.bin/quota/printquota.c:1.1.2.2 --- src/usr.bin/quota/printquota.c:1.1.2.1 Fri Jan 21 16:58:06 2011 +++ src/usr.bin/quota/printquota.c Sat Jan 29 17:42:37 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: printquota.c,v 1.1.2.1 2011/01/21 16:58:06 bouyer Exp $ */ +/* $NetBSD: printquota.c,v 1.1.2.2 2011/01/29 17:42:37 bouyer Exp $ */ /* * Copyright (c) 1980, 1990, 1993 @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)quota.c 8.4 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: printquota.c,v 1.1.2.1 2011/01/21 16:58:06 bouyer Exp $"); +__RCSID("$NetBSD: printquota.c,v 1.1.2.2 2011/01/29 17:42:37 bouyer Exp $"); #endif #endif /* not lint */ @@ -55,6 +55,9 @@ #include #include #include +#include +#include +#include #include @@ -62,12 +65,14 @@ * convert 64bit value to a printable string */ const char * -intprt(uint64_t val, int flags, int hflag) +intprt(uint64_t val, u_int flags, int hflag) { static char buf[21]; if (val == UQUAD_MAX) - return("-"); + return((flags & HN_PRIV_UNLIMITED) ? "unlimited" : "-"); + + flags &= ~HN_PRIV_UNLIMITED; if (flags & HN_B) val = dbtob(val); @@ -114,3 +119,37 @@ (void)snprintf(buf, sizeof buf, "%2d", (int)minutes); return (buf); } + +/* + * convert a string to a uint64 value + */ +int +intrd(char *str, uint64_t *val, u_int flags) +{ + char *last = &str[strlen(str) - 1]; + int ret; + + if (*last >= '0' && *last <= '9') { + /* no unit provided, use default */ + errno = 0; + *val = strtoumax(str, NULL, 10); + if (flags & HN_B) { + /* in kb, convert to disk blocks */ + *val = btodb(*val * 1024); + } + + return errno; + } + if (strcmp(str, "-") == 0 || strcmp(str, "unlimited") == 0) { + *val = UQUAD_MAX; + return 0; + } + if (flags & HN_B) { + if (*last == 'B' || *last == 'b') + *last = '\0'; + } + ret = dehumanize_number(str, (int64_t *)val); + if (flags & HN_B) + *val = btodb(*val); + return ret; +} Index: src/usr.bin/quota/printquota.h diff -u src/usr.bin/quota/printquota.h:1.1.2.2 src/usr.bin/quota/printquota.h:1.1.2.3 --- src/usr.bin/quota/printquota.h:1.1.2.2 Fri Jan 28 22:15:36 2011 +++ src/usr.bin/quota/printquota.h Sat Jan 29 17:42:37 2011 @@ -1,4 +1,7 @@ -/* $NetBSD: printquota.h,v 1.1.2.2 2011/01/28 22:15:36 bouyer Exp $ */ +/* $NetBSD: printquota.h,v 1.1.2.3 2011/01/29 17:42:37 bouyer Exp $ */ -const char *intprt(uint64_t, int, int); +const char *intprt(uint64_t, u_int, int); +#define HN_PRIV_UNLIMITED 0x8000 /* print "unlimited" instead of "-" */ const char *timeprt(time_t); +int intrd(char *str, uint64_t *val, u_int); +
CVS commit: [bouyer-quota2] src/usr.bin/quota
Module Name:src Committed By: bouyer Date: Fri Jan 21 16:36:57 UTC 2011 Modified Files: src/usr.bin/quota [bouyer-quota2]: quota.1 Log Message: Remove FILES section, it's obsolete To generate a diff of this commit: cvs rdiff -u -r1.14.52.1 -r1.14.52.2 src/usr.bin/quota/quota.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/quota/quota.1 diff -u src/usr.bin/quota/quota.1:1.14.52.1 src/usr.bin/quota/quota.1:1.14.52.2 --- src/usr.bin/quota/quota.1:1.14.52.1 Thu Jan 20 14:25:05 2011 +++ src/usr.bin/quota/quota.1 Fri Jan 21 16:36:57 2011 @@ -1,4 +1,4 @@ -.\" $NetBSD: quota.1,v 1.14.52.1 2011/01/20 14:25:05 bouyer Exp $ +.\" $NetBSD: quota.1,v 1.14.52.2 2011/01/21 16:36:57 bouyer Exp $ .\" .\" Copyright (c) 1983, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -135,14 +135,6 @@ .Nm exits with a non-zero status, one or more filesystems are over quota. -.Sh FILES -.Bl -tag -width quota.group -compact -.It Pa quota.user -located at the filesystem root with user quotas -.It Pa quota.group -located at the filesystem root with group quotas -.It Pa /etc/fstab -to find filesystem names and locations .El .Sh SEE ALSO .Xr quotactl 2 ,