mkfs_ext2: fix a bug where we don't fully respect -n on files
authorDenys Vlasenko <vda.linux@googlemail.com>
Thu, 22 Oct 2009 10:27:10 +0000 (12:27 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Thu, 22 Oct 2009 10:27:10 +0000 (12:27 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
util-linux/mkfs_ext2.c

index 10f7f5fb4c60d8d97f66db0803b3a3e993622067..ea35e52877725606750adbae2849761a6b42deb3 100644 (file)
@@ -233,7 +233,8 @@ int mkfs_ext2_main(int argc UNUSED_PARAM, char **argv)
                kilobytes = xatoull(argv[1]);
                // seek past end fails on block devices but works on files
                if (lseek(fd, kilobytes * 1024 - 1, SEEK_SET) != (off_t)-1) {
-                       xwrite(fd, "", 1); // file grows if needed
+                       if (!(opts & OPT_n))
+                               xwrite(fd, "", 1); // file grows if needed
                }
                //else {
                //      bb_error_msg("warning, block device is smaller");