Source-Changes-HG archive

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

[src/trunk]: src Reimplement repquota -x to print in tabular form instead of ...



details:   https://anonhg.NetBSD.org/src/rev/dbd522026ec6
branches:  trunk
changeset: 773376:dbd522026ec6
user:      dholland <dholland%NetBSD.org@localhost>
date:      Wed Feb 01 05:12:45 2012 +0000

description:
Reimplement repquota -x to print in tabular form instead of XML.

diffstat:

 tests/fs/ffs/t_miscquota.sh  |    4 +-
 usr.sbin/repquota/repquota.8 |   12 ++--
 usr.sbin/repquota/repquota.c |  107 ++++++++++++++++++++++--------------------
 3 files changed, 65 insertions(+), 58 deletions(-)

diffs (208 lines):

diff -r 80cd761beb67 -r dbd522026ec6 tests/fs/ffs/t_miscquota.sh
--- a/tests/fs/ffs/t_miscquota.sh       Wed Feb 01 05:10:44 2012 +0000
+++ b/tests/fs/ffs/t_miscquota.sh       Wed Feb 01 05:12:45 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_miscquota.sh,v 1.4 2012/01/18 20:51:23 bouyer Exp $ 
+# $NetBSD: t_miscquota.sh,v 1.5 2012/02/01 05:12:45 dholland Exp $ 
 #
 #  Copyright (c) 2011 Manuel Bouyer
 #  All rights reserved.
@@ -82,7 +82,7 @@
                i=$((i + 1))
        done
        # do a repquota
-       atf_check -s exit:0 -o 'match:<integer>0x64000' \
+       atf_check -s exit:0 -o 'match:user 409600 blocks  *81920 20 0' \
            env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -x -${expect} /mnt
        rump_quota_shutdown
 }
diff -r 80cd761beb67 -r dbd522026ec6 usr.sbin/repquota/repquota.8
--- a/usr.sbin/repquota/repquota.8      Wed Feb 01 05:10:44 2012 +0000
+++ b/usr.sbin/repquota/repquota.8      Wed Feb 01 05:12:45 2012 +0000
@@ -29,7 +29,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     from: @(#)repquota.8   8.1 (Berkeley) 6/6/93
-.\"    $NetBSD: repquota.8,v 1.11 2011/03/06 17:36:32 wiz Exp $
+.\"    $NetBSD: repquota.8,v 1.12 2012/02/01 05:12:45 dholland Exp $
 .\"
 .Dd February 10, 2011
 .Dt REPQUOTA 8
@@ -71,8 +71,8 @@
 Print a header line before printing each file system quotas.
 Print all exiting quotas, including those whose current usage is 0.
 .It Fl x
-export file system quota in a plist format suitable for
-.Xr quotactl 8 .
+export file system quota in a tabular dump format suitable for
+.Xr quotarestore 8 .
 A single file system should be specified.
 .El
 .Pp
@@ -86,12 +86,12 @@
 Only the super-user may use this command.
 .Sh SEE ALSO
 .Xr quota 1 ,
-.Xr quotactl 2 ,
+.Xr libquota 3 ,
 .Xr fstab 5 ,
 .Xr edquota 8 ,
 .Xr quotacheck 8 ,
-.Xr quotactl 8 ,
-.Xr quotaon 8
+.Xr quotaon 8 ,
+.Xr quotarestore 8
 .Sh HISTORY
 The
 .Nm
diff -r 80cd761beb67 -r dbd522026ec6 usr.sbin/repquota/repquota.c
--- a/usr.sbin/repquota/repquota.c      Wed Feb 01 05:10:44 2012 +0000
+++ b/usr.sbin/repquota/repquota.c      Wed Feb 01 05:12:45 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: repquota.c,v 1.39 2012/01/29 07:23:52 dholland Exp $   */
+/*     $NetBSD: repquota.c,v 1.40 2012/02/01 05:12:45 dholland Exp $   */
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)repquota.c 8.2 (Berkeley) 11/22/94";
 #else
-__RCSID("$NetBSD: repquota.c,v 1.39 2012/01/29 07:23:52 dholland Exp $");
+__RCSID("$NetBSD: repquota.c,v 1.40 2012/02/01 05:12:45 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -65,7 +65,6 @@
 #include <unistd.h>
 
 #include <quota/quota.h>
-#include <quota/quotaprop.h>
 #include <quota.h>
 
 #include "printquota.h"
@@ -395,69 +394,77 @@
 }
 
 static void
