diff --git a/sys/kern/vfs_quotactl.c b/sys/kern/vfs_quotactl.c index 9d29db6ac8d0..cd462f6eb8d5 100644 --- a/sys/kern/vfs_quotactl.c +++ b/sys/kern/vfs_quotactl.c @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_quotactl.c,v 1.4 2012/01/29 06:34:57 dholland Exp $ */ +/* $NetBSD: vfs_quotactl.c,v 1.5 2012/01/29 06:36:06 dholland Exp $ */ /* * Copyright (c) 1991, 1993, 1994 @@ -80,18 +80,115 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.4 2012/01/29 06:34:57 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.5 2012/01/29 06:36:06 dholland Exp $"); #include #include #include +static int +vfs_quotactl_getversion(struct mount *mp, + prop_dictionary_t cmddict, int q2type, + prop_array_t datas) +{ + struct vfs_quotactl_args args; + + args.qc_type = QCT_PROPLIB; + args.u.proplib.qc_cmddict = cmddict; + args.u.proplib.qc_q2type = q2type; + args.u.proplib.qc_datas = datas; + return VFS_QUOTACTL(mp, QUOTACTL_GETVERSION, &args); +} + +static int +vfs_quotactl_quotaon(struct mount *mp, + prop_dictionary_t cmddict, int q2type, + prop_array_t datas) +{ + struct vfs_quotactl_args args; + + args.qc_type = QCT_PROPLIB; + args.u.proplib.qc_cmddict = cmddict; + args.u.proplib.qc_q2type = q2type; + args.u.proplib.qc_datas = datas; + return VFS_QUOTACTL(mp, QUOTACTL_QUOTAON, &args); +} + +static int +vfs_quotactl_quotaoff(struct mount *mp, + prop_dictionary_t cmddict, int q2type, + prop_array_t datas) +{ + struct vfs_quotactl_args args; + + args.qc_type = QCT_PROPLIB; + args.u.proplib.qc_cmddict = cmddict; + args.u.proplib.qc_q2type = q2type; + args.u.proplib.qc_datas = datas; + return VFS_QUOTACTL(mp, QUOTACTL_QUOTAOFF, &args); +} + +static int +vfs_quotactl_get(struct mount *mp, + prop_dictionary_t cmddict, int q2type, + prop_array_t datas) +{ + struct vfs_quotactl_args args; + + args.qc_type = QCT_PROPLIB; + args.u.proplib.qc_cmddict = cmddict; + args.u.proplib.qc_q2type = q2type; + args.u.proplib.qc_datas = datas; + return VFS_QUOTACTL(mp, QUOTACTL_GET, &args); +} + +static int +vfs_quotactl_set(struct mount *mp, + prop_dictionary_t cmddict, int q2type, + prop_array_t datas) +{ + struct vfs_quotactl_args args; + + args.qc_type = QCT_PROPLIB; + args.u.proplib.qc_cmddict = cmddict; + args.u.proplib.qc_q2type = q2type; + args.u.proplib.qc_datas = datas; + return VFS_QUOTACTL(mp, QUOTACTL_SET, &args); +} + +static int +vfs_quotactl_getall(struct mount *mp, + prop_dictionary_t cmddict, int q2type, + prop_array_t datas) +{ + struct vfs_quotactl_args args; + + args.qc_type = QCT_PROPLIB; + args.u.proplib.qc_cmddict = cmddict; + args.u.proplib.qc_q2type = q2type; + args.u.proplib.qc_datas = datas; + return VFS_QUOTACTL(mp, QUOTACTL_GETALL, &args); +} + +static int +vfs_quotactl_clear(struct mount *mp, + prop_dictionary_t cmddict, int q2type, + prop_array_t datas) +{ + struct vfs_quotactl_args args; + + args.qc_type = QCT_PROPLIB; + args.u.proplib.qc_cmddict = cmddict; + args.u.proplib.qc_q2type = q2type; + args.u.proplib.qc_datas = datas; + return VFS_QUOTACTL(mp, QUOTACTL_CLEAR, &args); +} + static int vfs_quotactl_cmd(struct mount *mp, prop_dictionary_t cmddict) { int error; const char *cmd, *type; - int op; prop_array_t datas; int q2type; @@ -117,28 +214,24 @@ vfs_quotactl_cmd(struct mount *mp, prop_dictionary_t cmddict) prop_dictionary_remove(cmddict, "data"); /* prepare for return */ if (strcmp(cmd, "get version") == 0) { - op = QUOTACTL_GETVERSION; + error = vfs_quotactl_getversion(mp, cmddict, q2type, datas); } else if (strcmp(cmd, "quotaon") == 0) { - op = QUOTACTL_QUOTAON; + error = vfs_quotactl_quotaon(mp, cmddict, q2type, datas); } else if (strcmp(cmd, "quotaoff") == 0) { - op = QUOTACTL_QUOTAOFF; + error = vfs_quotactl_quotaoff(mp, cmddict, q2type, datas); } else if (strcmp(cmd, "get") == 0) { - op = QUOTACTL_GET; + error = vfs_quotactl_get(mp, cmddict, q2type, datas); } else if (strcmp(cmd, "set") == 0) { - op = QUOTACTL_SET; + error = vfs_quotactl_set(mp, cmddict, q2type, datas); } else if (strcmp(cmd, "getall") == 0) { - op = QUOTACTL_GETALL; + error = vfs_quotactl_getall(mp, cmddict, q2type, datas); } else if (strcmp(cmd, "clear") == 0) { - op = QUOTACTL_CLEAR; + error = vfs_quotactl_clear(mp, cmddict, q2type, datas); } else { /* XXX this a bad errno for this case */ error = EOPNOTSUPP; - goto fail; } - error = VFS_QUOTACTL(mp, op, cmddict, q2type, datas); - - fail: error = (prop_dictionary_set_int8(cmddict, "return", error) ? 0 : ENOMEM); prop_object_release(datas); diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index e429f6f11fc1..888908b246bb 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_subr.c,v 1.428 2012/01/29 06:34:57 dholland Exp $ */ +/* $NetBSD: vfs_subr.c,v 1.429 2012/01/29 06:36:06 dholland Exp $ */ /*- * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.428 2012/01/29 06:34:57 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.429 2012/01/29 06:36:06 dholland Exp $"); #include "opt_ddb.h" #include "opt_compat_netbsd.h" @@ -1006,15 +1006,14 @@ VFS_ROOT(struct mount *mp, struct vnode **a) } int -VFS_QUOTACTL(struct mount *mp, int op, prop_dictionary_t cmddict, int objtype, - prop_array_t datas) +VFS_QUOTACTL(struct mount *mp, int op, struct vfs_quotactl_args *args) { int error; if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) { KERNEL_LOCK(1, NULL); } - error = (*(mp->mnt_op->vfs_quotactl))(mp, op, cmddict, objtype, datas); + error = (*(mp->mnt_op->vfs_quotactl))(mp, op, args); if ((mp->mnt_iflag & IMNT_MPSAFE) == 0) { KERNEL_UNLOCK_ONE(NULL); } diff --git a/sys/miscfs/genfs/layer_extern.h b/sys/miscfs/genfs/layer_extern.h index 7bf8f8ebb70f..7da6fce511ec 100644 --- a/sys/miscfs/genfs/layer_extern.h +++ b/sys/miscfs/genfs/layer_extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: layer_extern.h,v 1.31 2012/01/29 06:34:58 dholland Exp $ */ +/* $NetBSD: layer_extern.h,v 1.32 2012/01/29 06:36:06 dholland Exp $ */ /* * Copyright (c) 1999 National Aeronautics & Space Administration @@ -88,7 +88,7 @@ struct vnode *layer_node_find(struct mount *, struct vnode *); /* VFS routines */ int layerfs_start(struct mount *, int); int layerfs_root(struct mount *, struct vnode **); -int layerfs_quotactl(struct mount *, int, prop_dictionary_t, int, prop_array_t); +int layerfs_quotactl(struct mount *, int, struct vfs_quotactl_args *); int layerfs_statvfs(struct mount *, struct statvfs *); int layerfs_sync(struct mount *, int, struct kauth_cred *); int layerfs_vget(struct mount *, ino_t, struct vnode **); diff --git a/sys/miscfs/genfs/layer_vfsops.c b/sys/miscfs/genfs/layer_vfsops.c index b372e141ba28..06ecadf44266 100644 --- a/sys/miscfs/genfs/layer_vfsops.c +++ b/sys/miscfs/genfs/layer_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: layer_vfsops.c,v 1.36 2012/01/29 06:34:58 dholland Exp $ */ +/* $NetBSD: layer_vfsops.c,v 1.37 2012/01/29 06:36:06 dholland Exp $ */ /* * Copyright (c) 1999 National Aeronautics & Space Administration @@ -74,7 +74,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: layer_vfsops.c,v 1.36 2012/01/29 06:34:58 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: layer_vfsops.c,v 1.37 2012/01/29 06:36:06 dholland Exp $"); #include #include @@ -141,12 +141,10 @@ layerfs_root(struct mount *mp, struct vnode **vpp) } int -layerfs_quotactl(struct mount *mp, int op, prop_dictionary_t dict, int objtype, - prop_array_t datas) +layerfs_quotactl(struct mount *mp, int op, struct vfs_quotactl_args *args) { - return VFS_QUOTACTL(MOUNTTOLAYERMOUNT(mp)->layerm_vfs, op, dict, - objtype, datas); + return VFS_QUOTACTL(MOUNTTOLAYERMOUNT(mp)->layerm_vfs, op, args); } int diff --git a/sys/sys/mount.h b/sys/sys/mount.h index 71954eed43be..59fba90fb94c 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -1,4 +1,4 @@ -/* $NetBSD: mount.h,v 1.204 2012/01/29 06:34:57 dholland Exp $ */ +/* $NetBSD: mount.h,v 1.205 2012/01/29 06:36:06 dholland Exp $ */ /* * Copyright (c) 1989, 1991, 1993 @@ -192,6 +192,7 @@ struct mount { #if defined(_KERNEL) #include +struct vfs_quotactl_args; #if __STDC__ struct nameidata; #endif @@ -208,8 +209,7 @@ struct vfsops { int (*vfs_start) (struct mount *, int); int (*vfs_unmount) (struct mount *, int); int (*vfs_root) (struct mount *, struct vnode **); - int (*vfs_quotactl) (struct mount *, int, prop_dictionary_t, int, - prop_array_t); + int (*vfs_quotactl) (struct mount *, int, struct vfs_quotactl_args *); int (*vfs_statvfs) (struct mount *, struct statvfs *); int (*vfs_sync) (struct mount *, int, struct kauth_cred *); int (*vfs_vget) (struct mount *, ino_t, struct vnode **); @@ -244,7 +244,7 @@ int VFS_MOUNT(struct mount *, const char *, void *, size_t *); int VFS_START(struct mount *, int); int VFS_UNMOUNT(struct mount *, int); int VFS_ROOT(struct mount *, struct vnode **); -int VFS_QUOTACTL(struct mount *, int, prop_dictionary_t, int, prop_array_t); +int VFS_QUOTACTL(struct mount *, int, struct vfs_quotactl_args *); int VFS_STATVFS(struct mount *, struct statvfs *); int VFS_SYNC(struct mount *, int, struct kauth_cred *); int VFS_FHTOVP(struct mount *, struct fid *, struct vnode **); @@ -270,7 +270,7 @@ int fsname##_mount(struct mount *, const char *, void *, \ int fsname##_start(struct mount *, int); \ int fsname##_unmount(struct mount *, int); \ int fsname##_root(struct mount *, struct vnode **); \ -int fsname##_quotactl(struct mount *, int, prop_dictionary_t, int, prop_array_t); \ +int fsname##_quotactl(struct mount *, int, struct vfs_quotactl_args *); \ int fsname##_statvfs(struct mount *, struct statvfs *); \ int fsname##_sync(struct mount *, int, struct kauth_cred *); \ int fsname##_vget(struct mount *, ino_t, struct vnode **); \ diff --git a/sys/sys/quotactl.h b/sys/sys/quotactl.h index 309f4608d415..8271144296bf 100644 --- a/sys/sys/quotactl.h +++ b/sys/sys/quotactl.h @@ -1,4 +1,4 @@ -/* $NetBSD: quotactl.h,v 1.2 2012/01/29 06:34:57 dholland Exp $ */ +/* $NetBSD: quotactl.h,v 1.3 2012/01/29 06:36:06 dholland Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. @@ -46,4 +46,19 @@ #define QUOTACTL_GETALL 5 #define QUOTACTL_CLEAR 6 +/* Argument encoding. */ +enum vfs_quotactl_argtypes { + QCT_PROPLIB, /* getversion, quotaon/off, get, set, getall, clear */ +}; +struct vfs_quotactl_args { + enum vfs_quotactl_argtypes qc_type; + union { + struct { + prop_dictionary_t qc_cmddict; + int qc_q2type; + prop_array_t qc_datas; + } proplib; + } u; +}; + #endif /* _SYS_QUOTACTL_H_ */ diff --git a/sys/ufs/ufs/ufs_extern.h b/sys/ufs/ufs/ufs_extern.h index da0f8f0c605a..9536fc441063 100644 --- a/sys/ufs/ufs/ufs_extern.h +++ b/sys/ufs/ufs/ufs_extern.h @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_extern.h,v 1.68 2012/01/29 06:34:58 dholland Exp $ */ +/* $NetBSD: ufs_extern.h,v 1.69 2012/01/29 06:36:07 dholland Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -149,7 +149,7 @@ void ufsquota_free(struct inode *); int chkdq(struct inode *, int64_t, kauth_cred_t, int); int chkiq(struct inode *, int32_t, kauth_cred_t, int); int quota_handle_cmd(struct mount *, struct lwp *, int, - prop_dictionary_t, int, prop_array_t); + struct vfs_quotactl_args *); int qsync(struct mount *); @@ -165,7 +165,7 @@ void ufs_reinit(void); void ufs_done(void); int ufs_start(struct mount *, int); int ufs_root(struct mount *, struct vnode **); -int ufs_quotactl(struct mount *, int, prop_dictionary_t, int, prop_array_t); +int ufs_quotactl(struct mount *, int, struct vfs_quotactl_args *); int ufs_fhtovp(struct mount *, struct ufid *, struct vnode **); /* ufs_vnops.c */ diff --git a/sys/ufs/ufs/ufs_quota.c b/sys/ufs/ufs/ufs_quota.c index 369273bb9b0c..2296c4932a7d 100644 --- a/sys/ufs/ufs/ufs_quota.c +++ b/sys/ufs/ufs/ufs_quota.c @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_quota.c,v 1.71 2012/01/29 06:34:58 dholland Exp $ */ +/* $NetBSD: ufs_quota.c,v 1.72 2012/01/29 06:36:07 dholland Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993, 1995 @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.71 2012/01/29 06:34:58 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.72 2012/01/29 06:36:07 dholland Exp $"); #if defined(_KERNEL_OPT) #include "opt_quota.h" @@ -72,19 +72,20 @@ static pool_cache_t dquot_cache; static int quota_handle_cmd_get_version(struct mount *, struct lwp *, - prop_dictionary_t, prop_array_t); + struct vfs_quotactl_args *args); static int quota_handle_cmd_get(struct mount *, struct lwp *, - prop_dictionary_t, int, prop_array_t); + struct vfs_quotactl_args *args); static int quota_handle_cmd_set(struct mount *, struct lwp *, - prop_dictionary_t, int, prop_array_t); + struct vfs_quotactl_args *args); static int quota_handle_cmd_getall(struct mount *, struct lwp *, - prop_dictionary_t, int, prop_array_t); + struct vfs_quotactl_args *args); static int quota_handle_cmd_clear(struct mount *, struct lwp *, - prop_dictionary_t, int, prop_array_t); + struct vfs_quotactl_args *args); static int quota_handle_cmd_quotaon(struct mount *, struct lwp *, - prop_dictionary_t, int, prop_array_t); + struct vfs_quotactl_args *args); static int quota_handle_cmd_quotaoff(struct mount *, struct lwp *, - prop_dictionary_t, int, prop_array_t); + struct vfs_quotactl_args *args); + /* * Initialize the quota fields of an inode. */ @@ -154,35 +155,31 @@ chkiq(struct inode *ip, int32_t change, kauth_cred_t cred, int flags) int quota_handle_cmd(struct mount *mp, struct lwp *l, int op, - prop_dictionary_t cmddict, int q2type, prop_array_t datas) + struct vfs_quotactl_args *args) { int error = 0; - KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY); - switch (op) { case QUOTACTL_GETVERSION: - error = quota_handle_cmd_get_version(mp, l, cmddict, datas); + error = quota_handle_cmd_get_version(mp, l, args); break; case QUOTACTL_QUOTAON: - error = quota_handle_cmd_quotaon(mp, l, cmddict, - q2type, datas); + error = quota_handle_cmd_quotaon(mp, l, args); break; case QUOTACTL_QUOTAOFF: - error = quota_handle_cmd_quotaoff(mp, l, cmddict, - q2type, datas); + error = quota_handle_cmd_quotaoff(mp, l, args); break; case QUOTACTL_GET: - error = quota_handle_cmd_get(mp, l, cmddict, q2type, datas); + error = quota_handle_cmd_get(mp, l, args); break; case QUOTACTL_SET: - error = quota_handle_cmd_set(mp, l, cmddict, q2type, datas); + error = quota_handle_cmd_set(mp, l, args); break; case QUOTACTL_GETALL: - error = quota_handle_cmd_getall(mp, l, cmddict, q2type, datas); + error = quota_handle_cmd_getall(mp, l, args); break; case QUOTACTL_CLEAR: - error = quota_handle_cmd_clear(mp, l, cmddict, q2type, datas); + error = quota_handle_cmd_clear(mp, l, args); break; default: panic("Invalid quotactl operation %d\n", op); @@ -193,12 +190,22 @@ quota_handle_cmd(struct mount *mp, struct lwp *l, int op, static int quota_handle_cmd_get_version(struct mount *mp, struct lwp *l, - prop_dictionary_t cmddict, prop_array_t datas) + struct vfs_quotactl_args *args) { struct ufsmount *ump = VFSTOUFS(mp); prop_array_t replies; prop_dictionary_t data; int error = 0; + prop_dictionary_t cmddict; + prop_array_t datas; + + KASSERT(args->qc_type == QCT_PROPLIB); + cmddict = args->u.proplib.qc_cmddict; + /* qc_q2type not used */ + datas = args->u.proplib.qc_datas; + + KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY); + KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY); if ((ump->um_flags & (UFS_QUOTA|UFS_QUOTA2)) == 0) return EOPNOTSUPP; @@ -249,7 +256,7 @@ quota_get_auth(struct mount *mp, struct lwp *l, uid_t id) { static int quota_handle_cmd_get(struct mount *mp, struct lwp *l, - prop_dictionary_t cmddict, int type, prop_array_t datas) + struct vfs_quotactl_args *args) { prop_array_t replies; prop_object_iterator_t iter; @@ -258,6 +265,17 @@ quota_handle_cmd_get(struct mount *mp, struct lwp *l, struct ufsmount *ump = VFSTOUFS(mp); int error, defaultq = 0; const char *idstr; + prop_dictionary_t cmddict; + int q2type; + prop_array_t datas; + + KASSERT(args->qc_type == QCT_PROPLIB); + cmddict = args->u.proplib.qc_cmddict; + q2type = args->u.proplib.qc_q2type; + datas = args->u.proplib.qc_datas; + + KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY); + KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY); if ((ump->um_flags & (UFS_QUOTA|UFS_QUOTA2)) == 0) return EOPNOTSUPP; @@ -292,13 +310,13 @@ quota_handle_cmd_get(struct mount *mp, struct lwp *l, goto err; #ifdef QUOTA if (ump->um_flags & UFS_QUOTA) - error = quota1_handle_cmd_get(ump, type, id, defaultq, + error = quota1_handle_cmd_get(ump, q2type, id, defaultq, replies); else #endif #ifdef QUOTA2 if (ump->um_flags & UFS_QUOTA2) { - error = quota2_handle_cmd_get(ump, type, id, defaultq, + error = quota2_handle_cmd_get(ump, q2type, id, defaultq, replies); } else #endif @@ -324,7 +342,7 @@ err: static int quota_handle_cmd_set(struct mount *mp, struct lwp *l, - prop_dictionary_t cmddict, int type, prop_array_t datas) + struct vfs_quotactl_args *args) { prop_array_t replies; prop_object_iterator_t iter; @@ -333,6 +351,17 @@ quota_handle_cmd_set(struct mount *mp, struct lwp *l, struct ufsmount *ump = VFSTOUFS(mp); int error, defaultq = 0; const char *idstr; + prop_dictionary_t cmddict; + int q2type; + prop_array_t datas; + + KASSERT(args->qc_type == QCT_PROPLIB); + cmddict = args->u.proplib.qc_cmddict; + q2type = args->u.proplib.qc_q2type; + datas = args->u.proplib.qc_datas; + + KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY); + KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY); if ((ump->um_flags & (UFS_QUOTA|UFS_QUOTA2)) == 0) return EOPNOTSUPP; @@ -364,13 +393,13 @@ quota_handle_cmd_set(struct mount *mp, struct lwp *l, goto err; #ifdef QUOTA if (ump->um_flags & UFS_QUOTA) - error = quota1_handle_cmd_set(ump, type, id, defaultq, + error = quota1_handle_cmd_set(ump, q2type, id, defaultq, data); else #endif #ifdef QUOTA2 if (ump->um_flags & UFS_QUOTA2) { - error = quota2_handle_cmd_set(ump, type, id, defaultq, + error = quota2_handle_cmd_set(ump, q2type, id, defaultq, data); } else #endif @@ -394,7 +423,7 @@ err: static int quota_handle_cmd_clear(struct mount *mp, struct lwp *l, - prop_dictionary_t cmddict, int type, prop_array_t datas) + struct vfs_quotactl_args *args) { prop_array_t replies; prop_object_iterator_t iter; @@ -403,6 +432,17 @@ quota_handle_cmd_clear(struct mount *mp, struct lwp *l, struct ufsmount *ump = VFSTOUFS(mp); int error, defaultq = 0; const char *idstr; + prop_dictionary_t cmddict; + int q2type; + prop_array_t datas; + + KASSERT(args->qc_type == QCT_PROPLIB); + cmddict = args->u.proplib.qc_cmddict; + q2type = args->u.proplib.qc_q2type; + datas = args->u.proplib.qc_datas; + + KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY); + KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY); if ((ump->um_flags & UFS_QUOTA2) == 0) return EOPNOTSUPP; @@ -434,7 +474,7 @@ quota_handle_cmd_clear(struct mount *mp, struct lwp *l, goto err; #ifdef QUOTA2 if (ump->um_flags & UFS_QUOTA2) { - error = quota2_handle_cmd_clear(ump, type, id, defaultq, + error = quota2_handle_cmd_clear(ump, q2type, id, defaultq, data); } else #endif @@ -458,11 +498,22 @@ err: static int quota_handle_cmd_getall(struct mount *mp, struct lwp *l, - prop_dictionary_t cmddict, int type, prop_array_t datas) + struct vfs_quotactl_args *args) { prop_array_t replies; struct ufsmount *ump = VFSTOUFS(mp); int error; + prop_dictionary_t cmddict; + int q2type; + prop_array_t datas; + + KASSERT(args->qc_type == QCT_PROPLIB); + cmddict = args->u.proplib.qc_cmddict; + q2type = args->u.proplib.qc_q2type; + datas = args->u.proplib.qc_datas; + + KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY); + KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY); if ((ump->um_flags & UFS_QUOTA2) == 0) return EOPNOTSUPP; @@ -478,7 +529,7 @@ quota_handle_cmd_getall(struct mount *mp, struct lwp *l, #ifdef QUOTA2 if (ump->um_flags & UFS_QUOTA2) { - error = quota2_handle_cmd_getall(ump, type, replies); + error = quota2_handle_cmd_getall(ump, q2type, replies); } else #endif panic("quota_handle_cmd_getall: no support ?"); @@ -492,12 +543,23 @@ quota_handle_cmd_getall(struct mount *mp, struct lwp *l, static int quota_handle_cmd_quotaon(struct mount *mp, struct lwp *l, - prop_dictionary_t cmddict, int type, prop_array_t datas) + struct vfs_quotactl_args *args) { prop_dictionary_t data; struct ufsmount *ump = VFSTOUFS(mp); int error; const char *qfile; + prop_dictionary_t cmddict; + int q2type; + prop_array_t datas; + + KASSERT(args->qc_type == QCT_PROPLIB); + cmddict = args->u.proplib.qc_cmddict; + q2type = args->u.proplib.qc_q2type; + datas = args->u.proplib.qc_datas; + + KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY); + KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY); if ((ump->um_flags & UFS_QUOTA2) != 0) return EBUSY; @@ -518,7 +580,7 @@ quota_handle_cmd_quotaon(struct mount *mp, struct lwp *l, return error; } #ifdef QUOTA - error = quota1_handle_cmd_quotaon(l, ump, type, qfile); + error = quota1_handle_cmd_quotaon(l, ump, q2type, qfile); #else error = EOPNOTSUPP; #endif @@ -528,10 +590,21 @@ quota_handle_cmd_quotaon(struct mount *mp, struct lwp *l, static int quota_handle_cmd_quotaoff(struct mount *mp, struct lwp *l, - prop_dictionary_t cmddict, int type, prop_array_t datas) + struct vfs_quotactl_args *args) { struct ufsmount *ump = VFSTOUFS(mp); int error; + prop_dictionary_t cmddict; + int q2type; + prop_array_t datas; + + KASSERT(args->qc_type == QCT_PROPLIB); + cmddict = args->u.proplib.qc_cmddict; + q2type = args->u.proplib.qc_q2type; + datas = args->u.proplib.qc_datas; + + KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY); + KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY); if ((ump->um_flags & UFS_QUOTA2) != 0) return EOPNOTSUPP; @@ -545,7 +618,7 @@ quota_handle_cmd_quotaoff(struct mount *mp, struct lwp *l, return error; } #ifdef QUOTA - error = quota1_handle_cmd_quotaoff(l, ump, type); + error = quota1_handle_cmd_quotaoff(l, ump, q2type); #else error = EOPNOTSUPP; #endif diff --git a/sys/ufs/ufs/ufs_vfsops.c b/sys/ufs/ufs/ufs_vfsops.c index 93b6d7b32127..b7c9aa3e852f 100644 --- a/sys/ufs/ufs/ufs_vfsops.c +++ b/sys/ufs/ufs/ufs_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_vfsops.c,v 1.45 2012/01/29 06:34:58 dholland Exp $ */ +/* $NetBSD: ufs_vfsops.c,v 1.46 2012/01/29 06:36:07 dholland Exp $ */ /* * Copyright (c) 1991, 1993, 1994 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_vfsops.c,v 1.45 2012/01/29 06:34:58 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_vfsops.c,v 1.46 2012/01/29 06:36:07 dholland Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -55,6 +55,7 @@ __KERNEL_RCSID(0, "$NetBSD: ufs_vfsops.c,v 1.45 2012/01/29 06:34:58 dholland Exp #include +#include #include #include #include @@ -100,8 +101,7 @@ ufs_root(struct mount *mp, struct vnode **vpp) * Do operations associated with quotas */ int -ufs_quotactl(struct mount *mp, int op, prop_dictionary_t cmddict, int q2type, - prop_array_t datas) +ufs_quotactl(struct mount *mp, int op, struct vfs_quotactl_args *args) { struct lwp *l = curlwp; @@ -112,9 +112,7 @@ ufs_quotactl(struct mount *mp, int op, prop_dictionary_t cmddict, int q2type, (void) l; return (EOPNOTSUPP); #else - int error; - - KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY); + int error; /* Mark the mount busy, as we're passing it to kauth(9). */ error = vfs_busy(mp, NULL); @@ -123,7 +121,7 @@ ufs_quotactl(struct mount *mp, int op, prop_dictionary_t cmddict, int q2type, } mutex_enter(&mp->mnt_updating); - error = quota_handle_cmd(mp, l, op, cmddict, q2type, datas); + error = quota_handle_cmd(mp, l, op, args); mutex_exit(&mp->mnt_updating); vfs_unbusy(mp, false, NULL);