From e1b096734daba1091f3818b69835a981d253a594 Mon Sep 17 00:00:00 2001 From: Ben McClelland Date: Mon, 25 Mar 2024 15:29:54 -0700 Subject: [PATCH] add StringNoLimit to quota rule The StringNoLimit() prints all quota rul attributes except the limit allowing the caller to post process the limit and print their own version. --- scoutfs.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/scoutfs.go b/scoutfs.go index eb95629..d34adef 100644 --- a/scoutfs.go +++ b/scoutfs.go @@ -1244,6 +1244,37 @@ func (q QuotaRule) String() string { return q.Raw(false) } +func (q QuotaRule) StringNoLimit() string { + switch q.QuotaSource[2] { + case quotaLiteral: + return fmt.Sprintf("P: %*v %*v Literal", + prioPad, q.Prioirity, opPad, q.Op) + case quotaUID: + if q.QuotaFlags[2] == quotaSelect { + return fmt.Sprintf("P: %*v %*v UID [%5v]", + prioPad, q.Prioirity, opPad, q.Op, q.QuotaValue[2]) + } + return fmt.Sprintf("P: %*v %*v UID general", + prioPad, q.Prioirity, opPad, q.Op) + case quotaGID: + if q.QuotaFlags[2] == quotaSelect { + return fmt.Sprintf("P: %*v %*v GID [%5v]", + prioPad, q.Prioirity, opPad, q.Op, q.QuotaValue[2]) + } + return fmt.Sprintf("P: %*v %*v GID general", + prioPad, q.Prioirity, opPad, q.Op) + case quotaProj: + if q.QuotaFlags[2] == quotaSelect { + return fmt.Sprintf("P: %*v %*v Proj [%5v]", + prioPad, q.Prioirity, opPad, q.Op, q.QuotaValue[2]) + } + return fmt.Sprintf("P: %*v %*v Proj general", + prioPad, q.Prioirity, opPad, q.Op) + } + + return q.Raw(false) +} + func (q QuotaRule) HumanString() string { limit := fmt.Sprintf("%v", q.Limit) if q.Op == QuotaData {