Sun Jan 29 06:36:07 2012 UTC ()
Introduce struct vfs_quotactl_args. Use it.

This change uglifies vfs_quotactl some in order to make room for
moving operation-specific but FS-independent logic out of ufs_quota.c.

Note: this change requires a kernel version bump.


(dholland)
diff -r1.4 -r1.5 src/sys/kern/vfs_quotactl.c
diff -r1.428 -r1.429 src/sys/kern/vfs_subr.c
diff -r1.31 -r1.32 src/sys/miscfs/genfs/layer_extern.h
diff -r1.36 -r1.37 src/sys/miscfs/genfs/layer_vfsops.c
diff -r1.204 -r1.205 src/sys/sys/mount.h
diff -r1.2 -r1.3 src/sys/sys/quotactl.h
diff -r1.68 -r1.69 src/sys/ufs/ufs/ufs_extern.h
diff -r1.71 -r1.72 src/sys/ufs/ufs/ufs_quota.c
diff -r1.45 -r1.46 src/sys/ufs/ufs/ufs_vfsops.c

cvs diff -r1.4 -r1.5 src/sys/kern/vfs_quotactl.c (expand / switch to unified diff)

--- src/sys/kern/vfs_quotactl.c 2012/01/29 06:34:57 1.4
+++ src/sys/kern/vfs_quotactl.c 2012/01/29 06:36:06 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: vfs_quotactl.c,v 1.4 2012/01/29 06:34:57 dholland Exp $ */ 1/* $NetBSD: vfs_quotactl.c,v 1.5 2012/01/29 06:36:06 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1991, 1993, 1994 4 * Copyright (c) 1991, 1993, 1994
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc. 6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed 7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph 8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc. 10 * the permission of UNIX System Laboratories, Inc.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -70,85 +70,178 @@ @@ -70,85 +70,178 @@
70 * 70 *
71 * @(#)ufs_quota.c 8.5 (Berkeley) 5/20/95 71 * @(#)ufs_quota.c 8.5 (Berkeley) 5/20/95
72 * From NetBSD: ufs_quota.c,v 1.70 2011/03/24 17:05:46 bouyer Exp 72 * From NetBSD: ufs_quota.c,v 1.70 2011/03/24 17:05:46 bouyer Exp
73 */ 73 */
74 74
75/* 75/*
76 * Note that both of the copyrights above are moderately spurious; 76 * Note that both of the copyrights above are moderately spurious;
77 * this code should almost certainly have the Copyright 2010 Manuel 77 * this code should almost certainly have the Copyright 2010 Manuel
78 * Bouyer notice and license found in e.g. sys/ufs/ufs/quota2_subr.c. 78 * Bouyer notice and license found in e.g. sys/ufs/ufs/quota2_subr.c.
79 * However, they're what was on the files this code was sliced out of. 79 * However, they're what was on the files this code was sliced out of.
80 */ 80 */
81 81
82#include <sys/cdefs.h> 82#include <sys/cdefs.h>
83__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.4 2012/01/29 06:34:57 dholland Exp $"); 83__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.5 2012/01/29 06:36:06 dholland Exp $");
84 84
85#include <sys/mount.h> 85#include <sys/mount.h>
86#include <sys/quotactl.h> 86#include <sys/quotactl.h>
87#include <quota/quotaprop.h> 87#include <quota/quotaprop.h>
88 88
89static int 89static int
 90vfs_quotactl_getversion(struct mount *mp,
 91 prop_dictionary_t cmddict, int q2type,
 92 prop_array_t datas)
 93{
 94 struct vfs_quotactl_args args;
 95
 96 args.qc_type = QCT_PROPLIB;
 97 args.u.proplib.qc_cmddict = cmddict;
 98 args.u.proplib.qc_q2type = q2type;
 99 args.u.proplib.qc_datas = datas;
 100 return VFS_QUOTACTL(mp, QUOTACTL_GETVERSION, &args);
 101}
 102
 103static int
 104vfs_quotactl_quotaon(struct mount *mp,
 105 prop_dictionary_t cmddict, int q2type,
 106 prop_array_t datas)
 107{
 108 struct vfs_quotactl_args args;
 109
 110 args.qc_type = QCT_PROPLIB;
 111 args.u.proplib.qc_cmddict = cmddict;
 112 args.u.proplib.qc_q2type = q2type;
 113 args.u.proplib.qc_datas = datas;
 114 return VFS_QUOTACTL(mp, QUOTACTL_QUOTAON, &args);
 115}
 116
 117static int
 118vfs_quotactl_quotaoff(struct mount *mp,
 119 prop_dictionary_t cmddict, int q2type,
 120 prop_array_t datas)
 121{
 122 struct vfs_quotactl_args args;
 123
 124 args.qc_type = QCT_PROPLIB;
 125 args.u.proplib.qc_cmddict = cmddict;
 126 args.u.proplib.qc_q2type = q2type;
 127 args.u.proplib.qc_datas = datas;
 128 return VFS_QUOTACTL(mp, QUOTACTL_QUOTAOFF, &args);
 129}
 130
 131static int
 132vfs_quotactl_get(struct mount *mp,
 133 prop_dictionary_t cmddict, int q2type,
 134 prop_array_t datas)
 135{
 136 struct vfs_quotactl_args args;
 137
 138 args.qc_type = QCT_PROPLIB;
 139 args.u.proplib.qc_cmddict = cmddict;
 140 args.u.proplib.qc_q2type = q2type;
 141 args.u.proplib.qc_datas = datas;
 142 return VFS_QUOTACTL(mp, QUOTACTL_GET, &args);
 143}
 144
 145static int
 146vfs_quotactl_set(struct mount *mp,
 147 prop_dictionary_t cmddict, int q2type,
 148 prop_array_t datas)
 149{
 150 struct vfs_quotactl_args args;
 151
 152 args.qc_type = QCT_PROPLIB;
 153 args.u.proplib.qc_cmddict = cmddict;
 154 args.u.proplib.qc_q2type = q2type;
 155 args.u.proplib.qc_datas = datas;
 156 return VFS_QUOTACTL(mp, QUOTACTL_SET, &args);
 157}
 158
 159static int
 160vfs_quotactl_getall(struct mount *mp,
 161 prop_dictionary_t cmddict, int q2type,
 162 prop_array_t datas)
 163{
 164 struct vfs_quotactl_args args;
 165
 166 args.qc_type = QCT_PROPLIB;
 167 args.u.proplib.qc_cmddict = cmddict;
 168 args.u.proplib.qc_q2type = q2type;
 169 args.u.proplib.qc_datas = datas;
 170 return VFS_QUOTACTL(mp, QUOTACTL_GETALL, &args);
 171}
 172
 173static int
 174vfs_quotactl_clear(struct mount *mp,
 175 prop_dictionary_t cmddict, int q2type,
 176 prop_array_t datas)
 177{
 178 struct vfs_quotactl_args args;
 179
 180 args.qc_type = QCT_PROPLIB;
 181 args.u.proplib.qc_cmddict = cmddict;
 182 args.u.proplib.qc_q2type = q2type;
 183 args.u.proplib.qc_datas = datas;
 184 return VFS_QUOTACTL(mp, QUOTACTL_CLEAR, &args);
 185}
 186
 187static int
