From: ashford@whisperpc.com
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] Add validation for sector size
Date: Thu, 22 Jan 2009 10:20:02 -0800 (PST) [thread overview]
Message-ID: <41569.75.80.183.92.1232648402.squirrel@www.whisperpc.com> (raw)
In-Reply-To: <1232492841.16352.2.camel@think.oraclecorp.com>
In mkfs.btrfs, the sector size must be a power of two for the second half of
the leafsize and nodesize checks to work, but sectorsize is never validated.
# diff -u mkfs.c- mkfs.c
--- mkfs.c- 2009-01-20 11:37:39.000000000 -0800
+++ mkfs.c 2009-01-22 10:13:49.000000000 -0800
@@ -391,14 +391,22 @@
}
}
sectorsize = max(sectorsize, (u32)getpagesize());
+ if ((sectorsize & (sectorsize - 1))) {
+ fprintf(stderr, "Sector size %u must be a power of 2\n",
+ sectorsize);
+ exit(1);
+ }
+
if (leafsize < sectorsize || (leafsize & (sectorsize - 1))) {
fprintf(stderr, "Illegal leafsize %u\n", leafsize);
exit(1);
}
+
if (nodesize < sectorsize || (nodesize & (sectorsize - 1))) {
fprintf(stderr, "Illegal nodesize %u\n", nodesize);
exit(1);
}
+
ac = ac - optind;
if (ac == 0)
print_usage();
#
prev parent reply other threads:[~2009-01-22 18:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-20 20:54 [Discussion] Extent Block Group allocations ashford
2009-01-20 23:07 ` Chris Mason
2009-01-22 18:20 ` ashford [this message]
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=41569.75.80.183.92.1232648402.squirrel@www.whisperpc.com \
--to=ashford@whisperpc.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