Module Name:    src
Committed By:   dholland
Date:           Sun Jan 29 06:46:17 UTC 2012

Modified Files:
        src/sys/ufs/ufs: ufs_quota.c ufs_quota.h ufs_quota1.c

Log Message:
For QUOTACTL_SET in quota1, use the quotaval data instead of proplib.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/ufs/ufs/ufs_quota.c
cvs rdiff -u -r1.5 -r1.6 src/sys/ufs/ufs/ufs_quota.h
cvs rdiff -u -r1.11 -r1.12 src/sys/ufs/ufs/ufs_quota1.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/ufs/ufs/ufs_quota.c
diff -u src/sys/ufs/ufs/ufs_quota.c:1.80 src/sys/ufs/ufs/ufs_quota.c:1.81
--- src/sys/ufs/ufs/ufs_quota.c:1.80	Sun Jan 29 06:44:33 2012
+++ src/sys/ufs/ufs/ufs_quota.c	Sun Jan 29 06:46:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_quota.c,v 1.80 2012/01/29 06:44:33 dholland Exp $	*/
+/*	$NetBSD: ufs_quota.c,v 1.81 2012/01/29 06:46:16 dholland Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.80 2012/01/29 06:44:33 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.81 2012/01/29 06:46:16 dholland Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -271,6 +271,8 @@ quota_handle_cmd_set(struct mount *mp, s
 	id_t id;
 	int defaultq;
 	int q2type;
+	const struct quotaval *blocks;
+	const struct quotaval *files;
 	prop_dictionary_t data;
 	int error;
 
@@ -278,6 +280,8 @@ quota_handle_cmd_set(struct mount *mp, s
 	id = args->u.set.qc_id;
 	defaultq = args->u.set.qc_defaultq;
 	q2type = args->u.set.qc_q2type;
+	blocks = args->u.set.qc_blocks;
+	files = args->u.set.qc_files;
 	data = args->u.set.qc_data;
 
 	KASSERT(prop_object_type(data) == PROP_TYPE_DICTIONARY);
@@ -294,7 +298,7 @@ quota_handle_cmd_set(struct mount *mp, s
 #ifdef QUOTA
 		if (ump->um_flags & UFS_QUOTA)
 			error = quota1_handle_cmd_set(ump, q2type, id, defaultq,
-			    data);
+			    blocks, files);
 		else
 #endif
 #ifdef QUOTA2

Index: src/sys/ufs/ufs/ufs_quota.h
diff -u src/sys/ufs/ufs/ufs_quota.h:1.5 src/sys/ufs/ufs/ufs_quota.h:1.6
--- src/sys/ufs/ufs/ufs_quota.h:1.5	Sun Jan 29 06:41:41 2012
+++ src/sys/ufs/ufs/ufs_quota.h	Sun Jan 29 06:46:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_quota.h,v 1.5 2012/01/29 06:41:41 dholland Exp $	*/
+/*	$NetBSD: ufs_quota.h,v 1.6 2012/01/29 06:46:16 dholland Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -115,7 +115,8 @@ int dq1get(struct vnode *, u_long, struc
 int dq1sync(struct vnode *, struct dquot *);
 int quota1_handle_cmd_get(struct ufsmount *, const struct quotakey *,
     struct quotaval *);
-int quota1_handle_cmd_set(struct ufsmount *, int, int, int, prop_dictionary_t);
+int quota1_handle_cmd_set(struct ufsmount *, int, int, int,
+    const struct quotaval *, const struct quotaval *);
 int quota1_handle_cmd_quotaon(struct lwp *, struct ufsmount *, int,
     const char *);
 int quota1_handle_cmd_quotaoff(struct lwp *, struct ufsmount *, int);

Index: src/sys/ufs/ufs/ufs_quota1.c
diff -u src/sys/ufs/ufs/ufs_quota1.c:1.11 src/sys/ufs/ufs/ufs_quota1.c:1.12
--- src/sys/ufs/ufs/ufs_quota1.c:1.11	Sun Jan 29 06:45:26 2012
+++ src/sys/ufs/ufs/ufs_quota1.c	Sun Jan 29 06:46:16 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_quota1.c,v 1.11 2012/01/29 06:45:26 dholland Exp $	*/
+/*	$NetBSD: ufs_quota1.c,v 1.12 2012/01/29 06:46:16 dholland Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.11 2012/01/29 06:45:26 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.12 2012/01/29 06:46:16 dholland Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -543,25 +543,22 @@ quota1_handle_cmd_get(struct ufsmount *u
 	return 0;
 }
 
+static uint32_t
+quota1_encode_limit(uint64_t lim)
+{
+	if (lim == QUOTA_NOLIMIT || lim >= 0xffffffff) {
+		return 0;
+	}
+	return lim;
+}
+
 int
 quota1_handle_cmd_set(struct ufsmount *ump, int type, int id,
-    int defaultq, prop_dictionary_t data)
+    int defaultq, const struct quotaval *blocks, const struct quotaval *files)
 {
 	struct dquot *dq;
 	struct dqblk dqb;
 	int error;
-	uint64_t bval[2];
-	uint64_t ival[2];
-	const char *val_limitsonly_grace[] = {QUOTADICT_LIMIT_GTIME};
-#define Q1_GTIME 0
-	const char *val_limitsonly_softhard[] =
-	    {QUOTADICT_LIMIT_SOFT, QUOTADICT_LIMIT_HARD};
-#define Q1_SOFT 0
-#define Q1_HARD 1
-
-	uint64_t *valuesp[QUOTA_NLIMITS];
-	valuesp[QUOTA_LIMIT_BLOCK] = bval;
-	valuesp[QUOTA_LIMIT_FILE] = ival;
 
 	if (ump->um_quotas[type] == NULLVP)
 		return ENODEV;
@@ -569,28 +566,20 @@ quota1_handle_cmd_set(struct ufsmount *u
 	if (defaultq) {
 		/* just update grace times */
 		KASSERT(id == 0);
