Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/edquota "quotaclass" -> "idtype". After lengthy wra...



details:   https://anonhg.NetBSD.org/src/rev/f09d7b40c28f
branches:  trunk
changeset: 772616:f09d7b40c28f
user:      dholland <dholland%NetBSD.org@localhost>
date:      Mon Jan 09 15:44:42 2012 +0000

description:
"quotaclass" -> "idtype". After lengthy wrangling on the mailing lists
the best conclusion for naming was to give up on "classes" and "types"
and use "idtype" for users vs. groups and "objtype" for blocks vs. files.

diffstat:

 usr.sbin/edquota/edquota.c |  118 ++++++++++++++++++++++----------------------
 1 files changed, 59 insertions(+), 59 deletions(-)

diffs (truncated from 429 to 300 lines):

diff -r e2906cf21ab8 -r f09d7b40c28f usr.sbin/edquota/edquota.c
--- a/usr.sbin/edquota/edquota.c        Mon Jan 09 15:44:05 2012 +0000
+++ b/usr.sbin/edquota/edquota.c        Mon Jan 09 15:44:42 2012 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: edquota.c,v 1.40 2012/01/09 15:44:05 dholland Exp $ */
+/*      $NetBSD: edquota.c,v 1.41 2012/01/09 15:44:42 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.40 2012/01/09 15:44:05 dholland Exp $");
+__RCSID("$NetBSD: edquota.c,v 1.41 2012/01/09 15:44:42 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -122,26 +122,26 @@
  * getinoquota as to the interpretation of quota classes.
  */
 static int
-getidbyname(const char *name, int quotaclass)
+getidbyname(const char *name, int idtype)
 {
        struct passwd *pw;
        struct group *gr;
 
        if (alldigits(name))
                return atoi(name);
-       switch(quotaclass) {
-       case QUOTA_CLASS_USER:
+       switch (idtype) {
+       case QUOTA_IDTYPE_USER:
                if ((pw = getpwnam(name)) != NULL)
                        return pw->pw_uid;
                warnx("%s: no such user", name);
                break;
-       case QUOTA_CLASS_GROUP:
+       case QUOTA_IDTYPE_GROUP:
                if ((gr = getgrnam(name)) != NULL)
                        return gr->gr_gid;
                warnx("%s: no such group", name);
                break;
        default:
-               warnx("%d: unknown quota type", quotaclass);
+               warnx("%d: unknown quota type", idtype);
                break;
        }
        sleep(1);
@@ -244,7 +244,7 @@
 // ffs quota v1
 
 static void
-putprivs1(uint32_t id, int quotaclass, struct quotause *qup)
+putprivs1(uint32_t id, int idtype, struct quotause *qup)
 {
        struct dqblk dqblk;
        int fd;
@@ -266,7 +266,7 @@
 }
 
 static struct quotause *
-getprivs1(long id, int quotaclass, const char *filesys)
+getprivs1(long id, int idtype, const char *filesys)
 {
        struct fstab *fs;
        char qfpathname[MAXPATHLEN];
@@ -286,7 +286,7 @@
                return NULL;
 
        if (!hasquota(qfpathname, sizeof(qfpathname), fs,
-           ufsclass2qtype(quotaclass)))
+           ufsclass2qtype(idtype)))
                return NULL;
 
        qup = quotause_create();
@@ -335,7 +335,7 @@
 // ffs quota v2
 
 static struct quotause *
-getprivs2(long id, int quotaclass, const char *filesys, int defaultq)
+getprivs2(long id, int idtype, const char *filesys, int defaultq)
 {
        struct quotause *qup;
        int8_t version;
@@ -345,10 +345,10 @@
        if (defaultq)
                qup->flags |= DEFAULT;
        if (!getvfsquota(filesys, qup->qv, &version,
-           id, quotaclass, defaultq, Dflag)) {
+           id, idtype, defaultq, Dflag)) {
                /* no entry, get default entry */
                if (!getvfsquota(filesys, qup->qv, &version,
-                   id, quotaclass, 1, Dflag)) {
+                   id, idtype, 1, Dflag)) {
                        free(qup);
                        return NULL;
                }
@@ -359,7 +359,7 @@
 }
 
 static void
