Module Name:    src
Committed By:   dholland
Date:           Sun Jan 29 07:16:01 UTC 2012

Modified Files:
        src/sys/compat/common: vfs_syscalls_50.c
        src/sys/ufs/ufs: quota.h
        src/usr.sbin/edquota: edquota.c

Log Message:
Rename static inline "helper" functions:
   ufsclass2qtype -> quota_idtype_to_ufs
   qtype2ufsclass -> quota_idtype_from_ufs

The reason for the direction of "ufs" changing is that the old names
were among the symbols using "ufs" to mean "fs-independent". So the
old names were for translating "ufsclass" (fs-independent quota id
type) to "qtype" (ufs-specific quota id type) and vice versa.

These functions are used in only two places, both of which are
inappropriate, so at some point they should probably be removed.
They're also identity transformations so not particularly helpful,
unless one were to make a careful and concerted effort to distinguish
the ufs quota code numbers from the fs-independent ones. This has not
been done and is probably impossible without support from a program
verifier, and maybe not even then.

They are static inline, so no compat concerns arise.

Also adjust the symbols they use to avoid <quota/quotaprop.h>.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/compat/common/vfs_syscalls_50.c
cvs rdiff -u -r1.28 -r1.29 src/sys/ufs/ufs/quota.h
cvs rdiff -u -r1.42 -r1.43 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/sys/compat/common/vfs_syscalls_50.c
diff -u src/sys/compat/common/vfs_syscalls_50.c:1.12 src/sys/compat/common/vfs_syscalls_50.c:1.13
--- src/sys/compat/common/vfs_syscalls_50.c:1.12	Sun Jan 29 06:29:04 2012
+++ src/sys/compat/common/vfs_syscalls_50.c	Sun Jan 29 07:16:00 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_syscalls_50.c,v 1.12 2012/01/29 06:29:04 dholland Exp $	*/
+/*	$NetBSD: vfs_syscalls_50.c,v 1.13 2012/01/29 07:16:00 dholland Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_50.c,v 1.12 2012/01/29 06:29:04 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_50.c,v 1.13 2012/01/29 07:16:00 dholland Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -338,6 +338,7 @@ compat_50_sys_quotactl(struct lwp *l, co
 	struct dqblk dqblk;
 	struct quotaval qv[QUOTA_NLIMITS];
 	uint64_t *values[QUOTA_NLIMITS];
+	int idtype;
 
 	values[QUOTA_LIMIT_BLOCK] = &qv[QUOTA_LIMIT_BLOCK].qv_hardlimit;
 	values[QUOTA_LIMIT_FILE] = &qv[QUOTA_LIMIT_FILE].qv_hardlimit;
@@ -376,16 +377,18 @@ compat_50_sys_quotactl(struct lwp *l, co
 		error = ENOMEM;
 		if (!prop_array_add_and_rel(datas, data))
 			goto out_datas;
+		idtype = quota_idtype_from_ufs(q1cmd & SUBCMDMASK);
 		if (!quota_prop_add_command(cmds, "quotaon",
-		    ufs_quota_class_names[qtype2ufsclass(q1cmd & SUBCMDMASK)],
+		    ufs_quota_class_names[idtype],
 		    datas))
 			goto out_cmds;
 		goto do_quotaonoff;
 
 	case Q_QUOTAOFF:
 		error = ENOMEM;
+		idtype = quota_idtype_from_ufs(q1cmd & SUBCMDMASK);
 		if (!quota_prop_add_command(cmds, "quotaoff",
-		    ufs_quota_class_names[qtype2ufsclass(q1cmd & SUBCMDMASK)],
+		    ufs_quota_class_names[idtype],
 		    datas))
 			goto out_cmds;
 do_quotaonoff:
@@ -417,8 +420,9 @@ do_quotaonoff:
 			goto out_data;
 		if (!prop_array_add_and_rel(datas, data))
 			goto out_datas;
+		idtype = quota_idtype_from_ufs(q1cmd & SUBCMDMASK);
 		if (!quota_prop_add_command(cmds, "get",
-		    ufs_quota_class_names[qtype2ufsclass(q1cmd & SUBCMDMASK)],
+		    ufs_quota_class_names[idtype],
 		    datas))
 			goto out_cmds;
 		if (!prop_dictionary_set_and_rel(dict, "commands", cmds))
@@ -473,8 +477,9 @@ do_quotaonoff:
 			goto out_data;
 		if (!prop_array_add_and_rel(datas, data))
 			goto out_datas;
+		idtype = quota_idtype_from_ufs(q1cmd & SUBCMDMASK);
 		if (!quota_prop_add_command(cmds, "set",
-		    ufs_quota_class_names[qtype2ufsclass(q1cmd & SUBCMDMASK)],
+		    ufs_quota_class_names[idtype],
 		    datas))
 			goto out_cmds;
 		if (!prop_dictionary_set_and_rel(dict, "commands", cmds))
@@ -502,8 +507,9 @@ do_quotaonoff:
 		 * emulate with a "get version"
 		 */
 		error = ENOMEM;