90vfs_quotactl_cmd(struct mount *mp, prop_dictionary_t cmddict) 188vfs_quotactl_cmd(struct mount *mp, prop_dictionary_t cmddict)
91{ 189{
92 int error; 190 int error;
93 const char *cmd, *type; 191 const char *cmd, *type;
94 int op; 
95 prop_array_t datas; 192 prop_array_t datas;
96 int q2type; 193 int q2type;
97 194
98 if (!prop_dictionary_get_cstring_nocopy(cmddict, "command", &cmd)) 195 if (!prop_dictionary_get_cstring_nocopy(cmddict, "command", &cmd))
99 return EINVAL; 196 return EINVAL;
100 if (!prop_dictionary_get_cstring_nocopy(cmddict, "type", &type)) 197 if (!prop_dictionary_get_cstring_nocopy(cmddict, "type", &type))
101 return EINVAL; 198 return EINVAL;
102 199
103 if (!strcmp(type, QUOTADICT_CLASS_USER)) { 200 if (!strcmp(type, QUOTADICT_CLASS_USER)) {
104 q2type = QUOTA_CLASS_USER; 201 q2type = QUOTA_CLASS_USER;
105 } else if (!strcmp(type, QUOTADICT_CLASS_GROUP)) { 202 } else if (!strcmp(type, QUOTADICT_CLASS_GROUP)) {
106 q2type = QUOTA_CLASS_GROUP; 203 q2type = QUOTA_CLASS_GROUP;
107 } else { 204 } else {
108 /* XXX this is a bad errno for this case */ 205 /* XXX this is a bad errno for this case */
109 return EOPNOTSUPP; 206 return EOPNOTSUPP;
110 } 207 }
111 208
112 datas = prop_dictionary_get(cmddict, "data"); 209 datas = prop_dictionary_get(cmddict, "data");
113 if (datas == NULL || prop_object_type(datas) != PROP_TYPE_ARRAY) 210 if (datas == NULL || prop_object_type(datas) != PROP_TYPE_ARRAY)
114 return EINVAL; 211 return EINVAL;
115 212
116 prop_object_retain(datas); 213 prop_object_retain(datas);
117 prop_dictionary_remove(cmddict, "data"); /* prepare for return */ 214 prop_dictionary_remove(cmddict, "data"); /* prepare for return */
118 215
119 if (strcmp(cmd, "get version") == 0) { 216 if (strcmp(cmd, "get version") == 0) {
120 op = QUOTACTL_GETVERSION; 217 error = vfs_quotactl_getversion(mp, cmddict, q2type, datas);
121 } else if (strcmp(cmd, "quotaon") == 0) { 218 } else if (strcmp(cmd, "quotaon") == 0) {
122 op = QUOTACTL_QUOTAON; 219 error = vfs_quotactl_quotaon(mp, cmddict, q2type, datas);
123 } else if (strcmp(cmd, "quotaoff") == 0) { 220 } else if (strcmp(cmd, "quotaoff") == 0) {
124 op = QUOTACTL_QUOTAOFF; 221 error = vfs_quotactl_quotaoff(mp, cmddict, q2type, datas);
125 } else if (strcmp(cmd, "get") == 0) { 222 } else if (strcmp(cmd, "get") == 0) {
126 op = QUOTACTL_GET; 223 error = vfs_quotactl_get(mp, cmddict, q2type, datas);
127 } else if (strcmp(cmd, "set") == 0) { 224 } else if (strcmp(cmd, "set") == 0) {
128 op = QUOTACTL_SET; 225 error = vfs_quotactl_set(mp, cmddict, q2type, datas);
129 } else if (strcmp(cmd, "getall") == 0) { 226 } else if (strcmp(cmd, "getall") == 0) {
130 op = QUOTACTL_GETALL; 227 error = vfs_quotactl_getall(mp, cmddict, q2type, datas);
131 } else if (strcmp(cmd, "clear") == 0) { 228 } else if (strcmp(cmd, "clear") == 0) {
132 op = QUOTACTL_CLEAR; 229 error = vfs_quotactl_clear(mp, cmddict, q2type, datas);
133 } else { 230 } else {
134 /* XXX this a bad errno for this case */ 231 /* XXX this a bad errno for this case */
135 error = EOPNOTSUPP; 232 error = EOPNOTSUPP;
136 goto fail; 
137 } 233 }
138 234
139 error = VFS_QUOTACTL(mp, op, cmddict, q2type, datas); 
140 
141 fail: 
142 error = (prop_dictionary_set_int8(cmddict, "return", 235 error = (prop_dictionary_set_int8(cmddict, "return",
143 error) ? 0 : ENOMEM); 236 error) ? 0 : ENOMEM);
144 prop_object_release(datas); 237 prop_object_release(datas);
145 238
146 return error; 239 return error;
147} 240}
148 241
149int 242int
150vfs_quotactl(struct mount *mp, prop_dictionary_t dict) 243vfs_quotactl(struct mount *mp, prop_dictionary_t dict)
151{ 244{
152 prop_dictionary_t cmddict; 245 prop_dictionary_t cmddict;
153 prop_array_t commands; 246 prop_array_t commands;
154 prop_object_iterator_t iter; 247 prop_object_iterator_t iter;

cvs diff -r1.428 -r1.429 src/sys/kern/vfs_subr.c (expand / switch to unified diff)

--- src/sys/kern/vfs_subr.c 2012/01/29 06:34:57 1.428
+++ src/sys/kern/vfs_subr.c 2012/01/29 06:36:06 1.429
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: vfs_subr.c,v 1.428 2012/01/29 06:34:57 dholland Exp $ */ 1/* $NetBSD: vfs_subr.c,v 1.429 2012/01/29 06:36:06 dholland Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center, by Charles M. Hannum, and by Andrew Doran. 9 * NASA Ames Research Center, by Charles M. Hannum, and by Andrew Doran.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -57,27 +57,27 @@ @@ -57,27 +57,27 @@
57 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 57 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
58 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 58 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 59 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 60 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 61 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 62 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 63 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64 * SUCH DAMAGE. 64 * SUCH DAMAGE.
65 * 65 *
66 * @(#)vfs_subr.c 8.13 (Berkeley) 4/18/94 66 * @(#)vfs_subr.c 8.13 (Berkeley) 4/18/94
67 */ 67 */
68 68
69#include <sys/cdefs.h> 69#include <sys/cdefs.h>
70__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.428 2012/01/29 06:34:57 dholland Exp $"); 70__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.429 2012/01/29 06:36:06 dholland Exp $");
71 71
72#include "opt_ddb.h" 72#include "opt_ddb.h"
73#include "opt_compat_netbsd.h" 73#include "opt_compat_netbsd.h"
74#include "opt_compat_43.h" 74#include "opt_compat_43.h"
75 75
76#include <sys/param.h> 76#include <sys/param.h>
77#include <sys/systm.h> 77#include <sys/systm.h>
78#include <sys/conf.h> 78#include <sys/conf.h>
79#include <sys/dirent.h> 79#include <sys/dirent.h>
80#include <sys/filedesc.h> 80#include <sys/filedesc.h>
81#include <sys/kernel.h> 81#include <sys/kernel.h>
82#include <sys/mount.h> 82#include <sys/mount.h>
83#include <sys/vnode.h> 83#include <sys/vnode.h>
@@ -996,35 +996,34 @@ VFS_ROOT(struct mount *mp, struct vnode  @@ -996,35 +996,34 @@ VFS_ROOT(struct mount *mp, struct vnode
996 996
997 if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) { 997 if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) {
998 KERNEL_LOCK(1, NULL); 998 KERNEL_LOCK(1, NULL);
999 } 999 }
1000 error = (*(mp->mnt_op->vfs_root))(mp, a); 1000 error = (*(mp->mnt_op->vfs_root))(mp, a);
1001 if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) { 1001 if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) {
1002 KERNEL_UNLOCK_ONE(NULL); 1002 KERNEL_UNLOCK_ONE(NULL);
1003 } 1003 }
1004 1004
1005 return error; 1005 return error;
1006} 1006}
1007 1007
1008int 1008int
1009VFS_QUOTACTL(struct mount *mp, int op, prop_dictionary_t cmddict, int objtype, 1009VFS_QUOTACTL(struct mount *mp, int op, struct vfs_quotactl_args *args)
1010 prop_array_t datas) 
1011{ 1010{
1012 int error; 1011 int error;
1013 1012
1014 if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) { 1013 if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) {
1015 KERNEL_LOCK(1, NULL); 1014 KERNEL_LOCK(1, NULL);
1016 } 1015 }
1017 error = (*(mp->mnt_op->vfs_quotactl))(mp, op, cmddict, objtype, datas); 1016 error = (*(mp->mnt_op->vfs_quotactl))(mp, op, args);
1018 if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) { 1017 if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) {
1019 KERNEL_UNLOCK_ONE(NULL); 1018 KERNEL_UNLOCK_ONE(NULL);
1020 } 1019 }
1021 1020
1022 return error; 1021 return error;
1023} 1022}
1024 1023
1025int 1024int
1026VFS_STATVFS(struct mount *mp, struct statvfs *a) 1025VFS_STATVFS(struct mount *mp, struct statvfs *a)
1027{ 1026{
1028 int error; 1027 int error;
1029 1028
1030 if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) { 1029 if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) {

cvs diff -r1.31 -r1.32 src/sys/miscfs/genfs/layer_extern.h (expand / switch to unified diff)

--- src/sys/miscfs/genfs/layer_extern.h 2012/01/29 06:34:58 1.31
+++ src/sys/miscfs/genfs/layer_extern.h 2012/01/29 06:36:06 1.32
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: layer_extern.h,v 1.31 2012/01/29 06:34:58 dholland Exp $ */ 1/* $NetBSD: layer_extern.h,v 1.32 2012/01/29 06:36:06 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1999 National Aeronautics & Space Administration 4 * Copyright (c) 1999 National Aeronautics & Space Administration
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This software was written by William Studenmund of the 7 * This software was written by William Studenmund of the
8 * Numerical Aerospace Simulation Facility, NASA Ames Research Center. 8 * Numerical Aerospace Simulation Facility, NASA Ames Research Center.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -78,27 +78,27 @@ void layerfs_init(void); @@ -78,27 +78,27 @@ void layerfs_init(void);
78void layerfs_done(void); 78void layerfs_done(void);
79int layer_node_alloc(struct mount *, struct vnode *, struct vnode **); 79int layer_node_alloc(struct mount *, struct vnode *, struct vnode **);
80int layer_node_create(struct mount *, struct vnode *, struct vnode **); 80int layer_node_create(struct mount *, struct vnode *, struct vnode **);
81struct vnode *layer_node_find(struct mount *, struct vnode *); 81struct vnode *layer_node_find(struct mount *, struct vnode *);
82 82
83#define LOG2_SIZEVNODE 7 /* log2(sizeof struct vnode) */ 83#define LOG2_SIZEVNODE 7 /* log2(sizeof struct vnode) */
84#define LAYER_NHASH(lmp, vp) \ 84#define LAYER_NHASH(lmp, vp) \
85 (&((lmp)->layerm_node_hashtbl[(((u_long)vp)>>LOG2_SIZEVNODE) & \ 85 (&((lmp)->layerm_node_hashtbl[(((u_long)vp)>>LOG2_SIZEVNODE) & \
86 (lmp)->layerm_node_hash])) 86 (lmp)->layerm_node_hash]))
87 87
88/* VFS routines */ 88/* VFS routines */
89int layerfs_start(struct mount *, int); 89int layerfs_start(struct mount *, int);
90int layerfs_root(struct mount *, struct vnode **); 90int layerfs_root(struct mount *, struct vnode **);
91int layerfs_quotactl(struct mount *, int, prop_dictionary_t, int, prop_array_t); 91int layerfs_quotactl(struct mount *, int, struct vfs_quotactl_args *);
92int layerfs_statvfs(struct mount *, struct statvfs *); 92int layerfs_statvfs(struct mount *, struct statvfs *);
93int layerfs_sync(struct mount *, int, struct kauth_cred *); 93int layerfs_sync(struct mount *, int, struct kauth_cred *);
94int layerfs_vget(struct mount *, ino_t, struct vnode **); 94int layerfs_vget(struct mount *, ino_t, struct vnode **);
95int layerfs_fhtovp(struct mount *, struct fid *, struct vnode **); 95int layerfs_fhtovp(struct mount *, struct fid *, struct vnode **);
96int layerfs_vptofh(struct vnode *, struct fid *, size_t *); 96int layerfs_vptofh(struct vnode *, struct fid *, size_t *);
97int layerfs_snapshot(struct mount *, struct vnode *, struct timespec *); 97int layerfs_snapshot(struct mount *, struct vnode *, struct timespec *);
98int layerfs_renamelock_enter(struct mount *); 98int layerfs_renamelock_enter(struct mount *);
99void layerfs_renamelock_exit(struct mount *); 99void layerfs_renamelock_exit(struct mount *);
100 100
101/* VOP routines */ 101/* VOP routines */
102int layer_bypass(void *); 102int layer_bypass(void *);
103int layer_getattr(void *); 103int layer_getattr(void *);
104int layer_inactive(void *); 104int layer_inactive(void *);

cvs diff -r1.36 -r1.37 src/sys/miscfs/genfs/layer_vfsops.c (expand / switch to unified diff)

--- src/sys/miscfs/genfs/layer_vfsops.c 2012/01/29 06:34:58 1.36
+++ src/sys/miscfs/genfs/layer_vfsops.c 2012/01/29 06:36:06 1.37
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: layer_vfsops.c,v 1.36 2012/01/29 06:34:58 dholland Exp $ */ 1/* $NetBSD: layer_vfsops.c,v 1.37 2012/01/29 06:36:06 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1999 National Aeronautics & Space Administration 4 * Copyright (c) 1999 National Aeronautics & Space Administration
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This software was written by William Studenmund of the 7 * This software was written by William Studenmund of the
8 * Numerical Aerospace Simulation Facility, NASA Ames Research Center. 8 * Numerical Aerospace Simulation Facility, NASA Ames Research Center.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -64,27 +64,27 @@ @@ -64,27 +64,27 @@
64 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 64 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
65 * SUCH DAMAGE. 65 * SUCH DAMAGE.
66 * 66 *
67 * from: Id: lofs_vfsops.c,v 1.9 1992/05/30 10:26:24 jsp Exp 67 * from: Id: lofs_vfsops.c,v 1.9 1992/05/30 10:26:24 jsp Exp
68 * from: @(#)lofs_vfsops.c 1.2 (Berkeley) 6/18/92 68 * from: @(#)lofs_vfsops.c 1.2 (Berkeley) 6/18/92
69 * @(#)null_vfsops.c 8.7 (Berkeley) 5/14/95 69 * @(#)null_vfsops.c 8.7 (Berkeley) 5/14/95
70 */ 70 */
71 71
72/* 72/*
73 * Generic layer VFS operations. 73 * Generic layer VFS operations.
74 */ 74 */
75 75
76#include <sys/cdefs.h> 76#include <sys/cdefs.h>
77__KERNEL_RCSID(0, "$NetBSD: layer_vfsops.c,v 1.36 2012/01/29 06:34:58 dholland Exp $"); 77__KERNEL_RCSID(0, "$NetBSD: layer_vfsops.c,v 1.37 2012/01/29 06:36:06 dholland Exp $");
78 78
79#include <sys/param.h> 79#include <sys/param.h>
80#include <sys/sysctl.h> 80#include <sys/sysctl.h>
81#include <sys/systm.h> 81#include <sys/systm.h>
82#include <sys/vnode.h> 82#include <sys/vnode.h>
83#include <sys/mount.h> 83#include <sys/mount.h>
84#include <sys/namei.h> 84#include <sys/namei.h>
85#include <sys/malloc.h> 85#include <sys/malloc.h>
86#include <sys/kauth.h> 86#include <sys/kauth.h>
87#include <sys/module.h> 87#include <sys/module.h>
88 88
89#include <miscfs/genfs/layer.h> 89#include <miscfs/genfs/layer.h>
90#include <miscfs/genfs/layer_extern.h> 90#include <miscfs/genfs/layer_extern.h>
@@ -131,32 +131,30 @@ layerfs_root(struct mount *mp, struct vn @@ -131,32 +131,30 @@ layerfs_root(struct mount *mp, struct vn
131 *vpp = NULL; 131 *vpp = NULL;
132 return EINVAL; 132 return EINVAL;
133 } 133 }
134 /* 134 /*
135 * Return root vnode with locked and with a reference held. 135 * Return root vnode with locked and with a reference held.
136 */ 136 */
137 vref(vp); 137 vref(vp);
138 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); 138 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
139 *vpp = vp; 139 *vpp = vp;
140 return 0; 140 return 0;
141} 141}
142 142
143int 143int
144layerfs_quotactl(struct mount *mp, int op, prop_dictionary_t dict, int objtype, 144layerfs_quotactl(struct mount *mp, int op, struct vfs_quotactl_args *args)
145 prop_array_t datas) 
146{ 145{
147 146
148 return VFS_QUOTACTL(MOUNTTOLAYERMOUNT(mp)->layerm_vfs, op, dict, 147 return VFS_QUOTACTL(MOUNTTOLAYERMOUNT(mp)->layerm_vfs, op, args);
149 objtype, datas); 
150} 148}
151 149
152int 150int
153layerfs_statvfs(struct mount *mp, struct statvfs *sbp) 151layerfs_statvfs(struct mount *mp, struct statvfs *sbp)
154{ 152{
155 struct statvfs *sbuf; 153 struct statvfs *sbuf;
156 int error; 154 int error;
157 155
158 sbuf = kmem_zalloc(sizeof(*sbuf), KM_SLEEP); 156 sbuf = kmem_zalloc(sizeof(*sbuf), KM_SLEEP);
159 if (sbuf == NULL) { 157 if (sbuf == NULL) {
160 return ENOMEM; 158 return ENOMEM;
161 } 159 }
162 error = VFS_STATVFS(MOUNTTOLAYERMOUNT(mp)->layerm_vfs, sbuf); 160 error = VFS_STATVFS(MOUNTTOLAYERMOUNT(mp)->layerm_vfs, sbuf);

cvs diff -r1.204 -r1.205 src/sys/sys/mount.h (expand / switch to unified diff)

--- src/sys/sys/mount.h 2012/01/29 06:34:57 1.204
+++ src/sys/sys/mount.h 2012/01/29 06:36:06 1.205
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mount.h,v 1.204 2012/01/29 06:34:57 dholland Exp $ */ 1/* $NetBSD: mount.h,v 1.205 2012/01/29 06:36:06 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1989, 1991, 1993 4 * Copyright (c) 1989, 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -182,44 +182,44 @@ struct mount { @@ -182,44 +182,44 @@ struct mount {
182 182
183#define VFS_MAXID 20 /* number of valid vfs ids */ 183#define VFS_MAXID 20 /* number of valid vfs ids */
184 184
185#define CTL_VFSGENCTL_NAMES { \ 185#define CTL_VFSGENCTL_NAMES { \
186 { 0, 0 }, \ 186 { 0, 0 }, \
187 { "maxtypenum", CTLTYPE_INT }, \ 187 { "maxtypenum", CTLTYPE_INT }, \
188 { "conf", CTLTYPE_NODE }, /* Special */ \ 188 { "conf", CTLTYPE_NODE }, /* Special */ \
189 { "usermount", CTLTYPE_INT }, \ 189 { "usermount", CTLTYPE_INT }, \
190 { "magiclinks", CTLTYPE_INT }, \ 190 { "magiclinks", CTLTYPE_INT }, \
191} 191}
192 192
193#if defined(_KERNEL) 193#if defined(_KERNEL)
194#include <prop/proplib.h> 194#include <prop/proplib.h>
 195struct vfs_quotactl_args;
