]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
mke2fs: If the device supports discard, don't print an error message
authorTheodore Ts'o <tytso@mit.edu>
Mon, 28 Feb 2011 01:09:54 +0000 (20:09 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 28 Feb 2011 01:09:54 +0000 (20:09 -0500)
Check to see if the device supports discard before starting the
progress bar, and then printing an error about inappropriate ioctl for
device (when creating a file system image to a file, for example).

Also, add a function signature in the ext2_io.h header file for
io_channel_discard() and fix an extra, uneeded argument in mke2fs's
call to that function.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/ext2fs/ext2_io.h
misc/mke2fs.c

index ba97341b108fb1a84482afe38bdaa6375fbc78a7..e71ada99d2fcd47467f178a581072190de396efb 100644 (file)
@@ -117,6 +117,9 @@ extern errcode_t io_channel_read_blk64(io_channel channel,
 extern errcode_t io_channel_write_blk64(io_channel channel,
                                        unsigned long long block,
                                        int count, const void *data);
+extern errcode_t io_channel_discard(io_channel channel,
+                                   unsigned long long block,
+                                   unsigned long long count);
 
 /* unix_io.c */
 extern io_manager unix_io_manager;
index 7866c2c1d6f79bc701717ad115d2a9770a6e27db..9798b888dbc663439d720a9afb5792b30ae52549 100644 (file)
@@ -2015,6 +2015,10 @@ static int mke2fs_discard_device(ext2_filsys fs)
        blk64_t cur = 0;
        int retval = 0;
 
+       retval = io_channel_discard(fs->io, 0, 0);
+       if (retval)
+               return retval;
+
        count *= (1024 * 1024);
        count /= fs->blocksize;
 
@@ -2027,7 +2031,7 @@ static int mke2fs_discard_device(ext2_filsys fs)
                if (cur + count > blocks)
                        count = blocks - cur;
 
-               retval = io_channel_discard(fs->io, cur, count, fs->blocksize);
+               retval = io_channel_discard(fs->io, cur, count);
                if (retval)
                        break;
                cur += count;