-		error = proptoquota64(data, valuesp, val_limitsonly_grace, 1,
-		    ufs_quota_limit_names, QUOTA_NLIMITS);
-		if (error)
-			return error;
 		if ((error = dqget(NULLVP, id, ump, type, &dq)) != 0)
 			return error;
 		mutex_enter(&dq->dq_interlock);
-		if (bval[Q1_GTIME] > 0)
+		if (blocks->qv_grace > 0)
 			ump->umq1_btime[type] = dq->dq_btime =
-			    bval[Q1_GTIME];
-		if (ival[Q1_GTIME] > 0)
+			    blocks->qv_grace;
+		if (files->qv_grace > 0)
 			ump->umq1_itime[type] = dq->dq_itime =
-			    ival[Q1_GTIME];
+			    files->qv_grace;
 		mutex_exit(&dq->dq_interlock);
 		dq->dq_flags |= DQ_MOD;
 		dqrele(NULLVP, dq);
 		return 0;
 	}
-	error = proptoquota64(data, valuesp, val_limitsonly_softhard, 2,
-	    ufs_quota_limit_names, QUOTA_NLIMITS);
-	if (error)
-		return error;
 
 	if ((error = dqget(NULLVP, id, ump, type, &dq)) != 0)
 		return (error);
@@ -604,20 +593,19 @@ quota1_handle_cmd_set(struct ufsmount *u
 	dqb.dqb_curinodes = dq->dq_curinodes;
 	dqb.dqb_btime = dq->dq_btime;
 	dqb.dqb_itime = dq->dq_itime;
-	dqb.dqb_bsoftlimit = (bval[Q1_SOFT] == UQUAD_MAX) ? 0 : bval[Q1_SOFT];
-	dqb.dqb_bhardlimit = (bval[Q1_HARD] == UQUAD_MAX) ? 0 : bval[Q1_HARD];
-	dqb.dqb_isoftlimit = (ival[Q1_SOFT] == UQUAD_MAX) ? 0 : ival[Q1_SOFT];
-	dqb.dqb_ihardlimit = (ival[Q1_HARD] == UQUAD_MAX) ? 0 : ival[Q1_HARD];
+	dqb.dqb_bsoftlimit = quota1_encode_limit(blocks->qv_softlimit);
+	dqb.dqb_bhardlimit = quota1_encode_limit(blocks->qv_hardlimit);
+	dqb.dqb_isoftlimit = quota1_encode_limit(files->qv_softlimit);
+	dqb.dqb_ihardlimit = quota1_encode_limit(files->qv_hardlimit);
 	if (dq->dq_id == 0) {
 		/* also update grace time if available */
-		if (proptoquota64(data, valuesp, val_limitsonly_grace, 1,
-		    ufs_quota_limit_names, QUOTA_NLIMITS) == 0) {
-			if (bval[Q1_GTIME] > 0)
-				ump->umq1_btime[type] = dqb.dqb_btime =
-				    bval[Q1_GTIME];
-			if (ival[Q1_GTIME] > 0)
-				ump->umq1_itime[type] = dqb.dqb_itime =
-				    ival[Q1_GTIME];
+		if (blocks->qv_grace != QUOTA_NOTIME) {
+			ump->umq1_btime[type] = dqb.dqb_btime =
+				blocks->qv_grace;
+		}
+		if (files->qv_grace != QUOTA_NOTIME) {
+			ump->umq1_itime[type] = dqb.dqb_itime =
+				files->qv_grace;
 		}
 	}
 	if (dqb.dqb_bsoftlimit &&

Reply via email to