Module Name: src Committed By: dholland Date: Wed Feb 1 05:12:45 UTC 2012
Modified Files: src/tests/fs/ffs: t_miscquota.sh src/usr.sbin/repquota: repquota.8 repquota.c Log Message: Reimplement repquota -x to print in tabular form instead of XML. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/fs/ffs/t_miscquota.sh cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/repquota/repquota.8 cvs rdiff -u -r1.39 -r1.40 src/usr.sbin/repquota/repquota.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/fs/ffs/t_miscquota.sh diff -u src/tests/fs/ffs/t_miscquota.sh:1.4 src/tests/fs/ffs/t_miscquota.sh:1.5 --- src/tests/fs/ffs/t_miscquota.sh:1.4 Wed Jan 18 20:51:23 2012 +++ src/tests/fs/ffs/t_miscquota.sh Wed Feb 1 05:12:45 2012 @@ -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 @@ quota_walk_list() 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 } Index: src/usr.sbin/repquota/repquota.8 diff -u src/usr.sbin/repquota/repquota.8:1.11 src/usr.sbin/repquota/repquota.8:1.12 --- src/usr.sbin/repquota/repquota.8:1.11 Sun Mar 6 17:36:32 2011 +++ src/usr.sbin/repquota/repquota.8 Wed Feb 1 05:12:45 2012 @@ -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 @@ group and user quotas if they exist). 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 @@ printed, along with any quotas created w 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 Index: src/usr.sbin/repquota/repquota.c diff -u src/usr.sbin/repquota/repquota.c:1.39 src/usr.sbin/repquota/repquota.c:1.40 --- src/usr.sbin/repquota/repquota.c:1.39 Sun Jan 29 07:23:52 2012 +++ src/usr.sbin/repquota/repquota.c Wed Feb 1 05:12:45 2012 @@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #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 @@ __RCSID("$NetBSD: repquota.c,v 1.39 2012 #include <unistd.h> #include <quota/quota.h> -#include <quota/quotaprop.h> #include <quota.h> #include "printquota.h" @@ -395,69 +394,77 @@ printquotas(int idtype, struct quotahand } static void -exportquotas(void) +exportquotaval(const struct quotaval *qv) { - uint32_t id; - struct fileusage *fup; - prop_dictionary_t dict, data; - prop_array_t cmds, datas; - int idtype; - uint64_t *valuesp[QUOTA_NLIMITS]; + if (qv->qv_hardlimit == QUOTA_NOLIMIT) { + printf(" -"); + } else { + printf(" %llu", (unsigned long long)qv->qv_hardlimit); + } - dict = quota_prop_create(); - cmds = prop_array_create(); + if (qv->qv_softlimit == QUOTA_NOLIMIT) { + printf(" -"); + } else { + printf(" %llu", (unsigned long long)qv->qv_softlimit); + } - if (dict == NULL || cmds == NULL) { - errx(1, "can't allocate proplist"); + 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) +{ + int idtype; + id_t id; + struct fileusage *fup; + + /* 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"); } /*