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 <suse-tux@gmx.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debian
Marcus Huewe 2016-03-26 22:26:40 -04:00 committed by Theodore Ts'o
parent a7ac9c222d
commit cba3fd5ca1
1 changed files with 8 additions and 8 deletions

View File

@ -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;