195#if __STDC__ 196#if __STDC__
196struct nameidata; 197struct nameidata;
197#endif 198#endif
198 199
199/* 200/*
200 * Operations supported on mounted file system. 201 * Operations supported on mounted file system.
201 */ 202 */
202 203
203struct vfsops { 204struct vfsops {
204 const char *vfs_name; 205 const char *vfs_name;
205 size_t vfs_min_mount_data; 206 size_t vfs_min_mount_data;
206 int (*vfs_mount) (struct mount *, const char *, void *, 207 int (*vfs_mount) (struct mount *, const char *, void *,
207 size_t *); 208 size_t *);
208 int (*vfs_start) (struct mount *, int); 209 int (*vfs_start) (struct mount *, int);
209 int (*vfs_unmount) (struct mount *, int); 210 int (*vfs_unmount) (struct mount *, int);
210 int (*vfs_root) (struct mount *, struct vnode **); 211 int (*vfs_root) (struct mount *, struct vnode **);
211 int (*vfs_quotactl) (struct mount *, int, prop_dictionary_t, int, 212 int (*vfs_quotactl) (struct mount *, int, struct vfs_quotactl_args *);
212 prop_array_t); 
213 int (*vfs_statvfs) (struct mount *, struct statvfs *); 213 int (*vfs_statvfs) (struct mount *, struct statvfs *);
214 int (*vfs_sync) (struct mount *, int, struct kauth_cred *); 214 int (*vfs_sync) (struct mount *, int, struct kauth_cred *);
215 int (*vfs_vget) (struct mount *, ino_t, struct vnode **); 215 int (*vfs_vget) (struct mount *, ino_t, struct vnode **);
216 int (*vfs_fhtovp) (struct mount *, struct fid *, 216 int (*vfs_fhtovp) (struct mount *, struct fid *,
217 struct vnode **); 217 struct vnode **);
218 int (*vfs_vptofh) (struct vnode *, struct fid *, size_t *); 218 int (*vfs_vptofh) (struct vnode *, struct fid *, size_t *);
219 void (*vfs_init) (void); 219 void (*vfs_init) (void);
220 void (*vfs_reinit) (void); 220 void (*vfs_reinit) (void);
221 void (*vfs_done) (void); 221 void (*vfs_done) (void);
222 int (*vfs_mountroot)(void); 222 int (*vfs_mountroot)(void);
223 int (*vfs_snapshot) (struct mount *, struct vnode *, 223 int (*vfs_snapshot) (struct mount *, struct vnode *,
224 struct timespec *); 224 struct timespec *);
225 int (*vfs_extattrctl) (struct mount *, int, 225 int (*vfs_extattrctl) (struct mount *, int,
@@ -234,53 +234,53 @@ struct vfsops { @@ -234,53 +234,53 @@ struct vfsops {
234}; 234};
235 235
236/* XXX vget is actually file system internal. */ 236/* XXX vget is actually file system internal. */
237#define VFS_VGET(MP, INO, VPP) (*(MP)->mnt_op->vfs_vget)(MP, INO, VPP) 237#define VFS_VGET(MP, INO, VPP) (*(MP)->mnt_op->vfs_vget)(MP, INO, VPP)
238 238
239#define VFS_RENAMELOCK_ENTER(MP) (*(MP)->mnt_op->vfs_renamelock_enter)(MP) 239#define VFS_RENAMELOCK_ENTER(MP) (*(MP)->mnt_op->vfs_renamelock_enter)(MP)
240#define VFS_RENAMELOCK_EXIT(MP) (*(MP)->mnt_op->vfs_renamelock_exit)(MP) 240#define VFS_RENAMELOCK_EXIT(MP) (*(MP)->mnt_op->vfs_renamelock_exit)(MP)
241#define VFS_FSYNC(MP, VP, FLG) (*(MP)->mnt_op->vfs_fsync)(VP, FLG) 241#define VFS_FSYNC(MP, VP, FLG) (*(MP)->mnt_op->vfs_fsync)(VP, FLG)
242 242
243int VFS_MOUNT(struct mount *, const char *, void *, size_t *); 243int VFS_MOUNT(struct mount *, const char *, void *, size_t *);
244int VFS_START(struct mount *, int); 244int VFS_START(struct mount *, int);
245int VFS_UNMOUNT(struct mount *, int); 245int VFS_UNMOUNT(struct mount *, int);
246int VFS_ROOT(struct mount *, struct vnode **); 246int VFS_ROOT(struct mount *, struct vnode **);
247int VFS_QUOTACTL(struct mount *, int, prop_dictionary_t, int, prop_array_t); 247int VFS_QUOTACTL(struct mount *, int, struct vfs_quotactl_args *);
248int VFS_STATVFS(struct mount *, struct statvfs *); 248int VFS_STATVFS(struct mount *, struct statvfs *);
249int VFS_SYNC(struct mount *, int, struct kauth_cred *); 249int VFS_SYNC(struct mount *, int, struct kauth_cred *);
250int VFS_FHTOVP(struct mount *, struct fid *, struct vnode **); 250int VFS_FHTOVP(struct mount *, struct fid *, struct vnode **);
251int VFS_VPTOFH(struct vnode *, struct fid *, size_t *); 251int VFS_VPTOFH(struct vnode *, struct fid *, size_t *);
252int VFS_SNAPSHOT(struct mount *, struct vnode *, struct timespec *); 252int VFS_SNAPSHOT(struct mount *, struct vnode *, struct timespec *);
253int VFS_EXTATTRCTL(struct mount *, int, struct vnode *, int, const char *); 253int VFS_EXTATTRCTL(struct mount *, int, struct vnode *, int, const char *);
254int VFS_SUSPENDCTL(struct mount *, int); 254int VFS_SUSPENDCTL(struct mount *, int);
255 255
256#endif /* _KERNEL */ 256#endif /* _KERNEL */
257 257
258#ifdef _KERNEL 258#ifdef _KERNEL
259#if __STDC__ 259#if __STDC__
260struct mbuf; 260struct mbuf;
261struct vnodeopv_desc; 261struct vnodeopv_desc;
262struct kauth_cred; 262struct kauth_cred;
263#endif 263#endif
264 264
265#define VFS_MAX_MOUNT_DATA 8192 265#define VFS_MAX_MOUNT_DATA 8192
266 266
267#define VFS_PROTOS(fsname) \ 267#define VFS_PROTOS(fsname) \
268int fsname##_mount(struct mount *, const char *, void *, \ 268int fsname##_mount(struct mount *, const char *, void *, \
269 size_t *); \ 269 size_t *); \
270int fsname##_start(struct mount *, int); \ 270int fsname##_start(struct mount *, int); \
271int fsname##_unmount(struct mount *, int); \ 271int fsname##_unmount(struct mount *, int); \
272int fsname##_root(struct mount *, struct vnode **); \ 272int fsname##_root(struct mount *, struct vnode **); \
273int fsname##_quotactl(struct mount *, int, prop_dictionary_t, int, prop_array_t); \ 273int fsname##_quotactl(struct mount *, int, struct vfs_quotactl_args *); \
274int fsname##_statvfs(struct mount *, struct statvfs *); \ 274int fsname##_statvfs(struct mount *, struct statvfs *); \
275int fsname##_sync(struct mount *, int, struct kauth_cred *); \ 275int fsname##_sync(struct mount *, int, struct kauth_cred *); \
276int fsname##_vget(struct mount *, ino_t, struct vnode **); \ 276int fsname##_vget(struct mount *, ino_t, struct vnode **); \
277int fsname##_fhtovp(struct mount *, struct fid *, struct vnode **); \ 277int fsname##_fhtovp(struct mount *, struct fid *, struct vnode **); \
278int fsname##_vptofh(struct vnode *, struct fid *, size_t *); \ 278int fsname##_vptofh(struct vnode *, struct fid *, size_t *); \
279void fsname##_init(void); \ 279void fsname##_init(void); \
280void fsname##_reinit(void); \ 280void fsname##_reinit(void); \
281void fsname##_done(void); \ 281void fsname##_done(void); \
282int fsname##_mountroot(void); \ 282int fsname##_mountroot(void); \
283int fsname##_snapshot(struct mount *, struct vnode *, \ 283int fsname##_snapshot(struct mount *, struct vnode *, \
284 struct timespec *); \ 284 struct timespec *); \
285int fsname##_extattrctl(struct mount *, int, struct vnode *, int, \ 285int fsname##_extattrctl(struct mount *, int, struct vnode *, int, \
286 const char *); \ 286 const char *); \

