diff options
author | Jan Kara <jack@suse.cz> | 2020-09-21 13:28:45 +0200 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2020-09-21 13:33:19 +0200 |
commit | 4aac5400dfd61416ffe7ff912f32061854e57e45 (patch) | |
tree | 3450e191180f288e62d6cac7bf643a1d03ada84b | |
parent | 75930ad1b962ceae08e8c2415b42794cd95ff874 (diff) | |
download | linuxquota-4aac5400dfd61416ffe7ff912f32061854e57e45.tar.gz |
quota: Add --filesystem option
Add option --filesystem to specify filesystem to report quotas for while
still maintaining the capability of specifying also names to report
quotas for.
Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r-- | quota.1 | 9 | ||||
-rw-r--r-- | quota.c | 23 |
2 files changed, 28 insertions, 4 deletions
@@ -142,6 +142,15 @@ device. .B -f, --filesystem-list report quotas only for filesystems specified on command line. .TP +.B --filesystem=\f2path\f1 +report quotas only for filesystem +.BR path . +This option can be specified multiple types and quota will be reported for each +specified filesystem. Unlike command line option +.B -f +remaining command like arguments are still treated as user / group / project names +to report. +.TP .B -m, --no-mixed-pathnames Currently, pathnames of NFSv4 mountpoints are sent without leading slash in the path. .BR rpc.rquotad @@ -82,6 +82,9 @@ static void usage(void) -F, --format=formatname display quota of a specific format\n\ -f, --filesystem-list display quota information only for given\n\ filesystems\n\ + --filesystem=path display quota information only for given\n\ + filesystem, remaining command line arguments\n\ + are still treated as user/group/project names\n\ -A, --all-nfs display quota for all NFS mountpoints\n\ -m, --no-mixed-pathnames trim leading slashes from NFSv4 mountpoints\n\ --show-mntpoint show mount point of the file system in output\n\ @@ -287,6 +290,8 @@ int main(int argc, char **argv) { int ngroups; gid_t gidset[NGROUPS_MAX], *gidsetp; + char **fsnames = NULL; + int fscount = 0; int i, ret, type = 0; struct option long_opts[] = { { "help", 0, NULL, 'h' }, @@ -309,6 +314,7 @@ int main(int argc, char **argv) { "no-mixed-pathnames", 0, NULL, 'm' }, { "show-mntpoint", 0, NULL, 257 }, { "hide-device", 0, NULL, 258 }, + { "filesystem", 1, NULL, 259 }, { NULL, 0, NULL, 0 } }; @@ -377,6 +383,13 @@ int main(int argc, char **argv) case 258: flags &= ~FL_SHOW_DEVICE; break; + case 259: + fscount++; + fsnames = reallocarray(fsnames, fscount, sizeof(char *)); + if (!fsnames) + die(1, _("Not enough memory for filesystem names")); + fsnames[fscount - 1] = optarg; + break; case 'V': version(); exit(0); @@ -390,8 +403,10 @@ int main(int argc, char **argv) if (!(flags & FL_USER) && !(flags & FL_GROUP) && !(flags & FL_PROJECT)) flags |= FL_USER; - if (flags & FL_FSLIST && flags & (FL_LOCALONLY | FL_NOAUTOFS)) + if (((flags & FL_FSLIST) || fscount) && flags & (FL_LOCALONLY | FL_NOAUTOFS)) errstr(_("Warning: Ignoring -%c when filesystem list specified.\n"), flags & FL_LOCALONLY ? 'l' : 'i'); + if (fscount && flags & FL_FSLIST) + die(1, "Cannot use both --filesystem and -f"); init_kernel_interface(); @@ -432,12 +447,12 @@ int main(int argc, char **argv) if (flags & FL_USER) for (; argc > 0; argc--, argv++) - ret |= showquotas(USRQUOTA, user2uid(*argv, !!(flags & FL_NUMNAMES), NULL), 0, NULL); + ret |= showquotas(USRQUOTA, user2uid(*argv, !!(flags & FL_NUMNAMES), NULL), fscount, fsnames); else if (flags & FL_GROUP) for (; argc > 0; argc--, argv++) - ret |= showquotas(GRPQUOTA, group2gid(*argv, !!(flags & FL_NUMNAMES), NULL), 0, NULL); + ret |= showquotas(GRPQUOTA, group2gid(*argv, !!(flags & FL_NUMNAMES), NULL), fscount, fsnames); else if (flags & FL_PROJECT) for (; argc > 0; argc--, argv++) - ret |= showquotas(PRJQUOTA, project2pid(*argv, !!(flags & FL_NUMNAMES), NULL), 0, NULL); + ret |= showquotas(PRJQUOTA, project2pid(*argv, !!(flags & FL_NUMNAMES), NULL), fscount, fsnames); return ret; } |