+exportquotaval(const struct quotaval *qv)
+{
+       if (qv->qv_hardlimit == QUOTA_NOLIMIT) {
+               printf(" -");
+       } else {
+               printf(" %llu", (unsigned long long)qv->qv_hardlimit);
+       }
+
+       if (qv->qv_softlimit == QUOTA_NOLIMIT) {
+               printf(" -");
+       } else {
+               printf(" %llu", (unsigned long long)qv->qv_softlimit);
+       }
+
+       printf(" %llu", (unsigned long long)qv->qv_usage);
+
+       if (qv->qv_expiretime == QUOTA_NOTIME) {
+               printf(" -");
+       } else {
+               printf(" %lld", (long long)qv->qv_expiretime);
+       }
+
+       if (qv->qv_grace == QUOTA_NOTIME) {
+               printf(" -");
+       } else {
+               printf(" %lld", (long long)qv->qv_grace);
+       }
+}
+
+static void
 exportquotas(void)
 {
-       uint32_t id;
+       int idtype;
+       id_t id;
        struct fileusage *fup;
-       prop_dictionary_t dict, data;
-       prop_array_t cmds, datas;
-       int idtype;
-       uint64_t *valuesp[QUOTA_NLIMITS];
 
-       dict = quota_prop_create();
-       cmds = prop_array_create();
-
-       if (dict == NULL || cmds == NULL) {
-               errx(1, "can't allocate proplist");
-       }
-
+       /* header */
+       printf("@format netbsd-quota-dump v1\n");
+       printf("# idtype id objtype   hard soft usage expire grace\n");
 
        for (idtype = 0; idtype < REPQUOTA_NUMIDTYPES; idtype++) {
                if (valid[idtype] == 0)
                        continue;
-               datas = prop_array_create();
-               if (datas == NULL)
-                       errx(1, "can't allocate proplist");
-               valuesp[QUOTA_LIMIT_BLOCK] =
-                   &defaultqv[idtype][QUOTA_LIMIT_BLOCK].qv_hardlimit;
-               valuesp[QUOTA_LIMIT_FILE] =
-                   &defaultqv[idtype][QUOTA_LIMIT_FILE].qv_hardlimit;
-               data = quota64toprop(0, 1, valuesp,
-                   ufs_quota_entry_names, UFS_QUOTA_NENTRIES,
-                   ufs_quota_limit_names, QUOTA_NLIMITS);
-               if (data == NULL)
-                       err(1, "quota64toprop(default)");
-               if (!prop_array_add_and_rel(datas, data))
-                       err(1, "prop_array_add(data)");
+
+               printf("%s default blocks  ", repquota_idtype_names[idtype]);
+               exportquotaval(&defaultqv[idtype][QUOTA_OBJTYPE_BLOCKS]);
+               printf("\n");
+                       
+               printf("%s default files  ", repquota_idtype_names[idtype]);
+               exportquotaval(&defaultqv[idtype][QUOTA_OBJTYPE_FILES]);
+               printf("\n");
 
                for (id = 0; id <= highid[idtype]; id++) {
                        fup = qremove(id, idtype);
                        if (fup == 0)
                                continue;
-                       valuesp[QUOTA_LIMIT_BLOCK] =
-                           &fup->fu_qv[QUOTA_LIMIT_BLOCK].qv_hardlimit;
-                       valuesp[QUOTA_LIMIT_FILE] =
-                           &fup->fu_qv[QUOTA_LIMIT_FILE].qv_hardlimit;
-                       data = quota64toprop(id, 0, valuesp,
-                           ufs_quota_entry_names, UFS_QUOTA_NENTRIES,
-                           ufs_quota_limit_names, QUOTA_NLIMITS);
-                       if (data == NULL)
-                               err(1, "quota64toprop(id)");
-                       if (!prop_array_add_and_rel(datas, data))
-                               err(1, "prop_array_add(data)");
+
+                       printf("%s %u blocks  ", repquota_idtype_names[idtype],
+                              id);
+                       exportquotaval(&fup->fu_qv[QUOTA_OBJTYPE_BLOCKS]);
+                       printf("\n");
+
+                       printf("%s %u files  ", repquota_idtype_names[idtype],
+                              id);
+                       exportquotaval(&fup->fu_qv[QUOTA_OBJTYPE_FILES]);
+                       printf("\n");
+
                        free(fup);
                }
-
-               if (!quota_prop_add_command(cmds, "set",
-                   ufs_quota_class_names[idtype], datas))
-                       err(1, "prop_add_command");
        }
-
-       if (!prop_dictionary_set(dict, "commands", cmds))
-               err(1, "prop_dictionary_set(command)");
-
-       printf("%s\n", prop_dictionary_externalize(dict));
-       return;
+       printf("@end\n");
 }
 
 /*



Home | Main Index | Thread Index | Old Index