1 - mkswap "works" without warning on a mounted device
3 --- util-linux-2.13-pre6/disk-utils/mkswap.c.kzak 2006-10-12 11:33:50.000000000 +0200
4 +++ util-linux-2.13-pre6/disk-utils/mkswap.c 2006-10-12 11:36:08.000000000 +0200
10 #include <sys/ioctl.h> /* for _IO */
11 #include <sys/utsname.h>
14 return (c >= '1' && c <= '9');
19 + * Check to make certain that our new filesystem won't be created on
20 + * an already mounted partition. Code adapted from mke2fs, Copyright
21 + * (C) 1994 Theodore Ts'o. Also licensed under GPL.
22 + * (C) 2006 Karel Zak -- port to mkswap
27 + struct mntent * mnt;
29 + if ((f = setmntent (MOUNTED, "r")) == NULL)
31 + while ((mnt = getmntent (f)) != NULL)
32 + if (strcmp (device_name, mnt->mnt_fsname) == 0)
41 main(int argc, char ** argv) {
44 /* Want a block device. Probably not /dev/hda or /dev/hdb. */
45 if (!S_ISBLK(statbuf.st_mode))
47 - else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340)
48 - die(_("Will not try to make swapdevice on '%s'"));
49 + else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340) {
52 + "will not try to make swapdevice on '%s'\n"),
53 + program_name, device_name);
55 + } else if (check_mount()) {
58 + "%s is mounted; will not make swapspace.\n"),
59 + program_name, device_name);
64 if (!force && version == 0) {