Bug 224040 - edquota -h omits B prefix when diskusage <= 8kBytes
Summary: edquota -h omits B prefix when diskusage <= 8kBytes
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 10.4-STABLE
Hardware: amd64 Any
: --- Affects Some People
Assignee: freebsd-bugs mailing list
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2017-12-02 19:05 UTC by Dr. Andreas Haakh
Modified: 2017-12-02 20:13 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dr. Andreas Haakh 2017-12-02 19:05:50 UTC
Hi,

edquota psh leads to
Quotas for user psh:
/datM: in use: 11656956k, limits (soft = 29360128k, hard = 31457280k)
        inodes in use: 3742, limits (soft = 10000, hard = 15000)
/datV: in use: 8k, limits (soft = 8000k, hard = 10240k)
        inodes in use: 1, limits (soft = 10000, hard = 15000)
which is fine. You can edit and save your choices

edquota -h psh:
Quotas for user psh:
/datM: in use: 11G, limits (soft = 28G, hard = 30G)
        inodes in use: 3742, limits (soft = 10k, hard = 15k)
/datV: in use: 8192, limits (soft = 8000K, hard = 10M)
        inodes in use: 1, limits (soft = 10k, hard = 15k)
------------------^^ missing prefix B
causes
edquota: /datV: in use: 8192, limits (soft = 8000K, hard = 10M): bad format

with the patch applied:
edquota -h psh leads to
Quotas for user psh:
/datM: in use: 11G, limits (soft = 28G, hard = 30G)
        inodes in use: 3742, limits (soft = 10k, hard = 15k)
/datV: in use: 8192B, limits (soft = 8000K, hard = 10M)
        inodes in use: 1, limits (soft = 10k, hard = 15k)
and the error is gone when saving changed values.


The fix is simple:
--- usr.sbin/edquota/edquota.c  (Revision 326108)
+++ usr.sbin/edquota/edquota.c  (Arbeitskopie)
@@ -506,7 +506,7 @@
 
        if (hflag) {
                humanize_number(numbuf, blocks < 0 ? 7 : 6,
-                   dbtob(blocks), "", HN_AUTOSCALE, HN_NOSPACE);
+                   dbtob(blocks), "", HN_AUTOSCALE, HN_B | HN_NOSPACE);
                return (numbuf);
        }
        snprintf(numbuf, sizeof(numbuf), "%juk", (uintmax_t)dbtokb(blocks));

regards
Andreas