Module Name: src Committed By: dholland Date: Mon Jan 30 19:16:36 UTC 2012
Modified Files: src/usr.sbin/edquota: Makefile edquota.c Log Message: Don't use the old getvfsquota() here. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/edquota/Makefile cvs rdiff -u -r1.43 -r1.44 src/usr.sbin/edquota/edquota.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.sbin/edquota/Makefile diff -u src/usr.sbin/edquota/Makefile:1.8 src/usr.sbin/edquota/Makefile:1.9 --- src/usr.sbin/edquota/Makefile:1.8 Thu Mar 24 17:05:47 2011 +++ src/usr.sbin/edquota/Makefile Mon Jan 30 19:16:36 2012 @@ -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 @@ DPADD= ${LIBQUOTA} ${LIBPROP} ${LIBRPCSV 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 Index: src/usr.sbin/edquota/edquota.c diff -u src/usr.sbin/edquota/edquota.c:1.43 src/usr.sbin/edquota/edquota.c:1.44 --- src/usr.sbin/edquota/edquota.c:1.43 Sun Jan 29 07:16:00 2012 +++ src/usr.sbin/edquota/edquota.c Mon Jan 30 19:16:36 2012 @@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #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 @@ __RCSID("$NetBSD: edquota.c,v 1.43 2012/ #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 @@ __RCSID("$NetBSD: edquota.c,v 1.43 2012/ #include <unistd.h> #include "printquota.h" -#include "getvfsquota.h" #include "quotautil.h" #include "pathnames.h" @@ -88,7 +86,7 @@ static const char *quotagroup = QUOTAGRO /* 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 @@ struct quotause { long flags; struct quotaval qv[QUOTA_NLIMITS]; char fsname[MAXPATHLEN + 1]; + char implementation[32]; char *qfname; }; @@ -107,7 +106,6 @@ struct quotalist { 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 @@ getprivs1(long id, int idtype, const cha //////////////////////////////////////////////////////////// // 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; } - if (version == 2) - qup->flags |= QUOTA2; + + impl = quota_getimplname(qh); + if (impl == NULL) { + impl = "???"; + } + 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 @@ writeprivs(struct quotalist *qlist, int } 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 @@ writeprivs(struct quotalist *qlist, int 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 @@ writeprivs(struct quotalist *qlist, int 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 @@ main(int argc, char *argv[]) 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;