From: Lukas Czerner <lczerner@redhat.com>
To: linux-ext4@vger.kernel.org
Cc: tytso@MIT.EDU, lczerner@redhat.com
Subject: [PATCH] e2fsprogs: Fix how we treat user-spcified filesystem size
Date: Tue, 1 Feb 2011 20:18:32 +0100 [thread overview]
Message-ID: <1296587912-16756-1-git-send-email-lczerner@redhat.com> (raw)
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.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
lib/e2p/parse_num.c | 9 +++++++++
misc/mke2fs.8.in | 40 ++++++++++++++++++++++++++++++++++------
resize/resize2fs.8.in | 8 ++++----
3 files changed, 47 insertions(+), 10 deletions(-)
diff --git a/lib/e2p/parse_num.c b/lib/e2p/parse_num.c
index 83a329a..5e7924b 100644
--- a/lib/e2p/parse_num.c
+++ b/lib/e2p/parse_num.c
@@ -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;
diff --git a/misc/mke2fs.8.in b/misc/mke2fs.8.in
index 2eead17..67a69b8 100644
--- a/misc/mke2fs.8.in
+++ b/misc/mke2fs.8.in
@@ -108,7 +108,7 @@ mke2fs \- create an ext2/ext3/ext4 filesystem
]
.I device
[
-.I blocks-count
+.I filesystem-size
]
@JDEV@.sp
@JDEV@.B "mke2fs \-O journal_dev"
@@ -136,7 +136,7 @@ mke2fs \- create an ext2/ext3/ext4 filesystem
@JDEV@]
@JDEV@.I external-journal
@JDEV@[
-@JDEV@.I blocks-count
+@JDEV@.I 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
diff --git a/resize/resize2fs.8.in b/resize/resize2fs.8.in
index e02345d..52aaef8 100644
--- a/resize/resize2fs.8.in
+++ b/resize/resize2fs.8.in
@@ -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
--
1.7.2.3
next reply other threads:[~2011-02-01 19:18 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-01 19:18 Lukas Czerner [this message]
2011-02-01 20:37 ` [PATCH] e2fsprogs: Fix how we treat user-spcified filesystem size Andreas Dilger
2011-02-01 21:08 ` Lukas Czerner
2011-02-01 21:57 ` Greg Freemyer
2011-02-02 10:12 ` Lukas Czerner
2011-02-02 17:56 ` Greg Freemyer
2011-02-02 18:05 ` Sunil Mushran
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1296587912-16756-1-git-send-email-lczerner@redhat.com \
--to=lczerner@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@MIT.EDU \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).