e2fsprogs: Fix how we treat user-spcified filesystem size
PATCH 1/1 e2fsprogs: Fix how we treat user-spcified filesystem size
mke2fs and resize2fs allows specifying filesystem size as a parameter, former called as blocks-count. However it has been a little bit messy so this commit fixes it mainly by updating man pages.
We can not specify filesystem size in blocks count withou specifying blocksize as well. It is because we need blocks count to determine filesystem type, and we need filesystem type to determine blocksize. So it should not be allowed, however due to compatibility reason it should be still possible, so at least print warning message for now, so we can easily restrict that later.
Filesystem size can be specified using units as suffixes. This was not documented for mke2fs, so this commits adds proper documentation into mke2fs man page.
For the sake of completeness add 'b' (blocks count) unit.
--- lib/e2p/parse_num.c | 9 +++++++++ misc/mke2fs.8.in | 40 ++++++++++++++++++++++++++++++++++------ resize/resize2fs.8.in | 8 ++++---- 3 files changed, 47 insertions(+), 10 deletions(-)
lib/e2p/parse_num.c +9 -0
@@ -10,6 +10,7 @@*/ #include "e2p.h" +#include "../misc/nls-enable.h" #include <stdlib.h>
@@ -37,6 +38,14 @@ unsigned long long parse_num_blocks2(const char *arg, int log_block_size) num >>= (1 +log_block_size);break ;case '\0' : +case 'b' : +if (!log_block_size) { +fprintf (stderr, +_ ("Warning: You can not specify blocks count " +"without specifying block size '-b'. Will " +"assume kilobytes instead of blocks count!.\n" + )); + }break ;default :return 0 ;
misc/mke2fs.8.in +34 -6
@@ -108,7 +108,7 @@ mke2fs \- create an ext2/ext3/ext4 filesystem ] .I device [ -.I blocks-count +.I filesystem-size ] @[email protected] @[email protected] "mke2fs \-O journal_dev"
@@ -136,7 +136,7 @@ mke2fs \- create an ext2/ext3/ext4 filesystem @JDEV@] @[email protected] external-journal @JDEV@[ -@[email protected] blocks-count +@[email protected] filesystem-size @JDEV@] .SH DESCRIPTION .B mke2fs
@@ -145,15 +145,43 @@ partition. .I device is the special file corresponding to the device (e.g .IR /dev/hdXX ). -.I blocks-count -is the number of blocks on the device. If omitted, -.B mke2fs -automagically figures the file system size. If called as +.I filesystem-size +is the size of the filesystem you want to create. +If no units are specified, the units of the +.I filesystem-size +parameter shall be the blocks count of the filesystem. Keep in mind that +you can not specify +.I filesystem-size +in blocks count without specifying the blocksize as well. This will be +allowed for now (kilobytes will be assumed) +due to compatibility reasons, however it may be restricted +in the future. +Optionally, the +.I filesystem-size +parameter may be suffixed by one of the following the units +designators: 'b', 's', 'K', 'M', or 'G', +for blocks count, 512 byte sectors, kilobytes, megabytes, or gigabytes, +respectively. +The +.I filesystem-size +may never be larger than the size of the partition. +If +.I filesystem-size +parameter is not specified, it will default to the size of the partition. +If called as .B mkfs.ext3 a journal is created as if the .B \-j option was specified. .PP +Note: when kilobytes is used above, I mean +.IR real , +power-of-2 kilobytes, (i.e., 1024 bytes), which some politically correct +folks insist should be the stupid-sounding ``kibibytes''. The same +holds true for megabytes, also sometimes known as ``mebibytes'', or +gigabytes, as the amazingly silly ``gibibytes''. Makes you want to +gibber, doesn't it? +.PP The defaults of the parameters for the newly created filesystem, if not overridden by the options listed below, are controlled by the .B /etc/mke2fs.conf
resize/resize2fs.8.in +4 -4
@@ -38,13 +38,13 @@ The parameter specifies the requested new size of the filesystem. If no units are specified, the units of the .I size -parameter shall be the filesystem blocksize of the filesystem. +parameter shall be the blocks count of the filesystem. Optionally, the .I size parameter may be suffixed by one of the following the units -designators: 's', 'K', 'M', or 'G', -for 512 byte sectors, kilobytes, megabytes, or gigabytes, respectively. -The +designators: 'b', 's', 'K', 'M', or 'G', +for blocks count, 512 byte sectors, kilobytes, megabytes, or gigabytes, +respectively. The .I size of the filesystem may never be larger than the size of the partition. If
Signature · 1 line
1.7.2.3
misc/mke2fs.8.in partition. · line 164
Quoted 6 lines · Lukas Czerner
misc/mke2fs.8.in +6
-0+Optionally, the +.I filesystem-size +parameter may be suffixed by one of the following the units +designators: 'b', 's', 'K', 'M', or 'G', +for blocks count, 512 byte sectors, kilobytes, megabytes, or gigabytes, +respectively.
My reading of parse_num_blocks() shows that 'T' is also accepted as a suffix for terabytes, which I was otherwise going to suggest be added, since this is the normal size for filesystems today. It might be worthwhile _briefly_ mentioning here that these are binary/power-of-two values and not decimal values, instead of the rant further below.
Minor technical nit - the proper metric value is lower-case 'k' for kilo, though the upper-case 'M', 'G', and 'T' are correct for mega-, giga-, and terabytes.
resize/resize2fs.8.in The · line 40
Quoted 7 lines
resize/resize2fs.8.in +3
-0@@ -38,13 +38,13 @@ The +designators: 'b', 's', 'K', 'M', or 'G', +for blocks count, 512 byte sectors, kilobytes, megabytes, or gigabytes, +respectively. The
Similarly, this also supports 'T' for terabytes, since it uses the same parse_num_blocks() function.
Cheers, Andreas
Quoted 9 lines · Andreas Dilger
misc/mke2fs.8.in partition. · line 164
Quoted 6 lines · Lukas Czerner
misc/mke2fs.8.in +6
-0+Optionally, the +.I filesystem-size +parameter may be suffixed by one of the following the units +designators: 'b', 's', 'K', 'M', or 'G', +for blocks count, 512 byte sectors, kilobytes, megabytes, or gigabytes, +respectively.My reading of
parse_num_blocks()shows that 'T' is also accepted as a suffix for terabytes, which I was otherwise going to suggest be added, since this is the normal size for filesystems today. It might be worthwhile _briefly_ mentioning here that these are binary/power-of-two values and not decimal values, instead of the rant further below.
The rant below was ripped of resize2fs man page, but I agree.
Quoted 2 lines
Minor technical nit - the proper metric value is lower-case 'k' for kilo, though the upper-case 'M', 'G', and 'T' are correct for mega-, giga-, and terabytes.
You're right, I completely missed 'T', will fix that. Regarding the minor technical nit, I know that, but I have just ripped that from resize2fs man page without really paying attention. Anyway thanks for corrections I'll fix it as well.
Quoted 11 lines
resize/resize2fs.8.in The · line 40
Quoted 8 lines
resize/resize2fs.8.in +3
-0@@ -38,13 +38,13 @@ The +designators: 'b', 's', 'K', 'M', or 'G', +for blocks count, 512 byte sectors, kilobytes, megabytes, or gigabytes, +respectively. TheSimilarly, this also supports 'T' for terabytes, since it uses the same
parse_num_blocks()function.
Quoted 2 lines
Cheers, Andreas
Thanks!
-Lukas
Quoted 11 lines · Andreas Dilger
misc/mke2fs.8.in partition. · line 164
Quoted 6 lines · Lukas Czerner
misc/mke2fs.8.in +6
-0+Optionally, the +.I filesystem-size +parameter may be suffixed by one of the following the units +designators: 'b', 's', 'K', 'M', or 'G', +for blocks count, 512 byte sectors, kilobytes, megabytes, or gigabytes, +respectively.My reading of
parse_num_blocks()shows that 'T' is also accepted as a suffix for terabytes, which I was otherwise going to suggest be added, since this is the normal size for filesystems today. It might be worthwhile _briefly_ mentioning here that these are binary/power-of-two values and not decimal values, instead of the rant further below.Minor technical nit - the proper metric value is lower-case 'k' for kilo, though the upper-case 'M', 'G', and 'T' are correct for mega-, giga-, and terabytes.
<pedantic>
If they are powers of 2, they are: kibibytes, mebibytes, gibibytes, and tebibytes.
See the chart on the right of: http://en.wikipedia.org/wiki/Kibibyte
Many linux tools have already moved to these names and abbreviations. (TiB not TB, etc.)
<\pedantic>
Greg
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 17 lines · Greg Freemyer
Quoted 11 lines · Andreas Dilger
misc/mke2fs.8.in partition. · line 164
Quoted 6 lines · Lukas Czerner
misc/mke2fs.8.in +6
-0+Optionally, the +.I filesystem-size +parameter may be suffixed by one of the following the units +designators: 'b', 's', 'K', 'M', or 'G', +for blocks count, 512 byte sectors, kilobytes, megabytes, or gigabytes, +respectively.My reading of
parse_num_blocks()shows that 'T' is also accepted as a suffix for terabytes, which I was otherwise going to suggest be added, since this is the normal size for filesystems today. It might be worthwhile _briefly_ mentioning here that these are binary/power-of-two values and not decimal values, instead of the rant further below.Minor technical nit - the proper metric value is lower-case 'k' for kilo, though the upper-case 'M', 'G', and 'T' are correct for mega-, giga-, and terabytes.
<pedantic>
If they are powers of 2, they are: kibibytes, mebibytes, gibibytes, and tebibytes.
Quoted 8 lines
See the chart on the right of: http://en.wikipedia.org/wiki/Kibibyte
Many linux tools have already moved to these names and abbreviations. (TiB not TB, etc.)
<\pedantic>Greg
Right, that's why there is the "rant" about it being called kilobytes, but still treated as binary, not decimal unit. But Andreas is right that it is not necessary to have one paragraph grumbling about the stupid-sounding kibibytes and so on.
So, what I am going to do is to cope with the standard and use those stupid-sounding binary prefixes (kibi- etc.), remove the "rant" and add one line note for people to be really sure that it is meant to be a binary unit.
Thanks!
-Lukas
Quoted 33 lines · Lukas Czerner
Quoted 17 lines · Greg Freemyer
Quoted 11 lines · Andreas Dilger
misc/mke2fs.8.in partition. · line 164
Quoted 6 lines · Lukas Czerner
misc/mke2fs.8.in +6
-0+Optionally, the +.I filesystem-size +parameter may be suffixed by one of the following the units +designators: 'b', 's', 'K', 'M', or 'G', +for blocks count, 512 byte sectors, kilobytes, megabytes, or gigabytes, +respectively.My reading of
parse_num_blocks()shows that 'T' is also accepted as a suffix for terabytes, which I was otherwise going to suggest be added, since this is the normal size for filesystems today. It might be worthwhile _briefly_ mentioning here that these are binary/power-of-two values and not decimal values, instead of the rant further below.Minor technical nit - the proper metric value is lower-case 'k' for kilo, though the upper-case 'M', 'G', and 'T' are correct for mega-, giga-, and terabytes.
<pedantic>
If they are powers of 2, they are: kibibytes, mebibytes, gibibytes, and tebibytes.Quoted 8 lines
See the chart on the right of: http://en.wikipedia.org/wiki/Kibibyte
Many linux tools have already moved to these names and abbreviations. (TiB not TB, etc.)
<\pedantic>Greg
Right, that's why there is the "rant" about it being called kilobytes, but still treated as binary, not decimal unit. But Andreas is right that it is not necessary to have one paragraph grumbling about the stupid-sounding kibibytes and so on.
Quoted 7 lines
So, what I am going to do is to cope with the standard and use those stupid-sounding binary prefixes (kibi- etc.), remove the "rant" and add one line note for people to be really sure that it is meant to be a binary unit.
Thanks!
-Lukas
Lukas,
I'm glad you did that. I see too often:
Fdisk is broken, I can only put a 150 gigabyte partition on my 160 gigabyte drive.
Hopefully people will realize the difference when they see its a 150 Gibibyte partition on a 160 Gigabyte drive.
Greg
Signature · 14 lines
Greg Freemyer Head of EDD Tape Extraction and Processing team Litigation Triage Solutions Specialist http://www.linkedin.com/in/gregfreemyer CNN/TruTV Aired Forensic Imaging Demo - http://insession.blogs.cnn.com/2010/03/23/how-computer-evidence-gets-retrieved/ The Norcross Group The Intersection of Evidence & Technology http://www.norcrossgroup.com -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 14 lines · Greg Freemyer
Quoted 5 lines
Right, that's why there is the "rant" about it being called kilobytes, but still treated as binary, not decimal unit. But Andreas is right that it is not necessary to have one paragraph grumbling about the stupid-sounding kibibytes and so on.
Quoted 7 lines
So, what I am going to do is to cope with the standard and use those stupid-sounding binary prefixes (kibi- etc.), remove the "rant" and add one line note for people to be really sure that it is meant to be a binary unit.
Thanks!
-LukasLukas,
Quoted 7 lines
I'm glad you did that. I see too often:
Fdisk is broken, I can only put a 150 gigabyte partition on my 160 gigabyte drive.
Hopefully people will realize the difference when they see its a 150 Gibibyte partition on a 160 Gigabyte drive.
That's wishful thinking.