cvs diff -r1.2 -r1.3 src/sys/sys/quotactl.h (expand / switch to unified diff)

--- src/sys/sys/quotactl.h 2012/01/29 06:34:57 1.2
+++ src/sys/sys/quotactl.h 2012/01/29 06:36:06 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: quotactl.h,v 1.2 2012/01/29 06:34:57 dholland Exp $ */ 1/* $NetBSD: quotactl.h,v 1.3 2012/01/29 06:36:06 dholland Exp $ */
2/*- 2/*-
3 * Copyright (c) 2011 The NetBSD Foundation, Inc. 3 * Copyright (c) 2011 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to The NetBSD Foundation 6 * This code is derived from software contributed to The NetBSD Foundation
7 * by David A. Holland. 7 * by David A. Holland.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -36,14 +36,29 @@ @@ -36,14 +36,29 @@
36 * really, anything that isn't libquota or inside the kernel) should 36 * really, anything that isn't libquota or inside the kernel) should
37 * use the <quota.h> API instead. 37 * use the <quota.h> API instead.
38 */ 38 */
39 39
40/* Command codes. */ 40/* Command codes. */
41#define QUOTACTL_GETVERSION 0 41#define QUOTACTL_GETVERSION 0
42#define QUOTACTL_QUOTAON 1 42#define QUOTACTL_QUOTAON 1
43#define QUOTACTL_QUOTAOFF 2 43#define QUOTACTL_QUOTAOFF 2
44#define QUOTACTL_GET 3 44#define QUOTACTL_GET 3
45#define QUOTACTL_SET 4 45#define QUOTACTL_SET 4
46#define QUOTACTL_GETALL 5 46#define QUOTACTL_GETALL 5
47#define QUOTACTL_CLEAR 6 47#define QUOTACTL_CLEAR 6
48 48
 49/* Argument encoding. */
 50enum vfs_quotactl_argtypes {
 51 QCT_PROPLIB, /* getversion, quotaon/off, get, set, getall, clear */
 52};
 53struct vfs_quotactl_args {
 54 enum vfs_quotactl_argtypes qc_type;
 55 union {
 56 struct {
 57 prop_dictionary_t qc_cmddict;
 58 int qc_q2type;
 59 prop_array_t qc_datas;
 60 } proplib;
 61 } u;
 62};
 63
49#endif /* _SYS_QUOTACTL_H_ */ 64#endif /* _SYS_QUOTACTL_H_ */

cvs diff -r1.68 -r1.69 src/sys/ufs/ufs/ufs_extern.h (expand / switch to unified diff)

