]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
mkswap: improve diagnostics message if the device is mounted
authorPetr Uzel <petr.uzel@suse.cz>
Sun, 13 May 2012 11:44:32 +0000 (13:44 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 15 May 2012 09:19:53 +0000 (11:19 +0200)
Currently, attempt to create swap on mounted partition results
with "/dev/sdXy: Device or resource busy" message being printed.
Change this to explicitly telling the user that the device is mounted.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
disk-utils/mkswap.c

index dec34e1ae381055e34ec5fb8dacf8b30883791af..43129a7d1639035887baff7dbd1ddcebb5903f31 100644 (file)
@@ -582,6 +582,11 @@ main(int argc, char **argv) {
                        PAGES * pagesize / 1024);
        }
 
+       if (is_mounted(device_name))
+               errx(EXIT_FAILURE, _("error: "
+                       "%s is mounted; will not make swapspace."),
+                       device_name);
+
        if (stat(device_name, &statbuf) < 0) {
                perror(device_name);
                exit(EXIT_FAILURE);
@@ -598,10 +603,6 @@ main(int argc, char **argv) {
 
        if (!S_ISBLK(statbuf.st_mode))
                check=0;
-       else if (is_mounted(device_name))
-               errx(EXIT_FAILURE, _("error: "
-                       "%s is mounted; will not make swapspace."),
-                       device_name);
        else if (blkdev_is_misaligned(DEV))
                warnx(_("warning: %s is misaligned"), device_name);