Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/quota Adjust the quota-fetching code to allow more t...
details: https://anonhg.NetBSD.org/src/rev/9dddd1eece91
branches: trunk
changeset: 771715:9dddd1eece91
user: dholland <dholland%NetBSD.org@localhost>
date: Wed Nov 30 16:12:32 2011 +0000
description:
Adjust the quota-fetching code to allow more than two object types.
(as far as we can so far, at least)
Note that quota won't actually work fully with multiple object types
as it is, but this and the last change are a good start and do fold
together a lot of duplicated code.
diffstat:
usr.bin/quota/quota.c | 30 +++++++++++++++++++++---------
1 files changed, 21 insertions(+), 9 deletions(-)
diffs (79 lines):
diff -r 081a65bff723 -r 9dddd1eece91 usr.bin/quota/quota.c
--- a/usr.bin/quota/quota.c Wed Nov 30 16:09:29 2011 +0000
+++ b/usr.bin/quota/quota.c Wed Nov 30 16:12:32 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: quota.c,v 1.42 2011/11/30 16:09:29 dholland Exp $ */
+/* $NetBSD: quota.c,v 1.43 2011/11/30 16:12:32 dholland 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.42 2011/11/30 16:09:29 dholland Exp $");
+__RCSID("$NetBSD: quota.c,v 1.43 2011/11/30 16:12:32 dholland Exp $");
#endif
#endif /* not lint */
@@ -80,7 +80,8 @@
struct quotause *next;
long flags;
uid_t id;
- struct quotaval qv[QUOTA_NLIMITS];
+ struct quotaval *qvs;
+ unsigned numqvs;
char fsname[MAXPATHLEN + 1];
};
#define FOUND 0x01
@@ -353,8 +354,8 @@
const char *msg;
int isquota2;
- qvs = qup->qv;
- numqvs = QUOTA_NLIMITS;
+ qvs = qup->qvs;
+ numqvs = qup->numqvs;
if (now == 0) {
time(&now);
@@ -399,7 +400,8 @@
isquota2 = (qup->flags & QUOTA2) != 0;
for (i=0; i<numqvs; i++) {
- printqv(&qvs[i], isquota2, isbytes[i], now);
+ printqv(&qvs[i], isquota2,
+ i >= QUOTA_NLIMITS ? 0 : isbytes[i], now);
}
printf("\n");
}
@@ -494,16 +496,26 @@
for (i = 0; i < nfst; i++) {
if (qup == NULL) {
if ((qup = malloc(sizeof *qup)) == NULL)
- err(1, "out of memory");
+ err(1, "Out of memory");
}
if (strncmp(fst[i].f_fstypename, "nfs",
sizeof(fst[i].f_fstypename)) == 0) {
version = 0;
+ qup->numqvs = QUOTA_NLIMITS;
+ qup->qvs = malloc(qup->numqvs * sizeof(qup->qvs[0]));
+ if (qup->qvs == NULL) {
+ err(1, "Out of memory");
+ }
if (getnfsquota(fst[i].f_mntfromname,
- qup->qv, id, ufs_quota_class_names[quotatype]) != 1)
+ qup->qvs, id, ufs_quota_class_names[quotatype]) != 1)
continue;
} else if ((fst[i].f_flag & ST_QUOTA) != 0) {
- if (getvfsquota(fst[i].f_mntonname, qup->qv, &version,
+ qup->numqvs = QUOTA_NLIMITS;
+ qup->qvs = malloc(qup->numqvs * sizeof(qup->qvs[0]));
+ if (qup->qvs == NULL) {
+ err(1, "Out of memory");
+ }
+ if (getvfsquota(fst[i].f_mntonname, qup->qvs, &version,
id, quotatype, dflag, Dflag) != 1)
continue;
} else
Home |
Main Index |
Thread Index |
Old Index