Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/edquota Don't use the old getvfsquota() here.
details: https://anonhg.NetBSD.org/src/rev/f1fb70ad182f
branches: trunk
changeset: 773301:f1fb70ad182f
user: dholland <dholland%NetBSD.org@localhost>
date: Mon Jan 30 19:16:36 2012 +0000
description:
Don't use the old getvfsquota() here.
diffstat:
usr.sbin/edquota/Makefile | 4 +-
usr.sbin/edquota/edquota.c | 95 +++++++++++++++++++++++++++++++--------------
2 files changed, 68 insertions(+), 31 deletions(-)
diffs (221 lines):
diff -r 88a2b8204798 -r f1fb70ad182f usr.sbin/edquota/Makefile
--- a/usr.sbin/edquota/Makefile Mon Jan 30 18:50:45 2012 +0000
+++ b/usr.sbin/edquota/Makefile Mon Jan 30 19:16:36 2012 +0000
@@ -1,5 +1,5 @@
# from: @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $NetBSD: Makefile,v 1.8 2011/03/24 17:05:47 bouyer Exp $
+# $NetBSD: Makefile,v 1.9 2012/01/30 19:16:36 dholland Exp $
.include <bsd.own.mk>
@@ -13,7 +13,7 @@
LDADD= -lquota -lprop -lrpcsvc
.PATH: ${NETBSDSRCDIR}/usr.bin/quota
-SRCS+= getvfsquota.c printquota.c quotautil.c
+SRCS+= printquota.c quotautil.c
.PATH: ${NETBSDSRCDIR}/sys/ufs/ufs
SRCS+= quota1_subr.c
diff -r 88a2b8204798 -r f1fb70ad182f usr.sbin/edquota/edquota.c
--- a/usr.sbin/edquota/edquota.c Mon Jan 30 18:50:45 2012 +0000
+++ b/usr.sbin/edquota/edquota.c Mon Jan 30 19:16:36 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: edquota.c,v 1.43 2012/01/29 07:16:00 dholland Exp $ */
+/* $NetBSD: edquota.c,v 1.44 2012/01/30 19:16:36 dholland Exp $ */
/*
* Copyright (c) 1980, 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "from: @(#)edquota.c 8.3 (Berkeley) 4/27/95";
#else
-__RCSID("$NetBSD: edquota.c,v 1.43 2012/01/29 07:16:00 dholland Exp $");
+__RCSID("$NetBSD: edquota.c,v 1.44 2012/01/30 19:16:36 dholland Exp $");
#endif
#endif /* not lint */
@@ -60,7 +60,6 @@
#include <quota/quotaprop.h>
#include <quota/quota.h>
#include <ufs/ufs/quota1.h>
-#include <sys/quota.h>
#include <assert.h>
#include <err.h>
@@ -77,7 +76,6 @@
#include <unistd.h>
#include "printquota.h"
-#include "getvfsquota.h"
#include "quotautil.h"
#include "pathnames.h"
@@ -88,7 +86,7 @@
/* flags for quotause */
#define FOUND 0x01
-#define QUOTA2 0x02
+#define XGRACE 0x02 /* extended grace periods (per-id) */
#define DEFAULT 0x04
struct quotause {
@@ -96,6 +94,7 @@
long flags;
struct quotaval qv[QUOTA_NLIMITS];
char fsname[MAXPATHLEN + 1];
+ char implementation[32];
char *qfname;
};
@@ -107,7 +106,6 @@
static void usage(void) __dead;
static int Hflag = 0;
-static int Dflag = 0;
/* more compact form of constants */
#define QL_BLK QUOTA_LIMIT_BLOCK
@@ -338,27 +336,69 @@
////////////////////////////////////////////////////////////
// ffs quota v2
+static int
+dogetprivs2(struct quotahandle *qh, int idtype, id_t id, int defaultq,
+ int objtype, struct quotause *qup)
+{
+ struct quotakey qk;
+
+ qk.qk_idtype = idtype;
+ qk.qk_id = defaultq ? QUOTA_DEFAULTID : id;
+ qk.qk_objtype = objtype;
+ if (quota_get(qh, &qk, &qup->qv[objtype])) {
+ /* no entry, get default entry */
+ qk.qk_id = QUOTA_DEFAULTID;
+ if (quota_get(qh, &qk, &qup->qv[objtype])) {
+ return -1;
+ }
+ }
+ return 0;
+}
+
static struct quotause *
getprivs2(long id, int idtype, const char *filesys, int defaultq)
{
struct quotause *qup;
- int8_t version;
+ struct quotahandle *qh;
+ const char *impl;
+ unsigned restrictions;
qup = quotause_create();
strcpy(qup->fsname, filesys);
if (defaultq)
qup->flags |= DEFAULT;
- if (!getvfsquota(filesys, qup->qv, &version,
- id, idtype, defaultq, Dflag)) {
- /* no entry, get default entry */
- if (!getvfsquota(filesys, qup->qv, &version,
- id, idtype, 1, Dflag)) {
- free(qup);
- return NULL;
- }
+
+ qh = quota_open(filesys);
+ if (qh == NULL) {
+ quotause_destroy(qup);
+ return NULL;
+ }
+
+ impl = quota_getimplname(qh);
+ if (impl == NULL) {
+ impl = "???";
}
- if (version == 2)
- qup->flags |= QUOTA2;
+ strlcpy(qup->implementation, impl, sizeof(qup->implementation));
+
+ restrictions = quota_getrestrictions(qh);
+ if ((restrictions & QUOTA_RESTRICT_UNIFORMGRACE) == 0) {
+ qup->flags |= XGRACE;
+ }
+
+ if (dogetprivs2(qh, idtype, id, defaultq, QUOTA_OBJTYPE_BLOCKS, qup)) {
+ quota_close(qh);
+ quotause_destroy(qup);
+ return NULL;
+ }
+
+ if (dogetprivs2(qh, idtype, id, defaultq, QUOTA_OBJTYPE_FILES, qup)) {
+ quota_close(qh);
+ quotause_destroy(qup);
+ return NULL;
+ }
+
+ quota_close(qh);
+
return qup;
}
@@ -648,9 +688,9 @@
}
for (qup = qlist->head; qup; qup = qup->next) {
struct quotaval *q = qup->qv;
- fprintf(fd, "%s (version %d):\n",
- qup->fsname, (qup->flags & QUOTA2) ? 2 : 1);
- if ((qup->flags & DEFAULT) == 0 || (qup->flags & QUOTA2) != 0) {
+ fprintf(fd, "%s (%s):\n",
+ qup->fsname, qup->implementation);
+ if ((qup->flags & DEFAULT) == 0 || (qup->flags & XGRACE) != 0) {
fprintf(fd, "\tblocks in use: %s, "
"limits (soft = %s, hard = %s",
intprt(b1, 21, q[QL_BLK].qv_usage,
@@ -659,17 +699,17 @@
HN_NOSPACE | HN_B, Hflag),
intprt(b3, 21, q[QL_BLK].qv_hardlimit,
HN_NOSPACE | HN_B, Hflag));
- if (qup->flags & QUOTA2)
+ if (qup->flags & XGRACE)
fprintf(fd, ", ");
} else
fprintf(fd, "\tblocks: (");
- if (qup->flags & (QUOTA2|DEFAULT)) {
+ if (qup->flags & (XGRACE|DEFAULT)) {
fprintf(fd, "grace = %s",
timepprt(b0, 21, q[QL_BLK].qv_grace, Hflag));
}
fprintf(fd, ")\n");
- if ((qup->flags & DEFAULT) == 0 || (qup->flags & QUOTA2) != 0) {
+ if ((qup->flags & DEFAULT) == 0 || (qup->flags & XGRACE) != 0) {
fprintf(fd, "\tinodes in use: %s, "
"limits (soft = %s, hard = %s",
intprt(b1, 21, q[QL_FL].qv_usage,
@@ -678,12 +718,12 @@
HN_NOSPACE, Hflag),
intprt(b3, 21, q[QL_FL].qv_hardlimit,
HN_NOSPACE, Hflag));
- if (qup->flags & QUOTA2)
+ if (qup->flags & XGRACE)
fprintf(fd, ", ");
} else
fprintf(fd, "\tinodes: (");
- if (qup->flags & (QUOTA2|DEFAULT)) {
+ if (qup->flags & (XGRACE|DEFAULT)) {
fprintf(fd, "grace = %s",
timepprt(b0, 21, q[QL_FL].qv_grace, Hflag));
}
@@ -1147,11 +1187,8 @@
errx(1, "permission denied");
protoname = NULL;
idtype = QUOTA_IDTYPE_USER;
- while ((ch = getopt(argc, argv, "DHcdugp:s:h:t:f:")) != -1) {
+ while ((ch = getopt(argc, argv, "Hcdugp:s:h:t:f:")) != -1) {
switch(ch) {
- case 'D':
- Dflag++;
- break;
case 'H':
Hflag++;
break;
Home |
Main Index |
Thread Index |
Old Index