+		idtype = quota_idtype_from_ufs(q1cmd & SUBCMDMASK);
 		if (!quota_prop_add_command(cmds, "get version",
-		    ufs_quota_class_names[qtype2ufsclass(q1cmd & SUBCMDMASK)],
+		    ufs_quota_class_names[idtype],
 		    datas))
 			goto out_cmds;
 		if (!prop_dictionary_set_and_rel(dict, "commands", cmds))

Index: src/sys/ufs/ufs/quota.h
diff -u src/sys/ufs/ufs/quota.h:1.28 src/sys/ufs/ufs/quota.h:1.29
--- src/sys/ufs/ufs/quota.h:1.28	Fri Mar 25 10:25:17 2011
+++ src/sys/ufs/ufs/quota.h	Sun Jan 29 07:16:00 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota.h,v 1.28 2011/03/25 10:25:17 bouyer Exp $	*/
+/*	$NetBSD: quota.h,v 1.29 2012/01/29 07:16:00 dholland Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -55,14 +55,14 @@
 
 
 #if !defined(HAVE_NBTOOL_CONFIG_H)
-#include <quota/quotaprop.h>
+#include <sys/quota.h>
 __inline static int __unused
-ufsclass2qtype(int class)
+quota_idtype_to_ufs(int idtype)
 {
-	switch(class) {
-	case QUOTA_CLASS_USER:
+	switch (idtype) {
+	case QUOTA_IDTYPE_USER:
 		return USRQUOTA;
-	case QUOTA_CLASS_GROUP:
+	case QUOTA_IDTYPE_GROUP:
 		return GRPQUOTA;
 	default:
 		return -1;
@@ -70,13 +70,13 @@ ufsclass2qtype(int class)
 }
 
 static __inline int __unused
-qtype2ufsclass(int type)
+quota_idtype_from_ufs(int ufstype)
 {
-	switch(type) {
+	switch (ufstype) {
 	case USRQUOTA:
-		return QUOTA_CLASS_USER;
+		return QUOTA_IDTYPE_USER;
 	case GRPQUOTA:
-		return QUOTA_CLASS_GROUP;
+		return QUOTA_IDTYPE_GROUP;
 	default:
 		return -1;
 	}

Index: src/usr.sbin/edquota/edquota.c
diff -u src/usr.sbin/edquota/edquota.c:1.42 src/usr.sbin/edquota/edquota.c:1.43
--- src/usr.sbin/edquota/edquota.c:1.42	Sun Jan 29 06:23:20 2012
+++ src/usr.sbin/edquota/edquota.c	Sun Jan 29 07:16:00 2012
@@ -1,4 +1,4 @@
-/*      $NetBSD: edquota.c,v 1.42 2012/01/29 06:23:20 dholland Exp $ */
+/*      $NetBSD: edquota.c,v 1.43 2012/01/29 07:16:00 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.42 2012/01/29 06:23:20 dholland Exp $");
+__RCSID("$NetBSD: edquota.c,v 1.43 2012/01/29 07:16:00 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -288,7 +288,7 @@ getprivs1(long id, int idtype, const cha
 		return NULL;
 
 	if (!hasquota(qfpathname, sizeof(qfpathname), fs,
-	    ufsclass2qtype(idtype)))
+	    quota_idtype_to_ufs(idtype)))
 		return NULL;
 
 	qup = quotause_create();

Reply via email to