-putprivs2(uint32_t id, int quotaclass, struct quotause *qup)
+putprivs2(uint32_t id, int idtype, struct quotause *qup)
 {
        struct quotahandle *qh;
        struct quotakey qk;
@@ -367,11 +367,11 @@
 
        if (qup->flags & DEFAULT) {
                snprintf(idname, sizeof(idname), "%s default",
-                        quotaclass == QUOTA_IDTYPE_USER ? "user" : "group");
+                        idtype == QUOTA_IDTYPE_USER ? "user" : "group");
                id = QUOTA_DEFAULTID;
        } else {
                snprintf(idname, sizeof(idname), "%s %u",
-                        quotaclass == QUOTA_IDTYPE_USER ? "uid" : "gid", id);
+                        idtype == QUOTA_IDTYPE_USER ? "uid" : "gid", id);
        }
 
        qh = quota_open(qup->fsname);
@@ -379,14 +379,14 @@
                err(1, "%s: quota_open", qup->fsname);
        }
 
-       qk.qk_idtype = quotaclass;
+       qk.qk_idtype = idtype;
        qk.qk_id = id;
        qk.qk_objtype = QUOTA_OBJTYPE_BLOCKS;
        if (quota_put(qh, &qk, &qup->qv[QL_BLK])) {
                err(1, "%s: quota_put (%s blocks)", qup->fsname, idname);
        }
 
