Compare commits

...

2 Commits

Author SHA1 Message Date
William Hubbs
7c9f1add21 Remove references to localmount
Convert all references to localmount to the specific file systems that
should be needed.
2015-07-31 12:44:55 -05:00
William Hubbs
a643e918dd Add experimental mount service
This is highly experimental, so read the mount-service.md file for more
info before you play with it.
2015-07-29 15:07:51 -05:00
43 changed files with 229 additions and 41 deletions

View File

@@ -1,7 +1,7 @@
include ../mk/net.mk
DIR= ${CONFDIR}
CONF= bootmisc fsck hostname localmount netmount urandom tmpfiles \
CONF= bootmisc fsck hostname localmount mount netmount urandom tmpfiles \
${CONF-${OS}}
ifeq (${MKNET},yes)

23
conf.d/mount Normal file
View File

@@ -0,0 +1,23 @@
# The mount service is a multiplexed service. This means you must have
# symbolic links to it in your init.d directory for each file system you
# want to mount. I recommend naming those symbolic links the same as the
# paths to the file systems they mount, removing the leading slash and
# substituting _ for the remaining slashes, for example:
#
# cd /etc/init.d
# ln -s mount mount.usr
# ln -s mount mount.usr_local
#
# Set up a symbolic link like this for each file system you wish to
# mount, then add the symbolic link to the appropriate runlevel. Once
# that is done, add the appropriate definitions for the file system to
# this file.
#
#You will need to define the mountpoint and any dependencies for each
#filesystem as shown here.
#
#If the mountpoint does not match an entry in fstab, the mount will be
#ignored.
#
#mount_usr_mountpoint="/usr"
#

View File

@@ -10,6 +10,6 @@ name="Avahi DNS Configuration Daemon"
depend()
{
use dns
need localmount dbus
need mount.usr mount.var dbus
after bootmisc
}

View File

@@ -10,6 +10,6 @@ name="Avahi Service Advertisement Daemon"
depend()
{
use dns
need localmount dbus
need mount.usr mount.var dbus
after bootmisc
}

View File

@@ -9,7 +9,7 @@ name="Message Bus Daemon"
depend()
{
need localmount net
need mount.usr mount.var net
after bootmisc
}

View File

