Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Change QUOTACTL_GETVERSION to QUOTACTL_STAT. Add struct ...



details:   https://anonhg.NetBSD.org/src/rev/b0f99484258a
branches:  trunk
changeset: 773204:b0f99484258a
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sun Jan 29 07:12:40 2012 +0000

description:
Change QUOTACTL_GETVERSION to QUOTACTL_STAT. Add struct quotastat.

This change requires a kernel version bump.

diffstat:

 sys/kern/vfs_quotactl.c |  22 +++++++++++++++++-----
 sys/sys/quotactl.h      |  30 +++++++++++++++++++++++++-----
 sys/ufs/ufs/ufs_quota.c |  32 +++++++++++++++++++++-----------
 3 files changed, 63 insertions(+), 21 deletions(-)

diffs (200 lines):

diff -r 4840d05194b1 -r b0f99484258a sys/kern/vfs_quotactl.c
--- a/sys/kern/vfs_quotactl.c   Sun Jan 29 07:11:55 2012 +0000
+++ b/sys/kern/vfs_quotactl.c   Sun Jan 29 07:12:40 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_quotactl.c,v 1.32 2012/01/29 07:11:55 dholland Exp $       */
+/*     $NetBSD: vfs_quotactl.c,v 1.33 2012/01/29 07:12:40 dholland Exp $       */
 
 /*
  * Copyright (c) 1991, 1993, 1994
@@ -80,7 +80,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.32 2012/01/29 07:11:55 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_quotactl.c,v 1.33 2012/01/29 07:12:40 dholland Exp $");
 
 #include <sys/malloc.h> /* XXX: temporary */
 #include <sys/mount.h>