-       qk.qk_idtype = quotaclass;
+       qk.qk_idtype = idtype;
        qk.qk_id = id;
        qk.qk_objtype = QUOTA_OBJTYPE_FILES;
        if (quota_put(qh, &qk, &qup->qv[QL_FL])) {
@@ -403,7 +403,7 @@
  * Collect the requested quota information.
  */
 static struct quotalist *
-getprivs(long id, int defaultq, int quotaclass, const char *filesys)
+getprivs(long id, int defaultq, int idtype, const char *filesys)
 {
        struct statvfs *fst;
        int nfst, i;
@@ -423,7 +423,7 @@
                    strcmp(fst[i].f_mntonname, filesys) != 0 &&
                    strcmp(fst[i].f_mntfromname, filesys) != 0)
                        continue;
-               qup = getprivs2(id, quotaclass, fst[i].f_mntonname, defaultq);
+               qup = getprivs2(id, idtype, fst[i].f_mntonname, defaultq);
                if (qup == NULL) {
                        /*
                         * XXX: returning NULL is totally wrong. On
@@ -447,7 +447,7 @@
                if (defaultq)
                        errx(1, "no default quota for version 1");
                /* if we get there, filesys is not mounted. try the old way */
-               qup = getprivs1(id, quotaclass, filesys);
+               qup = getprivs1(id, idtype, filesys);
                if (qup == NULL) {
                        /* XXX. see above */
                        /*return NULL;*/
@@ -463,20 +463,20 @@
  * Store the requested quota information.
  */
 static void
-putprivs(uint32_t id, int quotaclass, struct quotalist *qlist)
+putprivs(uint32_t id, int idtype, struct quotalist *qlist)
 {
        struct quotause *qup;
 
         for (qup = qlist->head; qup; qup = qup->next) {
                if (qup->qfname == NULL)
-                       putprivs2(id, quotaclass, qup);
+                       putprivs2(id, idtype, qup);
                else
-                       putprivs1(id, quotaclass, qup);
+                       putprivs1(id, idtype, qup);
        }
 }
 
 static void
-clearpriv(int argc, char **argv, const char *filesys, int quotaclass)
+clearpriv(int argc, char **argv, const char *filesys, int idtype)
 {
        struct statvfs *fst;
        int nfst, i;
@@ -495,7 +495,7 @@
        }
 
        for ( ; argc > 0; argc--, argv++) {
-               if ((id = getidbyname(*argv, quotaclass)) == -1)
+               if ((id = getidbyname(*argv, idtype)) == -1)
                        continue;
 
                if (nids + 1 > maxids) {
@@ -527,10 +527,10 @@
 
                for (j = 0; j < nids; j++) {
                        snprintf(idname, sizeof(idname), "%s %u",
-                                quotaclass == QUOTA_IDTYPE_USER ? 
+                                idtype == QUOTA_IDTYPE_USER ? 
                                 "uid" : "gid", ids[j]);
 
-                       qk.qk_idtype = quotaclass;
+                       qk.qk_idtype = idtype;
                        qk.qk_id = ids[j];
                        qk.qk_objtype = QUOTA_OBJTYPE_BLOCKS;
                        if (quota_delete(qh, &qk)) {
@@ -538,7 +538,7 @@
                                    fst[i].f_mntonname, idname);
                        }
 
-                       qk.qk_idtype = quotaclass;
+                       qk.qk_idtype = idtype;
                        qk.qk_id = ids[j];
                        qk.qk_objtype = QUOTA_OBJTYPE_FILES;
                        if (quota_delete(qh, &qk)) {
@@ -625,7 +625,7 @@
  */
 static int
 writeprivs(struct quotalist *qlist, int outfd, const char *name,
-    int quotaclass)
+    int idtype)
 {
        struct quotause *qup;
        FILE *fd;
@@ -637,10 +637,10 @@
                errx(1, "fdopen");
        if (name == NULL) {
                fprintf(fd, "Default %s quotas:\n",
-                   ufs_quota_class_names[quotaclass]);
+                   ufs_quota_class_names[idtype]);
        } else {
                fprintf(fd, "Quotas for %s %s:\n",
-                   ufs_quota_class_names[quotaclass], name);
+                   ufs_quota_class_names[idtype], name);
        }
        for (qup = qlist->head; qup; qup = qup->next) {
                struct quotaval *q = qup->qv;
@@ -934,7 +934,7 @@
 // actions
 
 static void
-replicate(const char *fs, int quotaclass, const char *protoname,
+replicate(const char *fs, int idtype, const char *protoname,
          char **names, int numnames)
 {
        long protoid, id;
@@ -942,25 +942,25 @@
        struct quotause *qup;
        int i;
 
-       if ((protoid = getidbyname(protoname, quotaclass)) == -1)
+       if ((protoid = getidbyname(protoname, idtype)) == -1)
                exit(1);
-       protoprivs = getprivs(protoid, 0, quotaclass, fs);
+       protoprivs = getprivs(protoid, 0, idtype, fs);
        for (qup = protoprivs->head; qup; qup = qup->next) {
                qup->qv[QL_BLK].qv_expiretime = 0;
                qup->qv[QL_FL].qv_expiretime = 0;
        }
        for (i=0; i<numnames; i++) {
-               id = getidbyname(names[i], quotaclass);
-               if (id < 0)
+               id = getidbyname(names[i], idtype);
+               if (id == -1)
                        continue;
-               putprivs(id, quotaclass, protoprivs);
+               putprivs(id, idtype, protoprivs);
        }
        /* XXX */
        /* quotalist_destroy(protoprivs); */
 }
 
 static void
-assign(const char *fs, int quotaclass,
+assign(const char *fs, int idtype,
        char *soft, char *hard, char *grace,
        char **names, int numnames)
 {
@@ -1008,13 +1008,13 @@
                        id = 0;
                        dflag = 1;
                } else {
-                       id = getidbyname(names[i], quotaclass);
+                       id = getidbyname(names[i], idtype);
                        if (id == -1)
                                continue;
                        dflag = 0;
                }
 
-               curprivs = getprivs(id, dflag, quotaclass, fs);
+               curprivs = getprivs(id, dflag, idtype, fs);
                for (lqup = curprivs->head; lqup; lqup = lqup->next) {
                        struct quotaval *q = lqup->qv;



Home | Main Index | Thread Index | Old Index