summaryrefslogtreecommitdiff
path: root/quotaon.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2016-07-12 14:18:10 +0200
committerJan Kara <jack@suse.cz>2016-07-12 14:18:10 +0200
commitbeeec582a54e86052560b75440562028cd6a7d0a (patch)
tree91d4156b218b6003c9f101164697841d401e13d5 /quotaon.c
parent3715b0f5bd11116796f5f80144ceefe539b320aa (diff)
quotaon: Improve reporting of quota state
quotactl Q_XFS_GETQSTAT is able to report whether only accounting or also quota enforcement is turned on. This works for XFS and GFS2 for ages and since kernel 4.1 also for other filesystems. Use this quotactl when it is supported and report more details in verbose mode. Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'quotaon.c')
-rw-r--r--quotaon.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/quotaon.c b/quotaon.c
index b9cc841..fe19224 100644
--- a/quotaon.c
+++ b/quotaon.c
@@ -332,23 +332,39 @@ static int newstate(struct mount_entry *mnt, int type, char *extra)
static int print_state(struct mount_entry *mnt, int type)
{
int on = 0;
-
- if (!strcmp(mnt->me_type, MNTTYPE_XFS) ||
- !strcmp(mnt->me_type, MNTTYPE_GFS2)) {
- if (kern_qfmt_supp(QF_XFS))
- on = kern_quota_on(mnt, type, QF_XFS) != -1;
+ char *state;
+
+ if (kern_qfmt_supp(QF_XFS)) {
+ on = kern_quota_state_xfs(mnt->me_devname, type);
+ if (!strcmp(mnt->me_type, MNTTYPE_XFS) ||
+ !strcmp(mnt->me_type, MNTTYPE_GFS2) || on >= 0) {
+ if (on < 0)
+ on = 0;
+ if (!(flags & FL_VERBOSE))
+ goto print_state;
+ if (on == 0)
+ state = _("off");
+ else if (on == 1)
+ state = _("on (accounting)");
+ else
+ state = _("on (enforced)");
+ goto print;
+ }
}
- else if (kernel_iface == IFACE_GENERIC)
+ if (kernel_iface == IFACE_GENERIC)
on = kern_quota_on(mnt, type, -1) != -1;
else if (kern_qfmt_supp(QF_VFSV0))
on = kern_quota_on(mnt, type, QF_VFSV0) != -1;
else if (kern_qfmt_supp(QF_VFSOLD))
on = kern_quota_on(mnt, type, QF_VFSOLD) != -1;
- printf(_("%s quota on %s (%s) is %s\n"), _(type2name(type)), mnt->me_dir, mnt->me_devname,
- on ? _("on") : _("off"));
+print_state:
+ state = on ? _("on") : _("off");
+print:
+ printf(_("%s quota on %s (%s) is %s\n"), _(type2name(type)),
+ mnt->me_dir, mnt->me_devname, state);
- return on;
+ return on > 0;
}
int main(int argc, char **argv)