--- src/sys/ufs/ufs/ufs_extern.h 2012/01/29 06:34:58 1.68
+++ src/sys/ufs/ufs/ufs_extern.h 2012/01/29 06:36:07 1.69
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ufs_extern.h,v 1.68 2012/01/29 06:34:58 dholland Exp $ */ 1/* $NetBSD: ufs_extern.h,v 1.69 2012/01/29 06:36:07 dholland Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1991, 1993, 1994 4 * Copyright (c) 1991, 1993, 1994
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -139,43 +139,43 @@ int ufs_parentcheck(struct vnode *, stru @@ -139,43 +139,43 @@ int ufs_parentcheck(struct vnode *, stru
139 int *, struct vnode **); 139 int *, struct vnode **);
140int ufs_blkatoff(struct vnode *, off_t, char **, struct buf **, bool); 140int ufs_blkatoff(struct vnode *, off_t, char **, struct buf **, bool);
141 141
142/* ufs_quota.c */ 142/* ufs_quota.c */
143/* 143/*
144 * Flags to chkdq() and chkiq() 144 * Flags to chkdq() and chkiq()
145 */ 145 */
146#define FORCE 0x01 /* force usage changes independent of limits */ 146#define FORCE 0x01 /* force usage changes independent of limits */
147void ufsquota_init(struct inode *); 147void ufsquota_init(struct inode *);
148void ufsquota_free(struct inode *); 148void ufsquota_free(struct inode *);
149int chkdq(struct inode *, int64_t, kauth_cred_t, int); 149int chkdq(struct inode *, int64_t, kauth_cred_t, int);
150int chkiq(struct inode *, int32_t, kauth_cred_t, int); 150int chkiq(struct inode *, int32_t, kauth_cred_t, int);
151int quota_handle_cmd(struct mount *, struct lwp *, int, 151int quota_handle_cmd(struct mount *, struct lwp *, int,
152 prop_dictionary_t, int, prop_array_t); 152 struct vfs_quotactl_args *);
153 153
154int qsync(struct mount *); 154int qsync(struct mount *);
155 155
156/* ufs_quota1.c */ 156/* ufs_quota1.c */
157int quota1_umount(struct mount *, int); 157int quota1_umount(struct mount *, int);
158 158
159/* ufs_quota2.c */ 159/* ufs_quota2.c */
160int quota2_umount(struct mount *, int); 160int quota2_umount(struct mount *, int);
161 161
162/* ufs_vfsops.c */ 162/* ufs_vfsops.c */
163void ufs_init(void); 163void ufs_init(void);
164void ufs_reinit(void); 164void ufs_reinit(void);
165void ufs_done(void); 165void ufs_done(void);
166int ufs_start(struct mount *, int); 166int ufs_start(struct mount *, int);
167int ufs_root(struct mount *, struct vnode **); 167int ufs_root(struct mount *, struct vnode **);
168int ufs_quotactl(struct mount *, int, prop_dictionary_t, int, prop_array_t); 168int ufs_quotactl(struct mount *, int, struct vfs_quotactl_args *);
169int ufs_fhtovp(struct mount *, struct ufid *, struct vnode **); 169int ufs_fhtovp(struct mount *, struct ufid *, struct vnode **);
170 170
171/* ufs_vnops.c */ 171/* ufs_vnops.c */
172void ufs_vinit(struct mount *, int (**)(void *), 172void ufs_vinit(struct mount *, int (**)(void *),
173 int (**)(void *), struct vnode **); 173 int (**)(void *), struct vnode **);
174int ufs_makeinode(int, struct vnode *, const struct ufs_lookup_results *, 174int ufs_makeinode(int, struct vnode *, const struct ufs_lookup_results *,
175 struct vnode **, struct componentname *); 175 struct vnode **, struct componentname *);
176int ufs_gop_alloc(struct vnode *, off_t, off_t, int, kauth_cred_t); 176int ufs_gop_alloc(struct vnode *, off_t, off_t, int, kauth_cred_t);
177void ufs_gop_markupdate(struct vnode *, int); 177void ufs_gop_markupdate(struct vnode *, int);
178 178
179/* 179/*
180 * Snapshot function prototypes. 180 * Snapshot function prototypes.
181 */ 181 */

cvs diff -r1.71 -r1.72 src/sys/ufs/ufs/ufs_quota.c (expand / switch to unified diff)

--- src/sys/ufs/ufs/ufs_quota.c 2012/01/29 06:34:58 1.71
+++ src/sys/ufs/ufs/ufs_quota.c 2012/01/29 06:36:07 1.72
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ufs_quota.c,v 1.71 2012/01/29 06:34:58 dholland Exp $ */ 1/* $NetBSD: ufs_quota.c,v 1.72 2012/01/29 06:36:07 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1982, 1986, 1990, 1993, 1995 4 * Copyright (c) 1982, 1986, 1990, 1993, 1995
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Robert Elz at The University of Melbourne. 8 * Robert Elz at The University of Melbourne.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE. 32 * SUCH DAMAGE.
33 * 33 *
34 * @(#)ufs_quota.c 8.5 (Berkeley) 5/20/95 34 * @(#)ufs_quota.c 8.5 (Berkeley) 5/20/95
35 */ 35 */
36 36
37#include <sys/cdefs.h> 37#include <sys/cdefs.h>
38__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.71 2012/01/29 06:34:58 dholland Exp $"); 38__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.72 2012/01/29 06:36:07 dholland Exp $");
39 39
40#if defined(_KERNEL_OPT) 40#if defined(_KERNEL_OPT)
41#include "opt_quota.h" 41#include "opt_quota.h"
42#endif  42#endif
43#include <sys/param.h> 43#include <sys/param.h>
44#include <sys/kernel.h> 44#include <sys/kernel.h>
45#include <sys/systm.h> 45#include <sys/systm.h>
46#include <sys/namei.h> 46#include <sys/namei.h>
47#include <sys/file.h> 47#include <sys/file.h>
48#include <sys/proc.h> 48#include <sys/proc.h>
49#include <sys/vnode.h> 49#include <sys/vnode.h>
50#include <sys/mount.h> 50#include <sys/mount.h>
51#include <sys/kauth.h> 51#include <sys/kauth.h>
@@ -62,39 +62,40 @@ kmutex_t dqlock; @@ -62,39 +62,40 @@ kmutex_t dqlock;
62kcondvar_t dqcv; 62kcondvar_t dqcv;
63 63
64/* 64/*
65 * Code pertaining to management of the in-core dquot data structures. 65 * Code pertaining to management of the in-core dquot data structures.
66 */ 66 */
67#define DQHASH(dqvp, id) \ 67#define DQHASH(dqvp, id) \
68 (((((long)(dqvp)) >> 8) + id) & dqhash) 68 (((((long)(dqvp)) >> 8) + id) & dqhash)
69static LIST_HEAD(dqhashhead, dquot) *dqhashtbl; 69static LIST_HEAD(dqhashhead, dquot) *dqhashtbl;
70static u_long dqhash; 70static u_long dqhash;
71static pool_cache_t dquot_cache; 71static pool_cache_t dquot_cache;
72 72
73 73
74static int quota_handle_cmd_get_version(struct mount *, struct lwp *, 74static int quota_handle_cmd_get_version(struct mount *, struct lwp *,
75 prop_dictionary_t, prop_array_t); 75 struct vfs_quotactl_args *args);
76static int quota_handle_cmd_get(struct mount *, struct lwp *, 76static int quota_handle_cmd_get(struct mount *, struct lwp *,
77 prop_dictionary_t, int, prop_array_t); 77 struct vfs_quotactl_args *args);
78static int quota_handle_cmd_set(struct mount *, struct lwp *, 78static int quota_handle_cmd_set(struct mount *, struct lwp *,
79 prop_dictionary_t, int, prop_array_t); 79 struct vfs_quotactl_args *args);
80static int quota_handle_cmd_getall(struct mount *, struct lwp *, 80static int quota_handle_cmd_getall(struct mount *, struct lwp *,
81 prop_dictionary_t, int, prop_array_t); 81 struct vfs_quotactl_args *args);
82static int quota_handle_cmd_clear(struct mount *, struct lwp *, 82static int quota_handle_cmd_clear(struct mount *, struct lwp *,
83 prop_dictionary_t, int, prop_array_t); 83 struct vfs_quotactl_args *args);
84static int quota_handle_cmd_quotaon(struct mount *, struct lwp *,  84static int quota_handle_cmd_quotaon(struct mount *, struct lwp *,
85 prop_dictionary_t, int, prop_array_t); 85 struct vfs_quotactl_args *args);
86static int quota_handle_cmd_quotaoff(struct mount *, struct lwp *,  86static int quota_handle_cmd_quotaoff(struct mount *, struct lwp *,
87 prop_dictionary_t, int, prop_array_t); 87 struct vfs_quotactl_args *args);
 88
88/* 89/*
89 * Initialize the quota fields of an inode. 90 * Initialize the quota fields of an inode.
90 */ 91 */
91void 92void
92ufsquota_init(struct inode *ip) 93ufsquota_init(struct inode *ip)
93{ 94{
94 int i; 95 int i;
95 96
96 for (i = 0; i < MAXQUOTAS; i++) 97 for (i = 0; i < MAXQUOTAS; i++)
97 ip->i_dquot[i] = NODQUOT; 98 ip->i_dquot[i] = NODQUOT;
98} 99}
99 100
100/* 101/*
@@ -144,71 +145,77 @@ chkiq(struct inode *ip, int32_t change,  @@ -144,71 +145,77 @@ chkiq(struct inode *ip, int32_t change,
144#ifdef QUOTA 145#ifdef QUOTA
145 if (ip->i_ump->um_flags & UFS_QUOTA) 146 if (ip->i_ump->um_flags & UFS_QUOTA)
146 return chkiq1(ip, change, cred, flags); 147 return chkiq1(ip, change, cred, flags);
147#endif 148#endif
148#ifdef QUOTA2 149#ifdef QUOTA2
149 if (ip->i_ump->um_flags & UFS_QUOTA2) 150 if (ip->i_ump->um_flags & UFS_QUOTA2)
150 return chkiq2(ip, change, cred, flags); 151 return chkiq2(ip, change, cred, flags);
151#endif 152#endif
152 return 0; 153 return 0;
153} 154}
154 155
155int 156int
156quota_handle_cmd(struct mount *mp, struct lwp *l, int op, 157quota_handle_cmd(struct mount *mp, struct lwp *l, int op,
157 prop_dictionary_t cmddict, int q2type, prop_array_t datas) 158 struct vfs_quotactl_args *args)
158{ 159{
159 int error = 0; 160 int error = 0;
160 161
161 KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY); 
162 
163 switch (op) { 162 switch (op) {
164 case QUOTACTL_GETVERSION: 163 case QUOTACTL_GETVERSION:
165 error = quota_handle_cmd_get_version(mp, l, cmddict, datas); 164 error = quota_handle_cmd_get_version(mp, l, args);
166 break; 165 break;
167 case QUOTACTL_QUOTAON: 166 case QUOTACTL_QUOTAON:
168 error = quota_handle_cmd_quotaon(mp, l, cmddict, 167 error = quota_handle_cmd_quotaon(mp, l, args);
169 q2type, datas); 
170 break; 168 break;
171 case QUOTACTL_QUOTAOFF: 169 case QUOTACTL_QUOTAOFF:
172 error = quota_handle_cmd_quotaoff(mp, l, cmddict, 170 error = quota_handle_cmd_quotaoff(mp, l, args);
173 q2type, datas); 
174 break; 171 break;
175 case QUOTACTL_GET: 172 case QUOTACTL_GET:
176 error = quota_handle_cmd_get(mp, l, cmddict, q2type, datas); 173 error = quota_handle_cmd_get(mp, l, args);
177 break; 174 break;
178 case QUOTACTL_SET: 175 case QUOTACTL_SET:
179 error = quota_handle_cmd_set(mp, l, cmddict, q2type, datas); 176 error = quota_handle_cmd_set(mp, l, args);
180 break; 177 break;
181 case QUOTACTL_GETALL: 178 case QUOTACTL_GETALL:
182 error = quota_handle_cmd_getall(mp, l, cmddict, q2type, datas); 179 error = quota_handle_cmd_getall(mp, l, args);
183 break; 180 break;
184 case QUOTACTL_CLEAR: 181 case QUOTACTL_CLEAR:
185 error = quota_handle_cmd_clear(mp, l, cmddict, q2type, datas); 182 error = quota_handle_cmd_clear(mp, l, args);
186 break; 183 break;
187 default: 184 default:
188 panic("Invalid quotactl operation %d\n", op); 185 panic("Invalid quotactl operation %d\n", op);
189 } 186 }
190 187
191 return error; 188 return error;
192} 189}
193 190
194static int  191static int
195quota_handle_cmd_get_version(struct mount *mp, struct lwp *l,  192quota_handle_cmd_get_version(struct mount *mp, struct lwp *l,
196 prop_dictionary_t cmddict, prop_array_t datas) 193 struct vfs_quotactl_args *args)
197{ 194{
198 struct ufsmount *ump = VFSTOUFS(mp); 195 struct ufsmount *ump = VFSTOUFS(mp);
199 prop_array_t replies; 196 prop_array_t replies;
200 prop_dictionary_t data; 197 prop_dictionary_t data;
201 int error = 0; 198 int error = 0;
 199 prop_dictionary_t cmddict;
 200 prop_array_t datas;
 201
 202 KASSERT(args->qc_type == QCT_PROPLIB);
 203 cmddict = args->u.proplib.qc_cmddict;
 204 /* qc_q2type not used */
 205 datas = args->u.proplib.qc_datas;
 206
 207 KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY);
 208 KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY);
