From: Marcus Huewe Date: Sun, 27 Mar 2016 02:26:40 +0000 (-0400) Subject: mke2fs: fix for the "-E offset=N" option X-Git-Tag: v1.43-WIP-2016-05-12~33 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=cba3fd5ca1e90fafe20386af41bb5aeeae3e3fd2;p=tools%2Fe2fsprogs.git mke2fs: fix for the "-E offset=N" option Configure the io channel with the specified offset before calling mke2fs_discard_device(). Otherwise the data before offset is discarded. Signed-off-by: Marcus Huewe Signed-off-by: Theodore Ts'o --- diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 3ab4729..b5c7a00 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -2815,6 +2815,14 @@ int main (int argc, char *argv[]) ext2fs_has_feature_journal(&fs_param))) journal_blocks = figure_journal_size(journal_size, fs); + sprintf(opt_string, "tdb_data_size=%d", fs->blocksize <= 4096 ? + 32768 : fs->blocksize * 8); + io_channel_set_options(fs->io, opt_string); + if (offset) { + sprintf(opt_string, "offset=%llu", offset); + io_channel_set_options(fs->io, opt_string); + } + /* Can't undo discard ... */ if (!noaction && discard && dev_size && (io_ptr != undo_io_manager)) { retval = mke2fs_discard_device(fs); @@ -2829,14 +2837,6 @@ int main (int argc, char *argv[]) } } - sprintf(opt_string, "tdb_data_size=%d", fs->blocksize <= 4096 ? - 32768 : fs->blocksize * 8); - io_channel_set_options(fs->io, opt_string); - if (offset) { - sprintf(opt_string, "offset=%llu", offset); - io_channel_set_options(fs->io, opt_string); - } - if (fs_param.s_flags & EXT2_FLAGS_TEST_FILESYS) fs->super->s_flags |= EXT2_FLAGS_TEST_FILESYS;