From: zimilo@code-trick.com
To: linux-btrfs@vger.kernel.org
Cc: Rock <zimilo@code-trick.com>
Subject: [RESEND PATCH V2][BTRFS-PROGS] [BUG] Fix Bug to corrupt the img file
Date: Fri, 26 Oct 2012 07:38:57 +0800 [thread overview]
Message-ID: <1351208337-3455-1-git-send-email-zimilo@code-trick.com> (raw)
From: Rock <zimilo@code-trick.com>
Reproduce steps:
> dd if=/dev/zero of=btrfs-small.img bs=1M count=1
> ls -lh btrfs-small.img
-rw-rw-r--. 1 rock rock 1.0M Oct 24 09:51 btrfs-small.img
^^^
> mkfs.btrfs btrfs-small.img
-rw-rw-r--. 1 rock rock 2.0M Oct 24 09:53 btrfs-small.img
^^^
Here you can see the original img file's size goes larger to 2Mb.
Signed-off-by: Rock Lee <zimilo@code-trick.com>
---
utils.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/utils.c b/utils.c
index 205e667..7ba746e 100644
--- a/utils.c
+++ b/utils.c
@@ -557,6 +557,12 @@ int btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_ret,
}
if (max_block_count)
block_count = min(block_count, max_block_count);
+
+ if (block_count < 2 * 1024 * 1024) {
+ fprintf(stderr, "size of %s is too small(less than 2Mb)\n", file);
+ exit(1);
+ }
+
zero_end = 1;
if (block_count < 1024 * 1024 * 1024 && !(*mixed)) {
--
1.7.9.5
reply other threads:[~2012-10-25 23:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1351208337-3455-1-git-send-email-zimilo@code-trick.com \
--to=zimilo@code-trick.com \
--cc=linux-btrfs@vger.kernel.org \
/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).