diff options
author | trasz <trasz@FreeBSD.org> | 2016-05-10 08:44:44 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2016-05-10 08:44:44 +0000 |
commit | 8e6e54de641f300c70302f954c7853f0f46616a9 (patch) | |
tree | 5742fbabd683728c69b68d3d4c57d83930d6b1ad /etc/rc.subr | |
parent | afb02a35fa1b82fd030ce96419146aa528d5cd84 (diff) | |
download | FreeBSD-src-8e6e54de641f300c70302f954c7853f0f46616a9.zip FreeBSD-src-8e6e54de641f300c70302f954c7853f0f46616a9.tar.gz |
Refactor the root mount hold code and add the wait to etc/rc.d/fsck.
This fixes mounting (non-root) USB drives on boot with fsck enabled
(with non-zero 'Pass#' field in fstab(5)).
Reported by: Graham Menhennitt <graham at menhennitt.com.au>
Reviewed by: jilles@
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D6221
Diffstat (limited to 'etc/rc.subr')
-rw-r--r-- | etc/rc.subr | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/etc/rc.subr b/etc/rc.subr index d04e253..8da111a 100644 --- a/etc/rc.subr +++ b/etc/rc.subr @@ -1954,6 +1954,37 @@ geli_make_list() echo ${devices2} } +# Originally, root mount hold had to be released before mounting +# the root filesystem. This delayed the boot, so it was changed +# to only wait if the root device isn't readily available. This +# can result in rc scripts executing before all the devices - such +# as graid(8), or USB disks - can be accessed. This function can +# be used to explicitly wait for root mount holds to be released. +root_hold_wait() +{ + local wait waited holders + + waited=0 + while true; do + holders="$(sysctl -n vfs.root_mount_hold)" + if [ -z "${holders}" ]; then + break; + fi + if [ ${waited} -eq 0 ]; then + echo -n "Waiting ${root_hold_delay}s" \ + "for the root mount holders: ${holders}" + else + echo -n . + fi + if [ ${waited} -ge ${root_hold_delay} ]; then + echo + break + fi + sleep 1 + waited=$(($waited + 1)) + done +} + # Find scripts in local_startup directories that use the old syntax # find_local_scripts_old() { |