202 209
203 if ((ump->um_flags & (UFS_QUOTA|UFS_QUOTA2)) == 0) 210 if ((ump->um_flags & (UFS_QUOTA|UFS_QUOTA2)) == 0)
204 return EOPNOTSUPP; 211 return EOPNOTSUPP;
205 212
206 replies = prop_array_create(); 213 replies = prop_array_create();
207 if (replies == NULL) 214 if (replies == NULL)
208 return ENOMEM; 215 return ENOMEM;
209 216
210 data = prop_dictionary_create(); 217 data = prop_dictionary_create();
211 if (data == NULL) { 218 if (data == NULL) {
212 prop_object_release(replies); 219 prop_object_release(replies);
213 return ENOMEM; 220 return ENOMEM;
214 } 221 }
@@ -239,35 +246,46 @@ quota_handle_cmd_get_version(struct moun @@ -239,35 +246,46 @@ quota_handle_cmd_get_version(struct moun
239 246
240/* XXX shouldn't all this be in kauth ? */ 247/* XXX shouldn't all this be in kauth ? */
241static int 248static int
242quota_get_auth(struct mount *mp, struct lwp *l, uid_t id) { 249quota_get_auth(struct mount *mp, struct lwp *l, uid_t id) {
243 /* The user can always query about his own quota. */ 250 /* The user can always query about his own quota. */
244 if (id == kauth_cred_getuid(l->l_cred)) 251 if (id == kauth_cred_getuid(l->l_cred))
245 return 0; 252 return 0;
246 return kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA, 253 return kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA,
247 KAUTH_REQ_SYSTEM_FS_QUOTA_GET, mp, KAUTH_ARG(id), NULL); 254 KAUTH_REQ_SYSTEM_FS_QUOTA_GET, mp, KAUTH_ARG(id), NULL);
248} 255}
249 256
250static int  257static int
251quota_handle_cmd_get(struct mount *mp, struct lwp *l,  258quota_handle_cmd_get(struct mount *mp, struct lwp *l,
252 prop_dictionary_t cmddict, int type, prop_array_t datas) 259 struct vfs_quotactl_args *args)
253{ 260{
254 prop_array_t replies; 261 prop_array_t replies;
255 prop_object_iterator_t iter; 262 prop_object_iterator_t iter;
256 prop_dictionary_t data; 263 prop_dictionary_t data;
257 uint32_t id; 264 uint32_t id;
258 struct ufsmount *ump = VFSTOUFS(mp); 265 struct ufsmount *ump = VFSTOUFS(mp);
259 int error, defaultq = 0; 266 int error, defaultq = 0;
260 const char *idstr; 267 const char *idstr;
 268 prop_dictionary_t cmddict;
 269 int q2type;
 270 prop_array_t datas;
 271
 272 KASSERT(args->qc_type == QCT_PROPLIB);
 273 cmddict = args->u.proplib.qc_cmddict;
 274 q2type = args->u.proplib.qc_q2type;
 275 datas = args->u.proplib.qc_datas;
 276
 277 KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY);
 278 KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY);
261 279
262 if ((ump->um_flags & (UFS_QUOTA|UFS_QUOTA2)) == 0) 280 if ((ump->um_flags & (UFS_QUOTA|UFS_QUOTA2)) == 0)
263 return EOPNOTSUPP; 281 return EOPNOTSUPP;
264  282
265 replies = prop_array_create(); 283 replies = prop_array_create();
266 if (replies == NULL) 284 if (replies == NULL)
267 return ENOMEM; 285 return ENOMEM;
268 286
269 iter = prop_array_iterator(datas); 287 iter = prop_array_iterator(datas);
270 if (iter == NULL) { 288 if (iter == NULL) {
271 prop_object_release(replies); 289 prop_object_release(replies);
272 return ENOMEM; 290 return ENOMEM;
273 } 291 }
@@ -282,67 +300,78 @@ quota_handle_cmd_get(struct mount *mp, s @@ -282,67 +300,78 @@ quota_handle_cmd_get(struct mount *mp, s
282 } 300 }
283 id = 0; 301 id = 0;
284 defaultq = 1; 302 defaultq = 1;
285 } else { 303 } else {
286 defaultq = 0; 304 defaultq = 0;
287 } 305 }
288 error = quota_get_auth(mp, l, id); 306 error = quota_get_auth(mp, l, id);
289 if (error == EPERM) 307 if (error == EPERM)
290 continue; 308 continue;
291 if (error != 0)  309 if (error != 0)
292 goto err; 310 goto err;
293#ifdef QUOTA 311#ifdef QUOTA
294 if (ump->um_flags & UFS_QUOTA) 312 if (ump->um_flags & UFS_QUOTA)
295 error = quota1_handle_cmd_get(ump, type, id, defaultq, 313 error = quota1_handle_cmd_get(ump, q2type, id, defaultq,
296 replies); 314 replies);
297 else 315 else
298#endif 316#endif
299#ifdef QUOTA2 317#ifdef QUOTA2
300 if (ump->um_flags & UFS_QUOTA2) { 318 if (ump->um_flags & UFS_QUOTA2) {
301 error = quota2_handle_cmd_get(ump, type, id, defaultq, 319 error = quota2_handle_cmd_get(ump, q2type, id, defaultq,
302 replies); 320 replies);
303 } else 321 } else
304#endif 322#endif
305 panic("quota_handle_cmd_get: no support ?"); 323 panic("quota_handle_cmd_get: no support ?");
306  324
307 if (error == ENOENT) 325 if (error == ENOENT)
308 continue; 326 continue;
309 if (error != 0) 327 if (error != 0)
310 goto err; 328 goto err;
311 } 329 }
312 prop_object_iterator_release(iter); 330 prop_object_iterator_release(iter);
313 if (!prop_dictionary_set_and_rel(cmddict, "data", replies)) { 331 if (!prop_dictionary_set_and_rel(cmddict, "data", replies)) {
314 error = ENOMEM; 332 error = ENOMEM;
315 } else { 333 } else {
316 error = 0; 334 error = 0;
317 } 335 }
318 return error; 336 return error;
319err: 337err:
320 prop_object_iterator_release(iter); 338 prop_object_iterator_release(iter);
321 prop_object_release(replies); 339 prop_object_release(replies);
322 return error; 340 return error;
323} 341}
324 342
325static int  343static int
326quota_handle_cmd_set(struct mount *mp, struct lwp *l,  344quota_handle_cmd_set(struct mount *mp, struct lwp *l,
327 prop_dictionary_t cmddict, int type, prop_array_t datas) 345 struct vfs_quotactl_args *args)
328{ 346{
329 prop_array_t replies; 347 prop_array_t replies;
330 prop_object_iterator_t iter; 348 prop_object_iterator_t iter;
331 prop_dictionary_t data; 349 prop_dictionary_t data;
332 uint32_t id; 350 uint32_t id;
333 struct ufsmount *ump = VFSTOUFS(mp); 351 struct ufsmount *ump = VFSTOUFS(mp);
334 int error, defaultq = 0; 352 int error, defaultq = 0;
335 const char *idstr; 353 const char *idstr;
 354 prop_dictionary_t cmddict;
 355 int q2type;
 356 prop_array_t datas;
 357
 358 KASSERT(args->qc_type == QCT_PROPLIB);
 359 cmddict = args->u.proplib.qc_cmddict;
 360 q2type = args->u.proplib.qc_q2type;
 361 datas = args->u.proplib.qc_datas;
 362
 363 KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY);
 364 KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY);
