summaryrefslogtreecommitdiffstats
path: root/sbin/swapon
diff options
context:
space:
mode:
authorhrs <hrs@FreeBSD.org>2013-09-05 20:50:52 +0000
committerhrs <hrs@FreeBSD.org>2013-09-05 20:50:52 +0000
commit81f77e5addb59457a633ddbd4b60b19c1d7e29ae (patch)
tree55d16499808c08d79267a801166722a246dde16e /sbin/swapon
parent4b58ef1a3ff9c3b82934962811f08ae233842ce0 (diff)
downloadFreeBSD-src-81f77e5addb59457a633ddbd4b60b19c1d7e29ae.zip
FreeBSD-src-81f77e5addb59457a633ddbd4b60b19c1d7e29ae.tar.gz
Enable "late" option when a file= option is specified in /etc/fstab.
The file= option requires rw mount where the backing store exists but it does not work because rc.d/swap runs before rc.d/fsck. Reported by: wblock
Diffstat (limited to 'sbin/swapon')
-rw-r--r--sbin/swapon/swapon.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/sbin/swapon/swapon.c b/sbin/swapon/swapon.c
index d93277c..7cf7df8 100644
--- a/sbin/swapon/swapon.c
+++ b/sbin/swapon/swapon.c
@@ -170,13 +170,20 @@ main(int argc, char **argv)
if (which_prog == SWAPON || which_prog == SWAPOFF) {
if (doall) {
while ((fsp = getfsent()) != NULL) {
- if (strcmp(fsp->fs_type, FSTAB_SW))
+ if (strcmp(fsp->fs_type, FSTAB_SW) != 0)
continue;
- if (strstr(fsp->fs_mntops, "noauto"))
+ if (strstr(fsp->fs_mntops, "noauto") != NULL)
continue;
+ /*
+ * Forcibly enable "late" option when file= is
+ * specified. This is because mounting file
+ * systems with rw option is typically
+ * required to make the backing store ready.
+ */
if (which_prog != SWAPOFF &&
- strstr(fsp->fs_mntops, "late") &&
- !late)
+ (strstr(fsp->fs_mntops, "late") != NULL ||
+ strstr(fsp->fs_mntops, "file=") != NULL) &&
+ late == 0)
continue;
swfile = swap_on_off(fsp->fs_spec, 1,
fsp->fs_mntops);
OpenPOWER on IntegriCloud