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

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

 



On Thu, 13 Dec 2007 00:09:52 +0100 Karel Zak wrote:

> 
>  When creating a new partition in fdisk, if using +sizeK (e.g.
>  +1000K) the final size is calculated by
> 
>     "size * 1024" (it means KiB)
> 
>  but if using +sizeM:
> 
>     "size * 1000000"  (it means MB)
> 
> 
>  See code:
> 
> 			switch (*line_ptr) {
> 				case 'c':
> 				case 'C':
> 					if (!display_in_cyl_units)
> 						i *= heads * sectors;
> 					break;
> 				case 'K':
> 					absolute = 1024;
> 					break;
> 				case 'k':
> 					absolute = 1000;
> 					break;
> 				case 'm':
> 				case 'M':
> 					absolute = 1000000;
> 					break;
> 				case 'g':
> 				case 'G':
> 					absolute = 1000000000;
> 					break;
> 				default:
> 					break;
> 			}
> 			if (absolute) {
> 				unsigned long long bytes;
> 				unsigned long unit;
> 
> 				bytes = (unsigned long long) i * absolute;
> 				unit = sector_size * units_per_sector;
> 				bytes += unit/2;	/* round */
> 				bytes /= unit;
> 				i = bytes;
> 			}
> 
> 
>  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.

---
~Randy
-
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