Module Name: src Committed By: dholland Date: Sun Jan 29 07:09:53 UTC 2012
Modified Files: src/sys/kern: vfs_quotactl.c src/sys/sys: quotactl.h src/sys/ufs/ufs: ufs_quota.c ufs_quota.h ufs_quota2.c Log Message: Add QUOTACTL_CURSORSKIPIDTYPE, QUOTACTL_CURSORATEND, QUOTACTL_CURSORREWIND. This change requires a kernel version bump. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/kern/vfs_quotactl.c cvs rdiff -u -r1.25 -r1.26 src/sys/sys/quotactl.h cvs rdiff -u -r1.97 -r1.98 src/sys/ufs/ufs/ufs_quota.c cvs rdiff -u -r1.19 -r1.20 src/sys/ufs/ufs/ufs_quota.h cvs rdiff -u -r1.25 -r1.26 src/sys/ufs/ufs/ufs_quota2.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/vfs_quotactl.c diff -u src/sys/kern/vfs_quotactl.c:1.28 src/sys/kern/vfs_quotactl.c:1.29 --- src/sys/kern/vfs_quotactl.c:1.28 Sun Jan 29 07:08:58 2012 +++ src/sys/kern/vfs_quotactl.c Sun Jan 29 07:09:52 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_quotactl.c,v 1.28 2012/01/29 07:08:58 dholland Exp $ */ +/* $NetBSD: vfs_quotactl.c,v 1.29 2012/01/29 07:09:52 dholland Exp $ */ /* * Copyright (c) 1991, 1993, 1994 @@ -80,7 +80,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.28 2012/01/29 07:08:58 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.29 2012/01/29 07:09:52 dholland Exp $"); #include <sys/malloc.h> /* XXX: temporary */ #include <sys/mount.h> @@ -560,14 +560,14 @@ vfs_quotactl_getall(struct mount *mp, lastid = 0; /* value not actually referenced */ while (1) { - args.qc_type = QCT_GETALL; - args.u.getall.qc_cursor = &cursor; - args.u.getall.qc_keys = keys; - args.u.getall.qc_vals = vals; - args.u.getall.qc_maxnum = loopmax; - args.u.getall.qc_ret = &loopnum; + args.qc_type = QCT_CURSORGET; + args.u.cursorget.qc_cursor = &cursor; + args.u.cursorget.qc_keys = keys; + args.u.cursorget.qc_vals = vals; + args.u.cursorget.qc_maxnum = loopmax; + args.u.cursorget.qc_ret = &loopnum; - error = VFS_QUOTACTL(mp, QUOTACTL_GETALL, &args); + error = VFS_QUOTACTL(mp, QUOTACTL_CURSORGET, &args); if (error) { goto err; } Index: src/sys/sys/quotactl.h diff -u src/sys/sys/quotactl.h:1.25 src/sys/sys/quotactl.h:1.26 --- src/sys/sys/quotactl.h:1.25 Sun Jan 29 07:08:58 2012 +++ src/sys/sys/quotactl.h Sun Jan 29 07:09:52 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: quotactl.h,v 1.25 2012/01/29 07:08:58 dholland Exp $ */ +/* $NetBSD: quotactl.h,v 1.26 2012/01/29 07:09:52 dholland Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. @@ -57,10 +57,13 @@ struct quotakcursor { #define QUOTACTL_QUOTAOFF 2 #define QUOTACTL_GET 3 #define QUOTACTL_PUT 4 -#define QUOTACTL_GETALL 5 +#define QUOTACTL_CURSORGET 5 #define QUOTACTL_DELETE 6 #define QUOTACTL_CURSOROPEN 7 #define QUOTACTL_CURSORCLOSE 8 +#define QUOTACTL_CURSORSKIPIDTYPE 9 +#define QUOTACTL_CURSORATEND 10 +#define QUOTACTL_CURSORREWIND 11 /* Argument encoding. */ enum vfs_quotactl_argtypes { @@ -71,7 +74,10 @@ enum vfs_quotactl_argtypes { QCT_DELETE, /* delete */ QCT_CURSOROPEN, /* open cursor */ QCT_CURSORCLOSE,/* close cursor */ - QCT_GETALL, /* get all */ + QCT_CURSORGET, /* get from cursor */ + QCT_CURSORSKIPIDTYPE, /* iteration hint */ + QCT_CURSORATEND,/* test cursor */ + QCT_CURSORREWIND,/* reset cursor */ }; struct vfs_quotactl_args { enum vfs_quotactl_argtypes qc_type; @@ -103,11 +109,22 @@ struct vfs_quotactl_args { } cursorclose; struct { struct quotakcursor *qc_cursor; + unsigned qc_idtype; + } cursorskipidtype; + struct { + struct quotakcursor *qc_cursor; struct quotakey *qc_keys; struct quotaval *qc_vals; unsigned qc_maxnum; unsigned *qc_ret; - } getall; + } cursorget; + struct { + struct quotakcursor *qc_cursor; + int *qc_ret; /* really boolean */ + } cursoratend; + struct { + struct quotakcursor *qc_cursor; + } cursorrewind; } u; }; Index: src/sys/ufs/ufs/ufs_quota.c diff -u src/sys/ufs/ufs/ufs_quota.c:1.97 src/sys/ufs/ufs/ufs_quota.c:1.98 --- src/sys/ufs/ufs/ufs_quota.c:1.97 Sun Jan 29 07:08:58 2012 +++ src/sys/ufs/ufs/ufs_quota.c Sun Jan 29 07:09:52 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_quota.c,v 1.97 2012/01/29 07:08:58 dholland Exp $ */ +/* $NetBSD: ufs_quota.c,v 1.98 2012/01/29 07:09:52 dholland Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993, 1995 @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.97 2012/01/29 07:08:58 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.98 2012/01/29 07:09:52 dholland Exp $"); #if defined(_KERNEL_OPT) #include "opt_quota.h" @@ -77,7 +77,7 @@ static int quota_handle_cmd_get(struct m struct vfs_quotactl_args *args); static int quota_handle_cmd_put(struct mount *, struct lwp *, struct vfs_quotactl_args *args); -static int quota_handle_cmd_getall(struct mount *, struct lwp *, +static int quota_handle_cmd_cursorget(struct mount *, struct lwp *, struct vfs_quotactl_args *args); static int quota_handle_cmd_delete(struct mount *, struct lwp *, struct vfs_quotactl_args *args); @@ -89,6 +89,12 @@ static int quota_handle_cmd_cursoropen(s struct vfs_quotactl_args *args); static int quota_handle_cmd_cursorclose(struct mount *, struct lwp *, struct vfs_quotactl_args *args); +static int quota_handle_cmd_cursorskipidtype(struct mount *, struct lwp *, + struct vfs_quotactl_args *args); +static int quota_handle_cmd_cursoratend(struct mount *, struct lwp *, + struct vfs_quotactl_args *args); +static int quota_handle_cmd_cursorrewind(struct mount *, struct lwp *, + struct vfs_quotactl_args *args); /* * Initialize the quota fields of an inode. @@ -179,8 +185,8 @@ quota_handle_cmd(struct mount *mp, struc case QUOTACTL_PUT: error = quota_handle_cmd_put(mp, l, args); break; - case QUOTACTL_GETALL: - error = quota_handle_cmd_getall(mp, l, args); + case QUOTACTL_CURSORGET: + error = quota_handle_cmd_cursorget(mp, l, args); break; case QUOTACTL_DELETE: error = quota_handle_cmd_delete(mp, l, args); @@ -191,6 +197,15 @@ quota_handle_cmd(struct mount *mp, struc case QUOTACTL_CURSORCLOSE: error = quota_handle_cmd_cursorclose(mp, l, args); break; + case QUOTACTL_CURSORSKIPIDTYPE: + error = quota_handle_cmd_cursorskipidtype(mp, l, args); + break; + case QUOTACTL_CURSORATEND: + error = quota_handle_cmd_cursoratend(mp, l, args); + break; + case QUOTACTL_CURSORREWIND: + error = quota_handle_cmd_cursorrewind(mp, l, args); + break; default: panic("Invalid quotactl operation %d\n", op); } @@ -365,7 +380,7 @@ quota_handle_cmd_delete(struct mount *mp } static int -quota_handle_cmd_getall(struct mount *mp, struct lwp *l, +quota_handle_cmd_cursorget(struct mount *mp, struct lwp *l, struct vfs_quotactl_args *args) { struct ufsmount *ump = VFSTOUFS(mp); @@ -376,12 +391,12 @@ quota_handle_cmd_getall(struct mount *mp unsigned *ret; int error; - KASSERT(args->qc_type == QCT_GETALL); - cursor = args->u.getall.qc_cursor; - keys = args->u.getall.qc_keys; - vals = args->u.getall.qc_vals; - maxnum = args->u.getall.qc_maxnum; - ret = args->u.getall.qc_ret; + KASSERT(args->qc_type == QCT_CURSORGET); + cursor = args->u.cursorget.qc_cursor; + keys = args->u.cursorget.qc_keys; + vals = args->u.cursorget.qc_vals; + maxnum = args->u.cursorget.qc_maxnum; + ret = args->u.cursorget.qc_ret; if ((ump->um_flags & UFS_QUOTA2) == 0) return EOPNOTSUPP; @@ -393,11 +408,11 @@ quota_handle_cmd_getall(struct mount *mp #ifdef QUOTA2 if (ump->um_flags & UFS_QUOTA2) { - error = quota2_handle_cmd_getall(ump, cursor, - keys, vals, maxnum, ret); + error = quota2_handle_cmd_cursorget(ump, cursor, keys, vals, + maxnum, ret); } else #endif - panic("quota_handle_cmd_getall: no support ?"); + panic("quota_handle_cmd_cursorget: no support ?"); return error; } @@ -455,6 +470,73 @@ quota_handle_cmd_cursorclose(struct moun } static int +quota_handle_cmd_cursorskipidtype(struct mount *mp, struct lwp *l, + struct vfs_quotactl_args *args) +{ + struct ufsmount *ump = VFSTOUFS(mp); + struct quotakcursor *cursor; + int idtype; + int error; + + KASSERT(args->qc_type == QCT_CURSORSKIPIDTYPE); + cursor = args->u.cursorskipidtype.qc_cursor; + idtype = args->u.cursorskipidtype.qc_idtype; + +#ifdef QUOTA2 + if (ump->um_flags & UFS_QUOTA2) { + error = quota2_handle_cmd_cursorskipidtype(ump, cursor, idtype); + } else +#endif + error = EOPNOTSUPP; + + return error; +} + +static int +quota_handle_cmd_cursoratend(struct mount *mp, struct lwp *l, + struct vfs_quotactl_args *args) +{ + struct ufsmount *ump = VFSTOUFS(mp); + struct quotakcursor *cursor; + int *ret; + int error; + + KASSERT(args->qc_type == QCT_CURSORATEND); + cursor = args->u.cursoratend.qc_cursor; + ret = args->u.cursoratend.qc_ret; + +#ifdef QUOTA2 + if (ump->um_flags & UFS_QUOTA2) { + error = quota2_handle_cmd_cursoratend(ump, cursor, ret); + } else +#endif + error = EOPNOTSUPP; + + return error; +} + +static int +quota_handle_cmd_cursorrewind(struct mount *mp, struct lwp *l, + struct vfs_quotactl_args *args) +{ + struct ufsmount *ump = VFSTOUFS(mp); + struct quotakcursor *cursor; + int error; + + KASSERT(args->qc_type == QCT_CURSORREWIND); + cursor = args->u.cursorrewind.qc_cursor; + +#ifdef QUOTA2 + if (ump->um_flags & UFS_QUOTA2) { + error = quota2_handle_cmd_cursorrewind(ump, cursor); + } else +#endif + error = EOPNOTSUPP; + + return error; +} + +static int quota_handle_cmd_quotaon(struct mount *mp, struct lwp *l, struct vfs_quotactl_args *args) { Index: src/sys/ufs/ufs/ufs_quota.h diff -u src/sys/ufs/ufs/ufs_quota.h:1.19 src/sys/ufs/ufs/ufs_quota.h:1.20 --- src/sys/ufs/ufs/ufs_quota.h:1.19 Sun Jan 29 07:08:58 2012 +++ src/sys/ufs/ufs/ufs_quota.h Sun Jan 29 07:09:52 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_quota.h,v 1.19 2012/01/29 07:08:58 dholland Exp $ */ +/* $NetBSD: ufs_quota.h,v 1.20 2012/01/29 07:09:52 dholland Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993, 1995 @@ -131,10 +131,15 @@ int quota2_handle_cmd_get(struct ufsmoun int quota2_handle_cmd_put(struct ufsmount *, const struct quotakey *, const struct quotaval *); int quota2_handle_cmd_delete(struct ufsmount *, const struct quotakey *); -int quota2_handle_cmd_getall(struct ufsmount *, struct quotakcursor *, +int quota2_handle_cmd_cursorget(struct ufsmount *, struct quotakcursor *, struct quotakey *, struct quotaval *, unsigned, unsigned *); int quota2_handle_cmd_cursoropen(struct ufsmount *, struct quotakcursor *); int quota2_handle_cmd_cursorclose(struct ufsmount *, struct quotakcursor *); +int quota2_handle_cmd_cursorskipidtype(struct ufsmount *, struct quotakcursor *, + int); +int quota2_handle_cmd_cursoratend(struct ufsmount *, struct quotakcursor *, + int *); +int quota2_handle_cmd_cursorrewind(struct ufsmount *, struct quotakcursor *); int q2sync(struct mount *); int dq2get(struct vnode *, u_long, struct ufsmount *, int, struct dquot *); int dq2sync(struct vnode *, struct dquot *); Index: src/sys/ufs/ufs/ufs_quota2.c diff -u src/sys/ufs/ufs/ufs_quota2.c:1.25 src/sys/ufs/ufs/ufs_quota2.c:1.26 --- src/sys/ufs/ufs/ufs_quota2.c:1.25 Sun Jan 29 07:08:58 2012 +++ src/sys/ufs/ufs/ufs_quota2.c Sun Jan 29 07:09:52 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_quota2.c,v 1.25 2012/01/29 07:08:58 dholland Exp $ */ +/* $NetBSD: ufs_quota2.c,v 1.26 2012/01/29 07:09:52 dholland Exp $ */ /*- * Copyright (c) 2010 Manuel Bouyer * All rights reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.25 2012/01/29 07:08:58 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_quota2.c,v 1.26 2012/01/29 07:09:52 dholland Exp $"); #include <sys/buf.h> #include <sys/param.h> @@ -1050,7 +1050,7 @@ quota2_getuids_callback(struct ufsmount } int -quota2_handle_cmd_getall(struct ufsmount *ump, struct quotakcursor *qkc, +quota2_handle_cmd_cursorget(struct ufsmount *ump, struct quotakcursor *qkc, struct quotakey *keys, struct quotaval *vals, unsigned maxreturn, unsigned *ret) { @@ -1280,6 +1280,74 @@ quota2_handle_cmd_cursorclose(struct ufs } int +quota2_handle_cmd_cursorskipidtype(struct ufsmount *ump, + struct quotakcursor *qkc, int idtype) +{ + struct ufsq2_cursor *cursor; + int error; + + cursor = Q2CURSOR(qkc); + error = q2cursor_check(cursor); + if (error) { + return error; + } + + switch (idtype) { + case QUOTA_IDTYPE_USER: + cursor->q2c_users_done = 1; + break; + case QUOTA_IDTYPE_GROUP: + cursor->q2c_groups_done = 1; + break; + default: + return EINVAL; + } + + return 0; +} + +int +quota2_handle_cmd_cursoratend(struct ufsmount *ump, struct quotakcursor *qkc, + int *ret) +{ + struct ufsq2_cursor *cursor; + int error; + + cursor = Q2CURSOR(qkc); + error = q2cursor_check(cursor); + if (error) { + return error; + } + + *ret = (cursor->q2c_users_done && cursor->q2c_groups_done); + return 0; +} + +int +quota2_handle_cmd_cursorrewind(struct ufsmount *ump, struct quotakcursor *qkc) +{ + struct ufsq2_cursor *cursor; + int error; + + cursor = Q2CURSOR(qkc); + error = q2cursor_check(cursor); + if (error) { + return error; + } + + cursor->q2c_hashsize = 0; + + cursor->q2c_users_done = 0; + cursor->q2c_groups_done = 0; + cursor->q2c_defaults_done = 0; + cursor->q2c_hashpos = 0; + cursor->q2c_uidpos = 0; + cursor->q2c_blocks_done = 0; + + return 0; +} + +int q2sync(struct mount *mp) { return 0;