336 365
337 if ((ump->um_flags & (UFS_QUOTA|UFS_QUOTA2)) == 0) 366 if ((ump->um_flags & (UFS_QUOTA|UFS_QUOTA2)) == 0)
338 return EOPNOTSUPP; 367 return EOPNOTSUPP;
339  368
340 replies = prop_array_create(); 369 replies = prop_array_create();
341 if (replies == NULL) 370 if (replies == NULL)
342 return ENOMEM; 371 return ENOMEM;
343 372
344 iter = prop_array_iterator(datas); 373 iter = prop_array_iterator(datas);
345 if (iter == NULL) { 374 if (iter == NULL) {
346 prop_object_release(replies); 375 prop_object_release(replies);
347 return ENOMEM; 376 return ENOMEM;
348 } 377 }
@@ -354,65 +383,76 @@ quota_handle_cmd_set(struct mount *mp, s @@ -354,65 +383,76 @@ quota_handle_cmd_set(struct mount *mp, s
354 if (strcmp(idstr, "default")) 383 if (strcmp(idstr, "default"))
355 continue; 384 continue;
356 id = 0; 385 id = 0;
357 defaultq = 1; 386 defaultq = 1;
358 } else { 387 } else {
359 defaultq = 0; 388 defaultq = 0;
360 } 389 }
361 error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA, 390 error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA,
362 KAUTH_REQ_SYSTEM_FS_QUOTA_MANAGE, mp, KAUTH_ARG(id), NULL); 391 KAUTH_REQ_SYSTEM_FS_QUOTA_MANAGE, mp, KAUTH_ARG(id), NULL);
363 if (error != 0) 392 if (error != 0)
364 goto err; 393 goto err;
365#ifdef QUOTA 394#ifdef QUOTA
366 if (ump->um_flags & UFS_QUOTA) 395 if (ump->um_flags & UFS_QUOTA)
367 error = quota1_handle_cmd_set(ump, type, id, defaultq, 396 error = quota1_handle_cmd_set(ump, q2type, id, defaultq,
368 data); 397 data);
369 else 398 else
370#endif 399#endif
371#ifdef QUOTA2 400#ifdef QUOTA2
372 if (ump->um_flags & UFS_QUOTA2) { 401 if (ump->um_flags & UFS_QUOTA2) {
373 error = quota2_handle_cmd_set(ump, type, id, defaultq, 402 error = quota2_handle_cmd_set(ump, q2type, id, defaultq,
374 data); 403 data);
375 } else 404 } else
376#endif 405#endif
377 panic("quota_handle_cmd_get: no support ?"); 406 panic("quota_handle_cmd_get: no support ?");
378  407
379 if (error && error != ENOENT) 408 if (error && error != ENOENT)
380 goto err; 409 goto err;
381 } 410 }
382 prop_object_iterator_release(iter); 411 prop_object_iterator_release(iter);
383 if (!prop_dictionary_set_and_rel(cmddict, "data", replies)) { 412 if (!prop_dictionary_set_and_rel(cmddict, "data", replies)) {
384 error = ENOMEM; 413 error = ENOMEM;
385 } else { 414 } else {
386 error = 0; 415 error = 0;
387 } 416 }
388 return error; 417 return error;
389err: 418err:
390 prop_object_iterator_release(iter); 419 prop_object_iterator_release(iter);
391 prop_object_release(replies); 420 prop_object_release(replies);
392 return error; 421 return error;
393} 422}
394 423
395static int  424static int
396quota_handle_cmd_clear(struct mount *mp, struct lwp *l,  425quota_handle_cmd_clear(struct mount *mp, struct lwp *l,
397 prop_dictionary_t cmddict, int type, prop_array_t datas) 426 struct vfs_quotactl_args *args)
398{ 427{
399 prop_array_t replies; 428 prop_array_t replies;
400 prop_object_iterator_t iter; 429 prop_object_iterator_t iter;
401 prop_dictionary_t data; 430 prop_dictionary_t data;
402 uint32_t id; 431 uint32_t id;
403 struct ufsmount *ump = VFSTOUFS(mp); 432 struct ufsmount *ump = VFSTOUFS(mp);
404 int error, defaultq = 0; 433 int error, defaultq = 0;
405 const char *idstr; 434 const char *idstr;
 435 prop_dictionary_t cmddict;
 436 int q2type;
 437 prop_array_t datas;
 438
 439 KASSERT(args->qc_type == QCT_PROPLIB);
 440 cmddict = args->u.proplib.qc_cmddict;
 441 q2type = args->u.proplib.qc_q2type;
 442 datas = args->u.proplib.qc_datas;
 443
 444 KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY);
 445 KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY);
406 446
407 if ((ump->um_flags & UFS_QUOTA2) == 0) 447 if ((ump->um_flags & UFS_QUOTA2) == 0)
408 return EOPNOTSUPP; 448 return EOPNOTSUPP;
409  449
410 replies = prop_array_create(); 450 replies = prop_array_create();
411 if (replies == NULL) 451 if (replies == NULL)
412 return ENOMEM; 452 return ENOMEM;
413 453
414 iter = prop_array_iterator(datas); 454 iter = prop_array_iterator(datas);
415 if (iter == NULL) { 455 if (iter == NULL) {
416 prop_object_release(replies); 456 prop_object_release(replies);
417 return ENOMEM; 457 return ENOMEM;
418 } 458 }
@@ -424,138 +464,171 @@ quota_handle_cmd_clear(struct mount *mp, @@ -424,138 +464,171 @@ quota_handle_cmd_clear(struct mount *mp,
424 if (strcmp(idstr, "default")) 464 if (strcmp(idstr, "default"))
425 continue; 465 continue;
426 id = 0; 466 id = 0;
427 defaultq = 1; 467 defaultq = 1;
428 } else { 468 } else {
429 defaultq = 0; 469 defaultq = 0;
430 } 470 }
431 error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA, 471 error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA,
432 KAUTH_REQ_SYSTEM_FS_QUOTA_MANAGE, mp, KAUTH_ARG(id), NULL); 472 KAUTH_REQ_SYSTEM_FS_QUOTA_MANAGE, mp, KAUTH_ARG(id), NULL);
433 if (error != 0) 473 if (error != 0)
434 goto err; 474 goto err;
435#ifdef QUOTA2 475#ifdef QUOTA2
436 if (ump->um_flags & UFS_QUOTA2) { 476 if (ump->um_flags & UFS_QUOTA2) {
437 error = quota2_handle_cmd_clear(ump, type, id, defaultq, 477 error = quota2_handle_cmd_clear(ump, q2type, id, defaultq,
438 data); 478 data);
439 } else 479 } else
440#endif 480#endif
441 panic("quota_handle_cmd_get: no support ?"); 481 panic("quota_handle_cmd_get: no support ?");
442  482
443 if (error && error != ENOENT) 483 if (error && error != ENOENT)
444 goto err; 484 goto err;
445 } 485 }
446 prop_object_iterator_release(iter); 486 prop_object_iterator_release(iter);
447 if (!prop_dictionary_set_and_rel(cmddict, "data", replies)) { 487 if (!prop_dictionary_set_and_rel(cmddict, "data", replies)) {
448 error = ENOMEM; 488 error = ENOMEM;
449 } else { 489 } else {
450 error = 0; 490 error = 0;
451 } 491 }
452 return error; 492 return error;
453err: 493err:
454 prop_object_iterator_release(iter); 494 prop_object_iterator_release(iter);
455 prop_object_release(replies); 495 prop_object_release(replies);
456 return error; 496 return error;
457} 497}
458 498
459static int  499static int
460quota_handle_cmd_getall(struct mount *mp, struct lwp *l,  500quota_handle_cmd_getall(struct mount *mp, struct lwp *l,
461 prop_dictionary_t cmddict, int type, prop_array_t datas) 501 struct vfs_quotactl_args *args)
462{ 502{
463 prop_array_t replies; 503 prop_array_t replies;
464 struct ufsmount *ump = VFSTOUFS(mp); 504 struct ufsmount *ump = VFSTOUFS(mp);
465 int error; 505 int error;
 506 prop_dictionary_t cmddict;
 507 int q2type;
 508 prop_array_t datas;
 509
 510 KASSERT(args->qc_type == QCT_PROPLIB);
 511 cmddict = args->u.proplib.qc_cmddict;
 512 q2type = args->u.proplib.qc_q2type;
 513 datas = args->u.proplib.qc_datas;
 514
 515 KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY);
 516 KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY);
466 517
467 if ((ump->um_flags & UFS_QUOTA2) == 0) 518 if ((ump->um_flags & UFS_QUOTA2) == 0)
468 return EOPNOTSUPP; 519 return EOPNOTSUPP;
469  520
470 error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA, 521 error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA,
471 KAUTH_REQ_SYSTEM_FS_QUOTA_GET, mp, NULL, NULL); 522 KAUTH_REQ_SYSTEM_FS_QUOTA_GET, mp, NULL, NULL);
472 if (error) 523 if (error)
473 return error; 524 return error;
474  525
475 replies = prop_array_create(); 526 replies = prop_array_create();
476 if (replies == NULL) 527 if (replies == NULL)
477 return ENOMEM; 528 return ENOMEM;
478 529
479#ifdef QUOTA2 530#ifdef QUOTA2
480 if (ump->um_flags & UFS_QUOTA2) { 531 if (ump->um_flags & UFS_QUOTA2) {
481 error = quota2_handle_cmd_getall(ump, type, replies); 532 error = quota2_handle_cmd_getall(ump, q2type, replies);
482 } else 533 } else
483#endif 534#endif
484 panic("quota_handle_cmd_getall: no support ?"); 535 panic("quota_handle_cmd_getall: no support ?");
485 if (!prop_dictionary_set_and_rel(cmddict, "data", replies)) { 536 if (!prop_dictionary_set_and_rel(cmddict, "data", replies)) {
486 error = ENOMEM; 537 error = ENOMEM;
487 } else { 538 } else {
488 error = 0; 539 error = 0;
489 } 540 }
490 return error; 541 return error;
491} 542}
492 543
493static int  544static int
494quota_handle_cmd_quotaon(struct mount *mp, struct lwp *l,  545quota_handle_cmd_quotaon(struct mount *mp, struct lwp *l,
495 prop_dictionary_t cmddict, int type, prop_array_t datas) 546 struct vfs_quotactl_args *args)
496{ 547{
497 prop_dictionary_t data; 548 prop_dictionary_t data;
498 struct ufsmount *ump = VFSTOUFS(mp); 549 struct ufsmount *ump = VFSTOUFS(mp);
499 int error; 550 int error;
500 const char *qfile; 551 const char *qfile;
 552 prop_dictionary_t cmddict;
 553 int q2type;
 554 prop_array_t datas;
 555
 556 KASSERT(args->qc_type == QCT_PROPLIB);
 557 cmddict = args->u.proplib.qc_cmddict;
 558 q2type = args->u.proplib.qc_q2type;
 559 datas = args->u.proplib.qc_datas;
 560
 561 KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY);
 562 KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY);
