Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/edquota Remove dependence on quotaprop.h, also quot...
details: https://anonhg.NetBSD.org/src/rev/f88d977292e0
branches: trunk
changeset: 773304:f88d977292e0
user: dholland <dholland%NetBSD.org@localhost>
date: Mon Jan 30 19:19:20 2012 +0000
description:
Remove dependence on quotaprop.h, also quotautil.c (no longer used).
Like repquota, compile in the number of object types for now because
making it support an arbitrary number would take some hacking.
diffstat:
usr.sbin/edquota/Makefile | 6 +-
usr.sbin/edquota/edquota.c | 157 ++++++++++++++++++++++++--------------------
2 files changed, 88 insertions(+), 75 deletions(-)
diffs (truncated from 382 to 300 lines):
diff -r f8da858c6f26 -r f88d977292e0 usr.sbin/edquota/Makefile
--- a/usr.sbin/edquota/Makefile Mon Jan 30 19:18:36 2012 +0000
+++ b/usr.sbin/edquota/Makefile Mon Jan 30 19:19:20 2012 +0000
@@ -1,5 +1,5 @@
# from: @(#)Makefile 8.1 (Berkeley) 6/6/93
-# $NetBSD: Makefile,v 1.9 2012/01/30 19:16:36 dholland Exp $
+# $NetBSD: Makefile,v 1.10 2012/01/30 19:19:20 dholland Exp $
.include <bsd.own.mk>
@@ -13,8 +13,6 @@
LDADD= -lquota -lprop -lrpcsvc
.PATH: ${NETBSDSRCDIR}/usr.bin/quota
-SRCS+= printquota.c quotautil.c
-.PATH: ${NETBSDSRCDIR}/sys/ufs/ufs
-SRCS+= quota1_subr.c
+SRCS+= printquota.c
.include <bsd.prog.mk>
diff -r f8da858c6f26 -r f88d977292e0 usr.sbin/edquota/edquota.c
--- a/usr.sbin/edquota/edquota.c Mon Jan 30 19:18:36 2012 +0000
+++ b/usr.sbin/edquota/edquota.c Mon Jan 30 19:19:20 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: edquota.c,v 1.45 2012/01/30 19:18:36 dholland Exp $ */
+/* $NetBSD: edquota.c,v 1.46 2012/01/30 19:19:20 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.45 2012/01/30 19:18:36 dholland Exp $");
+__RCSID("$NetBSD: edquota.c,v 1.46 2012/01/30 19:19:20 dholland Exp $");
#endif
#endif /* not lint */
@@ -57,9 +57,6 @@
#include <sys/statvfs.h>
#include <quota.h>
-#include <quota/quotaprop.h>
-#include <quota/quota.h>
-#include <ufs/ufs/quota1.h>
#include <assert.h>
#include <err.h>
@@ -76,10 +73,15 @@
#include <unistd.h>
#include "printquota.h"
-#include "quotautil.h"
#include "pathnames.h"
+/*
+ * XXX. Ideally we shouldn't compile this in, but it'll take some
+ * reworking to avoid it and it'll be ok for now.
+ */
+#define EDQUOTA_NUMOBJTYPES 2
+
#if 0
static const char *quotagroup = QUOTAGROUP;
#endif
@@ -94,7 +96,7 @@
struct quotause {
struct quotause *next;
long flags;
- struct quotaval qv[QUOTA_NLIMITS];
+ struct quotaval qv[EDQUOTA_NUMOBJTYPES];
char fsname[MAXPATHLEN + 1];
char implementation[32];
char *qfname;
@@ -103,6 +105,7 @@
struct quotalist {
struct quotause *head;
struct quotause *tail;
+ char *idtypename;
};
static void usage(void) __dead;
@@ -110,8 +113,8 @@
static int Hflag = 0;
/* more compact form of constants */
-#define QL_BLK QUOTA_LIMIT_BLOCK
-#define QL_FL QUOTA_LIMIT_FILE
+#define QO_BLK QUOTA_OBJTYPE_BLOCKS
+#define QO_FL QUOTA_OBJTYPE_FILES
////////////////////////////////////////////////////////////
// support code
@@ -201,6 +204,7 @@
qlist->head = NULL;
qlist->tail = NULL;
+ qlist->idtypename = NULL;
return qlist;
}
@@ -217,6 +221,7 @@
nextqup = qup->next;
quotause_destroy(qup);
}
+ free(qlist->idtypename);
free(qlist);
}
@@ -362,12 +367,14 @@
}
static struct quotause *
-getprivs2(long id, int idtype, const char *filesys, int defaultq)
+getprivs2(long id, int idtype, const char *filesys, int defaultq,
+ char **idtypename_p)
{
struct quotause *qup;
struct quotahandle *qh;
const char *impl;
unsigned restrictions;
+ const char *idtypename;
qup = quotause_create();
strcpy(qup->fsname, filesys);
@@ -391,6 +398,14 @@
qup->flags |= XGRACE;
}
+ if (*idtypename_p == NULL) {
+ idtypename = quota_idtype_getname(qh, idtype);
+ *idtypename_p = strdup(idtypename);
+ if (*idtypename_p == NULL) {
+ errx(1, "Out of memory");
+ }
+ }
+
if (dogetprivs2(qh, idtype, id, defaultq, QUOTA_OBJTYPE_BLOCKS, qup)) {
quota_close(qh);
quotause_destroy(qup);
@@ -432,14 +447,14 @@
qk.qk_idtype = idtype;
qk.qk_id = id;
qk.qk_objtype = QUOTA_OBJTYPE_BLOCKS;
- if (quota_put(qh, &qk, &qup->qv[QL_BLK])) {
+ if (quota_put(qh, &qk, &qup->qv[QO_BLK])) {
err(1, "%s: quota_put (%s blocks)", qup->fsname, idname);
}
qk.qk_idtype = idtype;
qk.qk_id = id;
qk.qk_objtype = QUOTA_OBJTYPE_FILES;
- if (quota_put(qh, &qk, &qup->qv[QL_FL])) {
+ if (quota_put(qh, &qk, &qup->qv[QO_FL])) {
err(1, "%s: quota_put (%s files)", qup->fsname, idname);
}
@@ -473,7 +488,8 @@
strcmp(fst[i].f_mntonname, filesys) != 0 &&
strcmp(fst[i].f_mntfromname, filesys) != 0)
continue;
- qup = getprivs2(id, idtype, fst[i].f_mntonname, defaultq);
+ qup = getprivs2(id, idtype, fst[i].f_mntonname, defaultq,
+ &qlist->idtypename);
if (qup == NULL) {
/*
* XXX: returning NULL is totally wrong. On
@@ -679,7 +695,7 @@
*/
static int
writeprivs(struct quotalist *qlist, int outfd, const char *name,
- int idtype)
+ int idtype, const char *idtypename)
{
struct quotause *qup;
FILE *fd;
@@ -690,11 +706,9 @@
if ((fd = fdopen(dup(outfd), "w")) == NULL)
errx(1, "fdopen");
if (name == NULL) {
- fprintf(fd, "Default %s quotas:\n",
- ufs_quota_class_names[idtype]);
+ fprintf(fd, "Default %s quotas:\n", idtypename);
} else {
- fprintf(fd, "Quotas for %s %s:\n",
- ufs_quota_class_names[idtype], name);
+ fprintf(fd, "Quotas for %s %s:\n", idtypename, name);
}
for (qup = qlist->head; qup; qup = qup->next) {
struct quotaval *q = qup->qv;
@@ -703,11 +717,11 @@
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,
+ intprt(b1, 21, q[QO_BLK].qv_usage,
HN_NOSPACE | HN_B, Hflag),
- intprt(b2, 21, q[QL_BLK].qv_softlimit,
+ intprt(b2, 21, q[QO_BLK].qv_softlimit,
HN_NOSPACE | HN_B, Hflag),
- intprt(b3, 21, q[QL_BLK].qv_hardlimit,
+ intprt(b3, 21, q[QO_BLK].qv_hardlimit,
HN_NOSPACE | HN_B, Hflag));
if (qup->flags & XGRACE)
fprintf(fd, ", ");
@@ -716,17 +730,17 @@
if (qup->flags & (XGRACE|DEFAULT)) {
fprintf(fd, "grace = %s",
- timepprt(b0, 21, q[QL_BLK].qv_grace, Hflag));
+ timepprt(b0, 21, q[QO_BLK].qv_grace, Hflag));
}
fprintf(fd, ")\n");
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,
+ intprt(b1, 21, q[QO_FL].qv_usage,
HN_NOSPACE, Hflag),
- intprt(b2, 21, q[QL_FL].qv_softlimit,
+ intprt(b2, 21, q[QO_FL].qv_softlimit,
HN_NOSPACE, Hflag),
- intprt(b3, 21, q[QL_FL].qv_hardlimit,
+ intprt(b3, 21, q[QO_FL].qv_hardlimit,
HN_NOSPACE, Hflag));
if (qup->flags & XGRACE)
fprintf(fd, ", ");
@@ -735,7 +749,7 @@
if (qup->flags & (XGRACE|DEFAULT)) {
fprintf(fd, "grace = %s",
- timepprt(b0, 21, q[QL_FL].qv_grace, Hflag));
+ timepprt(b0, 21, q[QO_FL].qv_grace, Hflag));
}
fprintf(fd, ")\n");
}
@@ -920,16 +934,16 @@
if (strcmp(fsp, qup->fsname))
continue;
if (version == 1 && dflag) {
- q[QL_BLK].qv_grace = graceb;
- q[QL_FL].qv_grace = gracei;
+ q[QO_BLK].qv_grace = graceb;
+ q[QO_FL].qv_grace = gracei;
qup->flags |= FOUND;
continue;
}
- if (strcmp(intprt(b1, 21, q[QL_BLK].qv_usage,
+ if (strcmp(intprt(b1, 21, q[QO_BLK].qv_usage,
HN_NOSPACE | HN_B, Hflag),
scurb) != 0 ||
- strcmp(intprt(b2, 21, q[QL_FL].qv_usage,
+ strcmp(intprt(b2, 21, q[QO_FL].qv_usage,
HN_NOSPACE, Hflag),
scuri) != 0) {
warnx("%s: cannot change current allocation",
@@ -942,24 +956,24 @@
* or were under it, but now have a soft limit
* and are over it.
*/
- if (q[QL_BLK].qv_usage &&
- q[QL_BLK].qv_usage >= softb &&
- (q[QL_BLK].qv_softlimit == 0 ||
- q[QL_BLK].qv_usage < q[QL_BLK].qv_softlimit))
- q[QL_BLK].qv_expiretime = 0;
- if (q[QL_FL].qv_usage &&
- q[QL_FL].qv_usage >= softi &&
- (q[QL_FL].qv_softlimit == 0 ||
- q[QL_FL].qv_usage < q[QL_FL].qv_softlimit))
- q[QL_FL].qv_expiretime = 0;
- q[QL_BLK].qv_softlimit = softb;
- q[QL_BLK].qv_hardlimit = hardb;
+ if (q[QO_BLK].qv_usage &&
+ q[QO_BLK].qv_usage >= softb &&
+ (q[QO_BLK].qv_softlimit == 0 ||
+ q[QO_BLK].qv_usage < q[QO_BLK].qv_softlimit))
+ q[QO_BLK].qv_expiretime = 0;
+ if (q[QO_FL].qv_usage &&
+ q[QO_FL].qv_usage >= softi &&
+ (q[QO_FL].qv_softlimit == 0 ||
+ q[QO_FL].qv_usage < q[QO_FL].qv_softlimit))
+ q[QO_FL].qv_expiretime = 0;
+ q[QO_BLK].qv_softlimit = softb;
+ q[QO_BLK].qv_hardlimit = hardb;
if (version == 2)
- q[QL_BLK].qv_grace = graceb;
- q[QL_FL].qv_softlimit = softi;
- q[QL_FL].qv_hardlimit = hardi;
+ q[QO_BLK].qv_grace = graceb;
+ q[QO_FL].qv_softlimit = softi;
+ q[QO_FL].qv_hardlimit = hardi;
if (version == 2)
- q[QL_FL].qv_grace = gracei;
+ q[QO_FL].qv_grace = gracei;
qup->flags |= FOUND;
}
}
@@ -974,12 +988,12 @@
qup->flags &= ~FOUND;
Home |
Main Index |
Thread Index |
Old Index