summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2016-03-30 14:32:23 +0200
committerJan Kara <jack@suse.cz>2016-03-31 10:29:28 +0200
commit1f99109c31bfbbdfbcaab4046f21d87eed625da8 (patch)
tree02d73397142ca7eac1b768688ba137f05a7267c2
parent4b62b7d4e1c261ae1c134662f05de370780b6eca (diff)
downloadquota-tools-1f99109c31bfbbdfbcaab4046f21d87eed625da8.tar.gz
repquota: Add project quota support
Signed-off-by: Li Xi <lixi@ddn.com> Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r--repquota.89
-rw-r--r--repquota.c31
2 files changed, 33 insertions, 7 deletions
diff --git a/repquota.8 b/repquota.8
index 89cd896..37dcb9a 100644
--- a/repquota.8
+++ b/repquota.8
@@ -5,7 +5,7 @@ repquota \- summarize quotas for a filesystem
.SH SYNOPSIS
.B /usr/sbin/repquota
[
-.B \-vspiug
+.B \-vspiugP
] [
.B \-c
|
@@ -22,7 +22,7 @@ repquota \- summarize quotas for a filesystem
.LP
.B /usr/sbin/repquota
[
-.B \-avtpsiug
+.B \-avtpsiugP
] [
.B \-c
|
@@ -59,7 +59,7 @@ printed is '-'. The second character denotes the state of inode usage
analogously.
.B repquota
-has to translate ids of all users/groups to names (unless option
+has to translate ids of all users/groups/projects to names (unless option
.B -n
was specified) so it may take a while to
print all the information. To make translating as fast as possible
@@ -125,6 +125,9 @@ Quota format with 64-bit quota limits and usage,
.B -g, --group
Report quotas for groups.
.TP
+.B -P, --project
+Report quotas for projects.
+.TP
.B -u, --user
Report quotas for users. This is the default.
.TP
diff --git a/repquota.c b/repquota.c
index 6fe9f0c..957dc8d 100644
--- a/repquota.c
+++ b/repquota.c
@@ -37,6 +37,7 @@
#define FL_NOCACHE 128 /* Don't cache dquots before resolving */
#define FL_NOAUTOFS 256 /* Ignore autofs mountpoints */
#define FL_RAWGRACE 512 /* Print grace times in seconds since epoch */
+#define FL_PROJECT 1024
static int flags, fmt = -1, ofmt = QOF_DEFAULT;
static char **mnt;
@@ -51,6 +52,7 @@ static void usage(void)
-v, --verbose display also users/groups without any usage\n\
-u, --user display information about users\n\
-g, --group display information about groups\n\
+-P, --project display information about projects\n\
-s, --human-readable show numbers in human friendly units (MB, GB, ...)\n\
-t, --truncate-names truncate names to 9 characters\n\
-p, --raw-grace print grace time in seconds since epoch\n\
@@ -77,6 +79,7 @@ static void parse_options(int argcnt, char **argstr)
{ "verbose", 0, NULL, 'v' },
{ "user", 0, NULL, 'u' },
{ "group", 0, NULL, 'g' },
+ { "project", 0, NULL, 'P' },
{ "help", 0, NULL, 'h' },
{ "truncate-names", 0, NULL, 't' },
{ "raw-grace", 0, NULL, 'p' },
@@ -90,7 +93,7 @@ static void parse_options(int argcnt, char **argstr)
{ NULL, 0, NULL, 0 }
};
- while ((ret = getopt_long(argcnt, argstr, "VavughtspncCiF:O:", long_opts, NULL)) != -1) {
+ while ((ret = getopt_long(argcnt, argstr, "VavugPhtspncCiF:O:", long_opts, NULL)) != -1) {
switch (ret) {
case '?':
case 'h':
@@ -104,6 +107,9 @@ static void parse_options(int argcnt, char **argstr)
case 'g':
flags |= FL_GROUP;
break;
+ case 'P':
+ flags |= FL_PROJECT;
+ break;
case 'v':
flags |= FL_VERBOSE;
break;
@@ -156,7 +162,7 @@ static void parse_options(int argcnt, char **argstr)
fputs(_("Specified both -n and -t but only one of them can be used.\n"), stderr);
exit(1);
}
- if (!(flags & (FL_USER | FL_GROUP)))
+ if (!(flags & (FL_USER | FL_GROUP | FL_PROJECT)))
flags |= FL_USER;
if (!(flags & FL_ALL)) {
mnt = argstr + optind;
@@ -290,7 +296,7 @@ static void dump_cached_dquots(int type)
}
endpwent();
}
- else {
+ else if (type == GRPQUOTA) {
struct group *grent;
setgrent();
@@ -302,6 +308,18 @@ static void dump_cached_dquots(int type)
}
}
endgrent();
+ } else {
+ struct fs_project *prent;
+
+ setprent();
+ while ((prent = getprent())) {
+ for (i = 0; i < cached_dquots && prent->pr_id != dquot_cache[i].dq_id; i++);
+ if (i < cached_dquots && !(dquot_cache[i].dq_flags & DQ_PRINTED)) {
+ print(dquot_cache+i, prent->pr_name);
+ dquot_cache[i].dq_flags |= DQ_PRINTED;
+ }
+ }
+ endprent();
}
for (i = 0; i < cached_dquots; i++)
if (!(dquot_cache[i].dq_flags & DQ_PRINTED)) {
@@ -346,8 +364,10 @@ static void report_it(struct quota_handle *h, int type)
if (type == USRQUOTA)
typestr = _("User");
- else
+ else if (type == GRPQUOTA)
typestr = _("Group");
+ else
+ typestr = _("Project");
if (ofmt == QOF_DEFAULT )
printf(_("*** Report for %s quotas on device %s\n"), _(type2name(type)), h->qh_quotadev);
@@ -420,6 +440,9 @@ int main(int argc, char **argv)
if (flags & FL_GROUP)
report(GRPQUOTA);
+ if (flags & FL_PROJECT)
+ report(PRJQUOTA);
+
if (ofmt == QOF_XML)
printf("</repquota>\n");