Whamcloud - gitweb
mke2fs: fix for the "-E offset=N" option
authorMarcus Huewe <suse-tux@gmx.de>
Sun, 27 Mar 2016 02:26:40 +0000 (22:26 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 27 Mar 2016 02:26:40 +0000 (22:26 -0400)
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>
misc/mke2fs.c

index 3ab4729..b5c7a00 100644 (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;