@@ -95,6 +95,7 @@
 {
        prop_array_t replies;
        prop_dictionary_t data;
+       struct quotastat stat;
        int q2version;
        struct vfs_quotactl_args args;
        int error;
@@ -102,13 +103,24 @@
        KASSERT(prop_object_type(cmddict) == PROP_TYPE_DICTIONARY);
        KASSERT(prop_object_type(datas) == PROP_TYPE_ARRAY);
 
-       args.qc_type = QCT_GETVERSION;
-       args.u.getversion.qc_version_ret = &q2version;
-       error = VFS_QUOTACTL(mp, QUOTACTL_GETVERSION, &args);
+       args.qc_type = QCT_STAT;
+       args.u.stat.qc_ret = &stat;
+       error = VFS_QUOTACTL(mp, QUOTACTL_STAT, &args);
        if (error) {
                return error;
        }
 
+       /*
+        * Set q2version based on the stat results. Currently there
+        * are two valid values for q2version, 1 and 2, which we pick
+        * based on whether quotacheck is required.
+        */
+       if (stat.qs_restrictions & QUOTA_RESTRICT_NEEDSQUOTACHECK) {
+               q2version = 1;
+       } else {
+               q2version = 2;
+       }
+
        data = prop_dictionary_create();
        if (data == NULL) {
                return ENOMEM;
diff -r 4840d05194b1 -r b0f99484258a sys/sys/quotactl.h
--- a/sys/sys/quotactl.h        Sun Jan 29 07:11:55 2012 +0000
+++ b/sys/sys/quotactl.h        Sun Jan 29 07:12:40 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: quotactl.h,v 1.28 2012/01/29 07:11:55 dholland Exp $   */
+/*     $NetBSD: quotactl.h,v 1.29 2012/01/29 07:12:41 dholland Exp $   */
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -37,6 +37,26 @@
  * use the <quota.h> API instead.
  */
 
+/* Size of random quota strings */
+#define QUOTA_NAMELEN   32
+
+/*
+ * Restrictions for qs_restrictions.
+ */
+#define QUOTA_RESTRICT_NEEDSQUOTACHECK 0x1     /* quotacheck(8) required */
+#define QUOTA_RESTRICT_UNIFORMGRACE    0x2     /* grace time is global */
+#define QUOTA_RESTRICT_32BIT           0x4     /* values limited to 2^32 */
+        
+/*              
+ * Structure for QUOTACTL_STAT.
+ */             
+struct quotastat {
+       char qs_implname[QUOTA_NAMELEN];
+       unsigned qs_numidtypes;
+       unsigned qs_numobjtypes;
+       unsigned qs_restrictions;
+};
+                        
 /*
  * Semi-opaque structure for cursors. This holds the cursor state in
  * userland; the size is exposed only to libquota, not to client code,
@@ -52,7 +72,7 @@
 };
 
 /* Command codes. */
-#define QUOTACTL_GETVERSION    0
+#define QUOTACTL_STAT          0
 #define QUOTACTL_QUOTAON       1
 #define QUOTACTL_QUOTAOFF      2
 #define QUOTACTL_GET           3
@@ -68,7 +88,7 @@
 /* Argument encoding. */
 enum vfs_quotactl_argtypes {
        QCT_PROPLIB,    /* unused */
-       QCT_GETVERSION, /* getversion */
+       QCT_STAT,       /* stat */
        QCT_GET,        /* get */
        QCT_PUT,        /* put */
        QCT_DELETE,     /* delete */
@@ -90,8 +110,8 @@
                        prop_array_t qc_datas;
                } proplib;
                struct {
-                       int *qc_version_ret;
-               } getversion;
+                       struct quotastat *qc_ret;
+               } stat;
                struct {
                        const struct quotakey *qc_key;
                        struct quotaval *qc_ret;
diff -r 4840d05194b1 -r b0f99484258a sys/ufs/ufs/ufs_quota.c
--- a/sys/ufs/ufs/ufs_quota.c   Sun Jan 29 07:11:55 2012 +0000
+++ b/sys/ufs/ufs/ufs_quota.c   Sun Jan 29 07:12:40 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ufs_quota.c,v 1.100 2012/01/29 07:11:55 dholland Exp $ */
+/*     $NetBSD: ufs_quota.c,v 1.101 2012/01/29 07:12:41 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.100 2012/01/29 07:11:55 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota.c,v 1.101 2012/01/29 07:12:41 dholland Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_quota.h"
@@ -71,7 +71,7 @@
 static pool_cache_t dquot_cache;
 
 
-static int quota_handle_cmd_get_version(struct mount *, struct lwp *,
+static int quota_handle_cmd_stat(struct mount *, struct lwp *,
     struct vfs_quotactl_args *args);
 static int quota_handle_cmd_get(struct mount *, struct lwp *,
     struct vfs_quotactl_args *args);
@@ -170,8 +170,8 @@
        int error = 0;
 
        switch (op) {
-           case QUOTACTL_GETVERSION:
-               error = quota_handle_cmd_get_version(mp, l, args);
+           case QUOTACTL_STAT:
+               error = quota_handle_cmd_stat(mp, l, args);
                break;
            case QUOTACTL_QUOTAON:
                error = quota_handle_cmd_quotaon(mp, l, args);
@@ -214,26 +214,36 @@
 }
 
 static int 
-quota_handle_cmd_get_version(struct mount *mp, struct lwp *l, 
+quota_handle_cmd_stat(struct mount *mp, struct lwp *l, 
     struct vfs_quotactl_args *args)
 {
        struct ufsmount *ump = VFSTOUFS(mp);
-       int *version_ret;
+       struct quotastat *ret;
 
-       KASSERT(args->qc_type == QCT_GETVERSION);
-       version_ret = args->u.getversion.qc_version_ret;
+       KASSERT(args->qc_type == QCT_STAT);
+       ret = args->u.stat.qc_ret;
 
        if ((ump->um_flags & (UFS_QUOTA|UFS_QUOTA2)) == 0)
                return EOPNOTSUPP;
 
 #ifdef QUOTA
        if (ump->um_flags & UFS_QUOTA) {
-               *version_ret = 1;
+               strcpy(ret->qs_implname, "ufs/ffs quota v1");
+               ret->qs_numidtypes = MAXQUOTAS;
+               /* XXX no define for this */
+               ret->qs_numobjtypes = 2;
+               ret->qs_restrictions = 0;
+               ret->qs_restrictions |= QUOTA_RESTRICT_NEEDSQUOTACHECK;
+               ret->qs_restrictions |= QUOTA_RESTRICT_UNIFORMGRACE;
+               ret->qs_restrictions |= QUOTA_RESTRICT_32BIT;
        } else
 #endif
 #ifdef QUOTA2
        if (ump->um_flags & UFS_QUOTA2) {
-               *version_ret = 2;
+               strcpy(ret->qs_implname, "ufs/ffs quota v2");
+               ret->qs_numidtypes = MAXQUOTAS;
+               ret->qs_numobjtypes = N_QL;
+               ret->qs_restrictions = 0;
        } else
 #endif
                return EOPNOTSUPP;



Home | Main Index | Thread Index | Old Index