From 23d6ef9e1302937d59437688820f6268d821016b Mon Sep 17 00:00:00 2001 From: Bron Gondwana Date: Thu, 13 Jun 2019 12:33:47 +1000 Subject: [PATCH] quota: add '-n' to report differences without fixing things! --- .../imap/reference/manpages/systemcommands/quota.rst | 5 +++++ imap/quota.c | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docsrc/imap/reference/manpages/systemcommands/quota.rst b/docsrc/imap/reference/manpages/systemcommands/quota.rst index df5c64c2df..a678aa35a2 100644 --- a/docsrc/imap/reference/manpages/systemcommands/quota.rst +++ b/docsrc/imap/reference/manpages/systemcommands/quota.rst @@ -64,6 +64,11 @@ Options Fix any inconsistencies in the quota subsystem before generating a report. +.. option:: -n + + Check for any inconsistencies in the quota subsystem but don't actually + fix them. Use with **-f** and **-q** to only see what's incorrect. + .. option:: -q Operate quietly. If **-f** is specified, then don't print the quota diff --git a/imap/quota.c b/imap/quota.c index ed6dbbd158..e032713b54 100644 --- a/imap/quota.c +++ b/imap/quota.c @@ -116,6 +116,7 @@ static int (*compar)(const char *s1, const char *s2); static struct quotaentry *quotaroots; static int quota_num = 0, quota_alloc = 0; static int quota_todo = 0; +static int flag_reportonly = 0; static int test_sync_mode = 0; @@ -153,6 +154,10 @@ int main(int argc,char **argv) isuser = 1; break; + case 'n': + flag_reportonly = 1; + break; + case 'J': jsonout = json_object(); break; @@ -563,7 +568,8 @@ int fixquota_finish(int thisquota) if (!quotaroots[thisquota].refcount) { quotaroots[thisquota].deleted = 1; fprintf(stderr, "%s: removed\n", root); - r = quota_deleteroot(root, 0); + if (!flag_reportonly) + r = quota_deleteroot(root, 0); if (r) { errmsg("failed deleting quotaroot '%s'", root, r); } @@ -586,7 +592,8 @@ int fixquota_finish(int thisquota) quota_names[res], localq.useds[res], localq.scanuseds[res]); - localq.useds[res] = localq.scanuseds[res]; + if (!flag_reportonly) + localq.useds[res] = localq.scanuseds[res]; } }