+static int get_print_quota(char *mnt, char *name, struct if_quotactl *qctl,
+ int verbose, int quiet, bool human_readable)
+{
+ int rc1 = 0, rc2 = 0, rc3 = 0;
+ char *obd_type = (char *)qctl->obd_type;
+ char *obd_uuid = (char *)qctl->obd_uuid.uuid;
+ __u64 total_ialloc = 0, total_balloc = 0;
+ int inacc;
+
+ rc1 = llapi_quotactl(mnt, qctl);
+ if (rc1 < 0) {
+ switch (rc1) {
+ case -ESRCH:
+ fprintf(stderr, "%s quotas are not enabled.\n",
+ qtype_name(qctl->qc_type));
+ goto out;
+ case -EPERM:
+ fprintf(stderr, "Permission denied.\n");
+ case -ENODEV:
+ case -ENOENT:
+ /* We already got error message. */
+ goto out;
+ default:
+ fprintf(stderr, "Unexpected quotactl error: %s\n",
+ strerror(-rc1));
+ }
+ }
+
+ if (qctl->qc_cmd == LUSTRE_Q_GETQUOTA && !quiet)
+ print_quota_title(name, qctl, human_readable);
+
+ if (rc1 && *obd_type)
+ fprintf(stderr, "%s %s ", obd_type, obd_uuid);
+
+ if (qctl->qc_valid != QC_GENERAL)
+ mnt = "";
+
+ inacc = (qctl->qc_cmd == LUSTRE_Q_GETQUOTA) &&
+ ((qctl->qc_dqblk.dqb_valid & (QIF_LIMITS|QIF_USAGE)) !=
+ (QIF_LIMITS|QIF_USAGE));
+
+ print_quota(mnt, qctl, QC_GENERAL, rc1, human_readable);
+
+ if (qctl->qc_valid == QC_GENERAL && qctl->qc_cmd != LUSTRE_Q_GETINFO &&
+ verbose) {
+ char strbuf[STRBUF_LEN];
+
+ rc2 = print_obd_quota(mnt, qctl, 1, human_readable,
+ &total_ialloc);
+ rc3 = print_obd_quota(mnt, qctl, 0, human_readable,
+ &total_balloc);
+ kbytes2str(total_balloc, strbuf, sizeof(strbuf),
+ human_readable);
+ printf("Total allocated inode limit: %ju, total "
+ "allocated block limit: %s\n", (uintmax_t)total_ialloc,
+ strbuf);
+ }
+
+ if (rc1 || rc2 || rc3 || inacc)
+ printf("Some errors happened when getting quota info. "
+ "Some devices may be not working or deactivated. "
+ "The data in \"[]\" is inaccurate.\n");
+out:
+ return rc1;
+
+}
+