# df -h and df -H units reversed?



## madoka (Jan 15, 2014)

The man page for df(1) says that with -H, it'll "se unit suffixes...based on powers of 1024" while with -h it'll "se unit suffixes based on powers of 1000", but it seems like it's the other way around:


```
# zfs create -o refquota=64000 storage/test # 64 KB = 64 * 1000
# df -b storage/test # 512 * 125 = 64000
Filesystem   512-blocks Used Avail Capacity  Mounted on
storage/test        125   71    54    57%    /storage/test
# df -H storage/test # should be 1 KB = 1024 ??
Filesystem      Size    Used   Avail Capacity  Mounted on
storage/test     64k     36k     27k    57%    /storage/test
# df -h storage/test # should be 1 KB = 1000 ??
Filesystem      Size    Used   Avail Capacity  Mounted on
storage/test     62k     35k     27k    57%    /storage/test
# df -k storage/test
Filesystem   1024-blocks Used Avail Capacity  Mounted on
storage/test          62   35    27    57%    /storage/test
```
Am I missing something?


----------



## usdmatt (Jan 15, 2014)

It appears there's a discrepancy between the man page and the code, although I'm not sure which one is doing it the right way round (I don't know if there's an existing convention for -[hH] options).

The man page says -h should use powers of 1000. The code however sets a 'UNITS_2' flag if the -h option is used, causing it to use base 2 numbers. It only uses powers of 1000 if set to use 'SI' units, which is does if you pass -H.


----------



## madoka (Jan 16, 2014)

Huh, I had looked the source, too, and I thought it was correct, but clearly I was mistaken.  I'd also searched the bug tracker and found nothing.  But I found this redoing the search again just now: bin/183681: df(1): -h and -H option: manual page have them swapped.  It was reported in November 2013.  I guess I should catch up on my sleep...


----------



## wblock@ (Jan 16, 2014)

Fixed in -CURRENT, will be MFCed to 9-STABLE in a few days.  Thanks for pointing this out!


----------



## madoka (Jan 17, 2014)

Thanks. I submitted a patch to freebsd-bugs yesterday but for some reason it didn't get posted, but I'm glad to hear that it's been resolved.


----------

