.B lfs quota [-o obd_uuid] [-u|-g] <username|groupname> <filesystem>
.br
+.B lfs quota <filesystem>
+.br
.B lfs quota -t [-u|-g] <filesystem>
.br
.B lfs help
To set filesystem quota grace times for users or groups. Grace time is specified in "XXwXXdXXhXXmXXs" format or as an integer seconds value, see EXAMPLES
.TP
.B quota [-o obd_uuid] [-u|-g] <username|groupname> <filesystem>
-To display disk usage and limits, either for the full filesystem, or for objects on a specific obd. A user or group name must be specified.
+To display disk usage and limits, either for the full filesystem, or for objects on a specific obd. A user or group name can be specified. If both user and group are omitted, quotas for current uid/gid are shown.
.TP
.B quota -t [-u|-g] <filesystem>
To display block and inode grace times for user (-u) or group (-g) quotas
static int lfs_quota(int argc, char **argv)
{
int c;
- char *name = NULL, *mnt;
+ char *mnt, *name = NULL;
struct if_quotactl qctl = { .qc_cmd = LUSTRE_Q_GETQUOTA,
- .qc_type = 0x01 };
+ .qc_type = UGQUOTA };
char *obd_type = (char *)qctl.obd_type;
char *obd_uuid = (char *)qctl.obd_uuid.uuid;
int rc, rc1 = 0, rc2 = 0, rc3 = 0;
+ int pass = 0;
optind = 0;
while ((c = getopt(argc, argv, "ugto:")) != -1) {
switch (c) {
case 'u':
- qctl.qc_type = 0x01;
+ if (qctl.qc_type != UGQUOTA) {
+ fprintf(stderr, "error: use either -u or -g\n");
+ return CMD_HELP;
+ }
+ qctl.qc_type = USRQUOTA;
break;
case 'g':
- qctl.qc_type = 0x02;
+ if (qctl.qc_type != UGQUOTA) {
+ fprintf(stderr, "error: use either -u or -g\n");
+ return CMD_HELP;
+ }
+ qctl.qc_type = GRPQUOTA;
break;
case 't':
qctl.qc_cmd = LUSTRE_Q_GETINFO;
}
}
- if (qctl.qc_type)
- qctl.qc_type--;
-
-
- if (qctl.qc_cmd == LUSTRE_Q_GETQUOTA) {
+ /* current uid/gid info for "lfs quota /path/to/lustre/mount" */
+ if (qctl.qc_cmd == LUSTRE_Q_GETQUOTA && qctl.qc_type == UGQUOTA &&
+ optind == argc - 1) {
+ug_output:
+ memset(&qctl, 0, sizeof(qctl)); /* spoiled by print_*_quota */
+ qctl.qc_cmd = LUSTRE_Q_GETQUOTA;
+ if (pass++ == 0) {
+ qctl.qc_type = USRQUOTA;
+ qctl.qc_id = geteuid();
+ } else {
+ qctl.qc_type = GRPQUOTA;
+ qctl.qc_id = getegid();
+ }
+ rc = id2name(&name, qctl.qc_id, qctl.qc_type);
+ if (rc)
+ name = "<unknown>";
+ } else if (qctl.qc_cmd == LUSTRE_Q_GETQUOTA) {
+ char *name;
if (optind + 2 != argc) {
fprintf(stderr, "error: missing quota argument(s)\n");
return CMD_HELP;
name, strerror(errno));
return CMD_HELP;
}
- print_quota_title(name, &qctl);
} else if (optind + 1 != argc) {
fprintf(stderr, "error: missing quota info argument(s)\n");
return CMD_HELP;
}
+ if (qctl.qc_cmd == LUSTRE_Q_GETQUOTA)
+ print_quota_title(name, &qctl);
+
mnt = argv[optind];
rc1 = llapi_quotactl(mnt, &qctl);
if (rc1 == -1 && errno == ESRCH) {
fprintf(stderr, "\n%s quotas are not enabled.\n",
- qctl.qc_type == 0x00 ? "user" : "group");
- return 0;
+ qctl.qc_type == USRQUOTA ? "user" : "group");
+ goto out;
}
if (rc1 && *obd_type)
fprintf(stderr, "%s %s ", obd_type, obd_uuid);
- if (!name)
- rc = id2name(&name, getuid(), qctl.qc_type);
-
- if (*obd_uuid) {
+ if (*obd_uuid)
mnt = "";
- name = obd_uuid;
- }
print_quota(mnt, &qctl, GENERAL_QUOTA_INFO);
printf("Some errors happened when getting quota info. "
"Some devices may be not working or deactivated. "
"The data in \"[]\" is inaccurate.\n");
+
+out:
+ if (pass == 1)
+ goto ug_output;
+
return 0;
}
#endif /* HAVE_QUOTA_SUPPORT */