]> err.no Git - util-linux/commitdiff
mkswap: unbreak -c ("check") option.
authorPeter De Wachter <pdewacht@gmail.com>
Sat, 5 Sep 2009 19:19:56 +0000 (21:19 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 7 Sep 2009 07:27:18 +0000 (09:27 +0200)
In the check_blocks() loop, current_page is not incremented. Because of this
bug, the loop does not end when the end of the device is reached.  Instead it
tries to continue reading, which of course fails, and eventually mkswap aborts
("too many bad pages").

Note that this can only be tested with swap partitions, mkswap ignores the -c
option for swap files.

Signed-off-by: Peter De Wachter <pdewacht@gmail.com>
disk-utils/mkswap.c

index bb97210ec955c6797a291e5bc15c1568341c4108..bdfa8f7a9123bb172914f37e31724ce58f357183 100644 (file)
@@ -309,9 +309,9 @@ check_blocks(void) {
                    current_page*pagesize)
                        die(_("seek failed in check_blocks"));
                if ((do_seek = (pagesize != read(DEV, buffer, pagesize)))) {
-                       page_bad(current_page++);
-                       continue;
+                       page_bad(current_page);
                }
+               current_page++;
        }
        if (badpages == 1)
                printf(_("one bad page\n"));