Re: fdisk: +size{k,K,m,M,g,G} chaos

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Karel Zak wrote:
> On Wed, Dec 12, 2007 at 03:16:46PM -0800, Randy Dunlap wrote:
>> On Thu, 13 Dec 2007 00:09:52 +0100 Karel Zak wrote:
>>>  It seems like a chaos between KiB, MiB, (2^N) and kB, MB, GB, (10^N).
>>>
>>>  Does anyone understand this code?  I don't believe it's a bug -- it's
>>>  too stupid...
>> It looks to me like someone decided that only K could mean 2^N
>> and any other suffix means 10^M.
> 
>  Yes. A proposed patch is below.
> 
>     Karel
> 
> 
> 
>>From 00855c890465670ba76934229dd6881647934e22 Mon Sep 17 00:00:00 2001
> From: Karel Zak <kzak@xxxxxxxxxx>
> Date: Thu, 13 Dec 2007 01:06:44 +0100
> Subject: [PATCH] fdisk: calculate +size{K,M,G} in 2^N
> 
> fdisk(8) does not calculate partition size (+sizeM or +sizeG)
> in MiB or GiB correctly. It uses 10^N instead 2^N.
> 
> This patch cleanups +size[kKmMgG] to:
> 
>    +size    -- bytes
>    +sizek   -- kB   (10^3)
>    +sizeK   -- KiB  (2^10)
>    +sizem   -- MB   (10^6)
>    +sizeM   -- MiB  (2^20)
>    +sizeg   -- GB   (10^9)
>    +sizeG   -- GiB  (2^30)

If you were changing the meaning, would it be better
to sync with coreutils? There it is:

<size> is a number which may be optionally followed
by the following multiplicative suffixes:
  b              512 ("blocks")
  KB            1000 (KiloBytes)
  K             1024 (KibiBytes)
  MB       1000*1000 (MegaBytes)
  M        1024*1024 (MebiBytes)
and so on for G, T, P, E, Z, Y

Pádraig.
-
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux