[BACK]Return to swap1 CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / etc / rc.d

File: [cvs.NetBSD.org] / src / etc / rc.d / swap1 (download)

Revision 1.12, Mon Apr 20 18:01:46 2015 UTC (3 years, 11 months ago) by prlw1
Branch: MAIN
CVS Tags: prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, phil-wifi-base, phil-wifi, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, pgoyette-compat-base, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315, perseant-stdc-iso10646-base, perseant-stdc-iso10646, netbsd-8-base, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, matt-nb8-mediatek-base, matt-nb8-mediatek, localcount-20160914, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan
Branch point for: pgoyette-compat
Changes since 1.11: +3 -1 lines

Apply modified version of patch from Wolfgang Stukenbrock in PR bin/41766

This forcibly unmounts tmpfs file systems, so that swapctl doesn't run
out of swap itself, eventually trying to kill pid 1.

No objections since:
  http://mail-index.netbsd.org/current-users/2015/03/16/msg026908.html

#!/bin/sh
#
# $NetBSD: swap1,v 1.12 2015/04/20 18:01:46 prlw1 Exp $
#

# PROVIDE: localswap
# REQUIRE: DISKS root
# KEYWORD: shutdown

$_rc_subr_loaded . /etc/rc.subr

name="swap1"
start_cmd="swap1_start"
stop_cmd="swap1_stop"

#		Add all block-type swap devices; these might be necessary
#		during disk checks.
#
swap1_start()
{
	# Treat exit status 2 from swapctl(8) as successful; it means
	# "no error, but no suitable swap devices were configured".
	#
	if ! checkyesno no_swap; then
		swapctl -A -t blk || [ $? = 2 ]
	fi
}

#		Remove all block-type swap devices
#
swap1_stop()
{
	if checkyesno swapoff || [ -n "$rc_force" ]; then
		echo "Forcibly unmounting tmpfs filesystems"
		umount -aft tmpfs
		echo "Removing block-type swap devices"
		swapctl -U -t blk || [ $? = 2 ]
	fi
}

load_rc_config swap
run_rc_command "$1"