@@ -10,7 +10,7 @@ name="DHCP Client Daemon"
depend()
{
provide net
need localmount
need mount.usr mount.var
use logger
after bootmisc modules
before dns

View File

@@ -12,7 +12,7 @@ extra_started_commands="reload"
depend()
{
provide dns
need localmount net
need mount.usr mount.var net
after bootmisc
}

View File

@@ -24,7 +24,7 @@ esac
depend()
{
provide dns
need localmount
need mount.usr mount.var
after bootmisc
}

View File

@@ -14,7 +14,7 @@ name="Network Time Protocol Daemon"
depend()
{
use dns
need localmount
need mount.usr mount.var
after bootmisc ntp-client
}

View File

@@ -31,7 +31,7 @@ fi
depend()
{
need localmount net
need mount.usr mount.var net
use dns
after bootmisc
}

View File

@@ -10,7 +10,7 @@ name="WPA Supplicant Daemon"
depend()
{
need localmount
need mount.usr mount.var
use logger
after bootmisc modules
before dns dhcpcd net

1
init.d/.gitignore vendored
View File

@@ -4,6 +4,7 @@ hostname
local
localmount
loopback
mount
moused
netmount
network

View File

@@ -2,7 +2,7 @@ include ../mk/net.mk
DIR= ${INITDIR}
SRCS= bootmisc.in fsck.in hostname.in local.in localmount.in loopback.in \
netmount.in osclock.in root.in savecache.in swap.in swapfiles.in \
mount.in netmount.in osclock.in root.in savecache.in swap.in swapfiles.in \
tmpfiles.setup.in swclock.in sysctl.in urandom.in s6-svscan.in ${SRCS-${OS}}
BIN= ${OBJS}

View File

@@ -4,7 +4,7 @@
depend()
{
need localmount
need mount.usr mount.var
before logger
after clock root sysctl
keyword -prefix -timeout

View File

@@ -6,7 +6,7 @@ description="Sets a font for the consoles."
depend()
{
need localmount termencoding
need mount.usr mount.var termencoding
after hotplug bootmisc
keyword -openvz -prefix -systemd-nspawn -uml -vserver -xenu -lxc
}

View File

@@ -7,7 +7,7 @@ command_args=$devd_args
name="Device State Change Daemon"
depend() {
need localmount
need mount.usr mount.var
after bootmisc
before net.lo0
keyword -jail -prefix

View File

@@ -6,7 +6,7 @@ description="Creates the dev database"
depend()
{
need localmount
need mount.usr mount.var
}
start()

View File

@@ -6,7 +6,7 @@ description="Applies a keymap for the consoles."
depend()
{
need localmount termencoding
need mount.usr mount.var termencoding
after bootmisc
keyword -openvz -prefix -systemd-nspawn -uml -vserver -xenu -lxc
}

View File

@@ -6,7 +6,7 @@ extra_commands="restore"
depend()
{
need localmount
need mount.usr mount.var
keyword -jail -prefix
}

118
init.d/mount.in Normal file
View File

@@ -0,0 +1,118 @@
#!@SBINDIR@/openrc-run
# Copyright (c) 2015 William Hubbs <w.d.hubbs@gmail.com>
# Released under the 2-clause BSD license.
description="Mount a file system defined in @SYSCONFDIR@/fstab"
extra_commands="generate"
depend()
{
need fsck
use modules mtab
after modules
keyword -jail -prefix -vserver -lxc
}
. "$RC_LIBEXECDIR"/sh/rc-mount.sh
start_pre()
{
# Do not start this service as "mount"
if [ "$rc_svcname" = mount ]; then
eerror "The mount service should not be started directly"
return 1
fi
return 0
}
start()
{
if [ "$rc_svcname" = mount-generate-symlinks ]; then
generate
return $?
fi
local mountname=${rc_svcname#*.}
local fspath=${mount_${mountname}_mountpoint}
# for now, make sure fspath is in fstab
if [ ! fstabinfo -q $fspath ]; then
einfo "$rc_svcname: $fspath is not in @SYSCONFDIR@/fstab"
return 0
fi
# Is the file system mounted?
if mountinfo -q $fspath; then
action=remount
msg=Remounting
else
action=mount
msg=Mounting
fi
ebegin "$msg $fspath according to @SYSCONFDIR@/fstab"
fstabinfo --$action $fspath
eend $? "$fspath failed to $action"
}
stop_pre()
{
# Do not stop this service as "mount"
if [ "$rc_svcname" = mount ]; then
eerror "The mount service should not be stopped directly"
return 1
fi
return 0
}
stop()
{
yesno $RC_GOINGDOWN || return 0
local mountname=${rc_svcname#*.}
local fspath=${mount_${mountname}_mountpoint}
# make sure fspath is in fstab
if ! fstabinfo -q $fspath; then
einfo "$rc_svcname: $fspath is not in @SYSCONFDIR@/fstab"
return 0
fi
# Is the file system mounted?
mountinfo -q $fspath || return 0
# Flush all pending disk writes now
sync
ebegin "Unmounting $fspath"
do_unmount umount $fspath
eend $? "Unable to umount $fspath"
return 0
}
generate()
{
local fslist="$(fstabinfo)"
local fs fsopts rc=0
local svcpath=${RC_SVCNAME%/*}
ebegin "Generating mount symlinks"
for fs in $fslist; do
case $fs in
/) ;;
/*)
fsopts="$(fstabinfo -o $fs)"
case "$fsopts" in
*noauto*) ;;
*)
local name="${fs#/}"
name="$(echo $name | sed 's#/#.#g')"
einfo ln -snf mount "${svcpath}/${name}"
rc=$?
[ $rc -ne 0 ] && break
*) ;;
esac
*) ;;
esac
done
eend $rc "Failed to generate symlinks for all mounts"
return $rc
}

View File

@@ -14,7 +14,7 @@ name="Console Mouse Daemon"
depend()
{
need localmount
need mount.usr mount.var
after bootmisc
keyword -jail -prefix
}

View File

@@ -10,7 +10,7 @@ __nl="
depend()
{
need localmount
need mount.usr mount.var
after bootmisc
if [ -n "$(interfaces)" ]; then
provide net

View File

@@ -6,7 +6,7 @@ required_files="/etc/newsyslog.conf"
depend()
{
need localmount
need mount.usr mount.var
keyword -prefix
}

View File

@@ -10,7 +10,7 @@ name="Name Service Cache Daemon"
extra_started_commands="flush"
depend() {
need localmount
need mount.usr mount.var
use net dns ldap ypbind
after bootmisc
}

View File

@@ -8,7 +8,7 @@ ttyn=${rc_tty_number:-${RC_TTY_NUMBER:-12}}
depend()
{
need localmount
need mount.usr mount.var
keyword -openvz -prefix -systemd-nspawn -vserver -lxc
}

View File

@@ -10,7 +10,7 @@ extra_commands="checkconfig showstatus"
extra_started_commands="reload"
depend() {
need localmount
need mount.usr mount.var
keyword -jail -prefix
}

View File

@@ -9,7 +9,7 @@ name="Power Control Daemon"
depend()
{
need localmount
need mount.usr mount.var
use logger
after bootmisc
keyword -jail -prefix

View File

@@ -7,7 +7,7 @@ description="Mounts misc filesystems in /proc."
depend()
{
use modules devfs
need localmount
need mount.usr mount.var
keyword -openvz -prefix -systemd-nspawn -vserver -lxc
}

View File

@@ -17,7 +17,7 @@ command_background=YES
depend()
{
need localmount
need mount.usr mount.var
after bootmisc
need net
}

View File

@@ -4,7 +4,7 @@
depend()
{
need localmount net
need mount.usr mount.var net
after *
before local
keyword -prefix

View File

@@ -9,7 +9,7 @@ name="RPC program number mapper"
depend()
{
provide rpc
need localmount
need mount.usr mount.var
use net logger dns
before inetd xinetd ntpd ntp-client
}

View File

@@ -9,7 +9,7 @@ pidfile=/var/run/s6-svscan.pid
depend()
{
need localmount
need mount.usr mount.var
}
start_pre()

View File

@@ -6,7 +6,7 @@ description="Saves a kernel dump."
depend()
{
need dumpon localmount
need dumpon mount.usr mount.var
before encswap
keyword -jail -prefix
}

View File

@@ -4,7 +4,7 @@
depend()
{
before localmount
before mount.usr mount.var
keyword -jail -openvz -prefix -systemd-nspawn -vserver -lxc
}

View File

@@ -4,7 +4,7 @@
depend()
{
need localmount
need mount.usr mount.var
keyword -jail -openvz -prefix -systemd-nspawn -vserver -lxc
}

View File

@@ -3,7 +3,7 @@
# Released under the 2-clause BSD license.
depend() {
need localmount
need mount.usr mount.var
keyword -jail -prefix
}

View File

@@ -14,7 +14,7 @@ depend()
{
provide logger
use net newsyslog
need localmount
need mount.usr mount.var
after bootmisc
keyword -prefix
}

View File

@@ -6,7 +6,7 @@ description="Set up tmpfiles.d entries"
depend()
{
need localmount
need mount.usr mount.var
}
start()

View File

@@ -7,7 +7,7 @@ description="Initializes the random number generator."
depend()
{
need localmount
need mount.usr mount.var
keyword -jail -lxc -openvz -prefix -systemd-nspawn
}

View File

@@ -4,7 +4,7 @@
depend()
{
need localmount
need mount.usr mount.var
keyword -prefix
}

View File

@@ -487,8 +487,8 @@ _need_dbus()
depend()
{
# We write a pidfile and to /var/cache, so we need localmount.
need localmount
# We write a pidfile and to /var/cache, so we need mount.var.
need mount.var
# We can optionally use the network, but it's not essential.
use net
# We should be after bootmisc so that /var/run is cleaned before

46
mount-service.md Normal file
View File

@@ -0,0 +1,46 @@
# New Mount Service
This is definitely considered testing code, so if you use it on your
system and it breaks, you have been warned.
This document will evolve as the testing proceeds and will be removed
once the script goes mainline.
Since this is on a topic branch, this branch will be subject to
rebasing, merging commits, etc. When it goes to master, everything here
will be in one commit.
The goal of this is to replace the localmount and metmount services with
a single mount service which will be multiplexed so that there is one
service for each file system that will be mounted.
- rc-service mount generate
scans your fstab and attempts to generate symbolic links in /etc/init.d
for each file system you want to mount.
Then you must edit /etc/conf.d/mount to list all of your file systems
and the dependencies they have by using
rc_mount_foo_before/after/need/use settings.
rc-service mount.foo start
tries to mount a file system and
rc-service mount.foo stop
tries to unmount it if your system is going down.
I'm considering automating the generation of symlinks into the boot
process, but I'm not sure yet whether this is a good idea.
I haven't decided yet exactly how I want to handle the transition from
localmount/netmount to this new mount service yet, so you will
definitely not have a clean boot if you try to boot with this.
Another question is whether I want to try automating adding the mount
services to runlevels; I think no, but let me know if you feel
differently.
Any suggestions would be helpful.

View File

@@ -939,9 +939,9 @@ svc_stop_real(void)
{
bool stopped;
/* If we're stopping localmount, set LC_ALL=C so that
/* If we're stopping mount.*, set LC_ALL=C so that
* bash doesn't load anything blocking the unmounting of /usr */
if (strcmp(applet, "localmount") == 0)
if (strncmp(applet, "mount.", 6) == 0)
setenv("LC_ALL", "C", 1);
if (ibsave)