summaryrefslogtreecommitdiffstats
path: root/disk-utils/mkswap.c
diff options
context:
space:
mode:
authorPetr Uzel2012-05-13 13:44:32 +0200
committerKarel Zak2012-05-15 11:19:53 +0200
commitdceb1f220c9210a5dfa6565157b223c54f677be2 (patch)
tree0a4788e23ed7d965b2b2037a45bc1752aa0e3b0d /disk-utils/mkswap.c
parentmkswap: allow creating swap on /dev/hd[ab] (diff)
downloadkernel-qcow2-util-linux-dceb1f220c9210a5dfa6565157b223c54f677be2.tar.gz
kernel-qcow2-util-linux-dceb1f220c9210a5dfa6565157b223c54f677be2.tar.xz
kernel-qcow2-util-linux-dceb1f220c9210a5dfa6565157b223c54f677be2.zip
mkswap: improve diagnostics message if the device is mounted
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>
Diffstat (limited to 'disk-utils/mkswap.c')
-rw-r--r--disk-utils/mkswap.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c
index dec34e1ae..43129a7d1 100644
--- a/disk-utils/mkswap.c
+++ b/disk-utils/mkswap.c
@@ -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);