501 563
502 if ((ump->um_flags & UFS_QUOTA2) != 0) 564 if ((ump->um_flags & UFS_QUOTA2) != 0)
503 return EBUSY; 565 return EBUSY;
504  566
505 if (prop_array_count(datas) != 1) 567 if (prop_array_count(datas) != 1)
506 return EINVAL; 568 return EINVAL;
507 569
508 data = prop_array_get(datas, 0); 570 data = prop_array_get(datas, 0);
509 if (data == NULL) 571 if (data == NULL)
510 return ENOMEM; 572 return ENOMEM;
511 if (!prop_dictionary_get_cstring_nocopy(data, "quotafile", 573 if (!prop_dictionary_get_cstring_nocopy(data, "quotafile",
512 &qfile)) 574 &qfile))
513 return EINVAL; 575 return EINVAL;
514 576
515 error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA, 577 error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA,
516 KAUTH_REQ_SYSTEM_FS_QUOTA_ONOFF, mp, NULL, NULL); 578 KAUTH_REQ_SYSTEM_FS_QUOTA_ONOFF, mp, NULL, NULL);
517 if (error != 0) { 579 if (error != 0) {
518 return error; 580 return error;
519 } 581 }
520#ifdef QUOTA 582#ifdef QUOTA
521 error = quota1_handle_cmd_quotaon(l, ump, type, qfile); 583 error = quota1_handle_cmd_quotaon(l, ump, q2type, qfile);
522#else 584#else
523 error = EOPNOTSUPP; 585 error = EOPNOTSUPP;
524#endif 586#endif
525  587
526 return error; 588 return error;
527} 589}
528 590
529static int  591static int
530quota_handle_cmd_quotaoff(struct mount *mp, struct lwp *l,  592quota_handle_cmd_quotaoff(struct mount *mp, struct lwp *l,
531 prop_dictionary_t cmddict, int type, prop_array_t datas) 593 struct vfs_quotactl_args *args)
532{ 594{
533 struct ufsmount *ump = VFSTOUFS(mp); 595 struct ufsmount *ump = VFSTOUFS(mp);
534 int error; 596 int error;
 597 prop_dictionary_t cmddict;
 598 int q2type;
 599 prop_array_t datas;
 600
 601 KASSERT(args->qc_type == QCT_PROPLIB);
 602 cmddict = args->u.proplib.qc_cmddict;
 603 q2type = args->u.proplib.qc_q2type;
 604 datas = args->u.proplib.qc_datas;
 605
 606 KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY);
 607 KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY);
535 608
536 if ((ump->um_flags & UFS_QUOTA2) != 0) 609 if ((ump->um_flags & UFS_QUOTA2) != 0)
537 return EOPNOTSUPP; 610 return EOPNOTSUPP;
538  611
539 if (prop_array_count(datas) != 0) 612 if (prop_array_count(datas) != 0)
540 return EINVAL; 613 return EINVAL;
541 614
542 error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA, 615 error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FS_QUOTA,
543 KAUTH_REQ_SYSTEM_FS_QUOTA_ONOFF, mp, NULL, NULL); 616 KAUTH_REQ_SYSTEM_FS_QUOTA_ONOFF, mp, NULL, NULL);
544 if (error != 0) { 617 if (error != 0) {
545 return error; 618 return error;
546 } 619 }
547#ifdef QUOTA 620#ifdef QUOTA
548 error = quota1_handle_cmd_quotaoff(l, ump, type); 621 error = quota1_handle_cmd_quotaoff(l, ump, q2type);
549#else 622#else
550 error = EOPNOTSUPP; 623 error = EOPNOTSUPP;
551#endif 624#endif
552  625
553 return error; 626 return error;
554} 627}
555 628
556/* 629/*
557 * Initialize the quota system. 630 * Initialize the quota system.
558 */ 631 */
559void 632void
560dqinit(void) 633dqinit(void)
561{ 634{

cvs diff -r1.45 -r1.46 src/sys/ufs/ufs/ufs_vfsops.c (expand / switch to unified diff)

--- src/sys/ufs/ufs/ufs_vfsops.c 2012/01/29 06:34:58 1.45
+++ src/sys/ufs/ufs/ufs_vfsops.c 2012/01/29 06:36:07 1.46
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ufs_vfsops.c,v 1.45 2012/01/29 06:34:58 dholland Exp $ */ 1/* $NetBSD: ufs_vfsops.c,v 1.46 2012/01/29 06:36:07 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1991, 1993, 1994 4 * Copyright (c) 1991, 1993, 1994
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc. 6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed 7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph 8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc. 10 * the permission of UNIX System Laboratories, Inc.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -27,44 +27,45 @@ @@ -27,44 +27,45 @@
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE. 34 * SUCH DAMAGE.
35 * 35 *
36 * @(#)ufs_vfsops.c 8.8 (Berkeley) 5/20/95 36 * @(#)ufs_vfsops.c 8.8 (Berkeley) 5/20/95
37 */ 37 */
38 38
39#include <sys/cdefs.h> 39#include <sys/cdefs.h>
40__KERNEL_RCSID(0, "$NetBSD: ufs_vfsops.c,v 1.45 2012/01/29 06:34:58 dholland Exp $"); 40__KERNEL_RCSID(0, "$NetBSD: ufs_vfsops.c,v 1.46 2012/01/29 06:36:07 dholland Exp $");
41 41
42#if defined(_KERNEL_OPT) 42#if defined(_KERNEL_OPT)
43#include "opt_ffs.h" 43#include "opt_ffs.h"
44#include "opt_quota.h" 44#include "opt_quota.h"
45#endif 45#endif
46 46
47#include <sys/param.h> 47#include <sys/param.h>
48#include <sys/mbuf.h> 48#include <sys/mbuf.h>
49#include <sys/mount.h> 49#include <sys/mount.h>
50#include <sys/proc.h> 50#include <sys/proc.h>
51#include <sys/buf.h> 51#include <sys/buf.h>
52#include <sys/vnode.h> 52#include <sys/vnode.h>
53#include <sys/kmem.h> 53#include <sys/kmem.h>
54#include <sys/kauth.h> 54#include <sys/kauth.h>
55 55
56#include <miscfs/specfs/specdev.h> 56#include <miscfs/specfs/specdev.h>
57 57
 58#include <sys/quotactl.h>
58#include <ufs/ufs/quota.h> 59#include <ufs/ufs/quota.h>
59#include <ufs/ufs/inode.h> 60#include <ufs/ufs/inode.h>
60#include <ufs/ufs/ufsmount.h> 61#include <ufs/ufs/ufsmount.h>
61#include <ufs/ufs/ufs_extern.h> 62#include <ufs/ufs/ufs_extern.h>
62#ifdef UFS_DIRHASH 63#ifdef UFS_DIRHASH
63#include <ufs/ufs/dirhash.h> 64#include <ufs/ufs/dirhash.h>
64#endif 65#endif
65#include <quota/quotaprop.h> 66#include <quota/quotaprop.h>
66 67
67/* how many times ufs_init() was called */ 68/* how many times ufs_init() was called */
68static int ufs_initcount = 0; 69static int ufs_initcount = 0;
69 70
70pool_cache_t ufs_direct_cache; 71pool_cache_t ufs_direct_cache;
@@ -90,50 +91,47 @@ ufs_root(struct mount *mp, struct vnode  @@ -90,50 +91,47 @@ ufs_root(struct mount *mp, struct vnode
90 struct vnode *nvp; 91 struct vnode *nvp;
91 int error; 92 int error;
92 93
93 if ((error = VFS_VGET(mp, (ino_t)ROOTINO, &nvp)) != 0) 94 if ((error = VFS_VGET(mp, (ino_t)ROOTINO, &nvp)) != 0)
94 return (error); 95 return (error);
95 *vpp = nvp; 96 *vpp = nvp;
96 return (0); 97 return (0);
97} 98}
98 99
99/* 100/*
100 * Do operations associated with quotas 101 * Do operations associated with quotas
101 */ 102 */
102int 103int
103ufs_quotactl(struct mount *mp, int op, prop_dictionary_t cmddict, int q2type, 104ufs_quotactl(struct mount *mp, int op, struct vfs_quotactl_args *args)
104 prop_array_t datas) 
105{ 105{
106 struct lwp *l = curlwp; 106 struct lwp *l = curlwp;
107 107
108#if !defined(QUOTA) && !defined(QUOTA2) 108#if !defined(QUOTA) && !defined(QUOTA2)
109 (void) mp; 109 (void) mp;
110 (void) cmddict; 110 (void) cmddict;
111 (void) dummy; 111 (void) dummy;
112 (void) l; 112 (void) l;
113 return (EOPNOTSUPP); 113 return (EOPNOTSUPP);
114#else 114#else
115 int error; 115 int error;
116 
117 KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY); 
118 116
119 /* Mark the mount busy, as we're passing it to kauth(9). */ 117 /* Mark the mount busy, as we're passing it to kauth(9). */
120 error = vfs_busy(mp, NULL); 118 error = vfs_busy(mp, NULL);
121 if (error) { 119 if (error) {
122 return (error); 120 return (error);
123 } 121 }
124 mutex_enter(&mp->mnt_updating); 122 mutex_enter(&mp->mnt_updating);
125 123
126 error = quota_handle_cmd(mp, l, op, cmddict, q2type, datas); 124 error = quota_handle_cmd(mp, l, op, args);
127 125
128 mutex_exit(&mp->mnt_updating); 126 mutex_exit(&mp->mnt_updating);
129 vfs_unbusy(mp, false, NULL); 127 vfs_unbusy(mp, false, NULL);
130 return (error); 128 return (error);
131#endif 129#endif
132} 130}
133  131
134#if 0 132#if 0
135 switch (cmd) { 133 switch (cmd) {
136 case Q_SYNC: 134 case Q_SYNC:
137 break; 135 break;
138 136
139 case Q_GETQUOTA: 137 case Q_GETQUOTA: