mke2fs.c (PRS, set_fs_defaults): If the sector size of the
device is larger than the default block size, then use the
sector size of the device as the default block size.
getsectsize.c (ext2fs_get_device_sectsize): New function which
returns the hardware sector size (if it is available).
diff --git a/misc/ChangeLog b/misc/ChangeLog
index 22e94b2..3f94898 100644
--- a/misc/ChangeLog
+++ b/misc/ChangeLog
@@ -1,3 +1,9 @@
+2003-05-21 Theodore Ts'o <tytso@mit.edu>
+
+ * mke2fs.c (PRS, set_fs_defaults): If the sector size of the
+ device is larger than the default block size, then use the
+ sector size of the device as the default block size.
+
2003-05-18 Theodore Ts'o <tytso@mit.edu>
* badblocks.c: Use an unsigned integer to support 4-byte test
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index d30729a..545ec96 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -147,7 +147,8 @@
static void set_fs_defaults(const char *fs_type,
struct ext2_super_block *super,
- int blocksize, int *inode_ratio)
+ int blocksize, int sector_size,
+ int *inode_ratio)
{
int megs;
int ratio = 0;
@@ -170,6 +171,8 @@
blocksize : p->inode_ratio;
use_bsize = p->blocksize;
}
+ if (use_bsize < sector_size)
+ use_bsize = sector_size;
if (blocksize <= 0) {
if (use_bsize == DEF_MAX_BLOCKSIZE)
use_bsize = sys_page_size;
@@ -799,6 +802,7 @@
int inode_ratio = 0;
int inode_size = 0;
int reserved_ratio = 5;
+ int sector_size = 0;
ext2_ino_t num_inodes = 0;
errcode_t retval;
char * oldpath = getenv("PATH");
@@ -1187,7 +1191,15 @@
((tmp = getenv("MKE2FS_FIRST_META_BG"))))
param.s_first_meta_bg = atoi(tmp);
- set_fs_defaults(fs_type, ¶m, blocksize, &inode_ratio);
+ /* Get the hardware sector size, if available */
+ retval = ext2fs_get_device_sectsize(device_name, §or_size);
+ if (retval) {
+ com_err(program_name, retval,
+ _("while trying to determine hardware sector size"));
+ exit(1);
+ }
+
+ set_fs_defaults(fs_type, ¶m, blocksize, sector_size, &inode_ratio);
blocksize = EXT2_BLOCK_SIZE(¶m);
if (param.s_blocks_per_group) {