If it's in fstab, let mount work everything out instead of us.
This commit is contained in:
parent
675d0a94c7
commit
46af0c7ddb
@ -7,7 +7,7 @@
|
|||||||
# Drop to a shell, remount / ro, and then reboot
|
# Drop to a shell, remount / ro, and then reboot
|
||||||
#
|
#
|
||||||
single_user() {
|
single_user() {
|
||||||
if [ "${RC_SYS}" = "VPS" ] ; then
|
if [ "${RC_SYS}" = "VPS" ]; then
|
||||||
einfo "Halting"
|
einfo "Halting"
|
||||||
halt -f
|
halt -f
|
||||||
return
|
return
|
||||||
@ -15,7 +15,7 @@ single_user() {
|
|||||||
|
|
||||||
sulogin ${CONSOLE}
|
sulogin ${CONSOLE}
|
||||||
einfo "Unmounting filesystems"
|
einfo "Unmounting filesystems"
|
||||||
if [ -c /dev/null ] ; then
|
if [ -c /dev/null ]; then
|
||||||
mount -a -o remount,ro 2>/dev/null
|
mount -a -o remount,ro 2>/dev/null
|
||||||
else
|
else
|
||||||
mount -a -o remount,ro
|
mount -a -o remount,ro
|
||||||
@ -31,20 +31,19 @@ single_user() {
|
|||||||
mount_svcdir() {
|
mount_svcdir() {
|
||||||
local fs= fsopts="-o rw,noexec,nodev,nosuid" devdir="none" devtmp="none" x=
|
local fs= fsopts="-o rw,noexec,nodev,nosuid" devdir="none" devtmp="none" x=
|
||||||
local svcsize=${svcsize:-1024}
|
local svcsize=${svcsize:-1024}
|
||||||
local mntcmd=$(fstabinfo --mountcmd "${RC_SVCDIR}")
|
|
||||||
|
|
||||||
if grep -Eq "[[:space:]]+tmpfs$" /proc/filesystems ; then
|
if grep -Eq "[[:space:]]+tmpfs$" /proc/filesystems; then
|
||||||
fs="tmpfs"
|
fs="tmpfs"
|
||||||
fsopts="${fsopts},mode=0755,size=${svcsize}k"
|
fsopts="${fsopts},mode=0755,size=${svcsize}k"
|
||||||
elif grep -Eq "[[:space:]]+ramfs$" /proc/filesystems ; then
|
elif grep -Eq "[[:space:]]+ramfs$" /proc/filesystems; then
|
||||||
fs="ramfs"
|
fs="ramfs"
|
||||||
# ramfs has no special options
|
# ramfs has no special options
|
||||||
elif [ -e /dev/ram0 -a -e /dev/ram1 ] \
|
elif [ -e /dev/ram0 -a -e /dev/ram1 ] \
|
||||||
&& grep -Eq "[[:space:]]+ext2$" /proc/filesystems ; then
|
&& grep -Eq "[[:space:]]+ext2$" /proc/filesystems; then
|
||||||
devdir="/dev/ram0"
|
devdir="/dev/ram0"
|
||||||
devtmp="/dev/ram1"
|
devtmp="/dev/ram1"
|
||||||
fs="ext2"
|
fs="ext2"
|
||||||
for x in ${devdir} ${devtmp} ; do
|
for x in ${devdir} ${devtmp}; do
|
||||||
try dd if=/dev/zero of="${x}" bs=1k count="${svcsize}"
|
try dd if=/dev/zero of="${x}" bs=1k count="${svcsize}"
|
||||||
try mkfs -t "${fs}" -i 1024 -vm0 "${x}" "${svcsize}"
|
try mkfs -t "${fs}" -i 1024 -vm0 "${x}" "${svcsize}"
|
||||||
done
|
done
|
||||||
@ -56,20 +55,22 @@ mount_svcdir() {
|
|||||||
single_user
|
single_user
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If we have no entry in fstab for $svcdir, provide our own
|
|
||||||
if [ -z "${mntcmd}" ] ; then
|
|
||||||
mntcmd="-t ${fs} ${fsopts} ${devdir} ${RC_SVCDIR}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
local dotmp=false
|
local dotmp=false
|
||||||
if [ -e "${RC_SVCDIR}"/deptree ] ; then
|
if [ -e "${RC_SVCDIR}"/deptree ]; then
|
||||||
dotmp=true
|
dotmp=true
|
||||||
try mount -n -t "${fs}" -o rw "${devtmp}" "${RC_LIBDIR}"/tmp
|
try mount -n -t "${fs}" -o rw "${devtmp}" "${RC_LIBDIR}"/tmp
|
||||||
cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/depconfig \
|
cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/depconfig \
|
||||||
"${RC_SVCDIR}"/nettree "${RC_LIBDIR}"/tmp 2>/dev/null
|
"${RC_SVCDIR}"/nettree "${RC_LIBDIR}"/tmp 2>/dev/null
|
||||||
fi
|
fi
|
||||||
eval try mount -n ${mntcmd}
|
|
||||||
if ${dotmp} ; then
|
# If we have no entry in fstab for $svcdir, provide our own
|
||||||
|
if fstabinfo --quiet "${RC_SVCDIR}"; then
|
||||||
|
try mount -n "${RC_SVCDIR}"
|
||||||
|
else
|
||||||
|
try mount -n -t "${fs}" ${fsopts} "${devdir}" "${RC_SVCDIR}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ${dotmp}; then
|
||||||
cp -p "${RC_LIBDIR}"/tmp/deptree "${RC_LIBDIR}"/tmp/depconfig \
|
cp -p "${RC_LIBDIR}"/tmp/deptree "${RC_LIBDIR}"/tmp/depconfig \
|
||||||
"${RC_LIBDIR}"/tmp/nettree "${RC_SVCDIR}" 2>/dev/null
|
"${RC_LIBDIR}"/tmp/nettree "${RC_SVCDIR}" 2>/dev/null
|
||||||
try umount -n "${RC_LIBDIR}"/tmp
|
try umount -n "${RC_LIBDIR}"/tmp
|
||||||
@ -93,7 +94,7 @@ get_KV() {
|
|||||||
# Set the console loglevel to 1 for a cleaner boot
|
# Set the console loglevel to 1 for a cleaner boot
|
||||||
# the logger should anyhow dump the ring-0 buffer at start to the
|
# the logger should anyhow dump the ring-0 buffer at start to the
|
||||||
# logs, and that with dmesg can be used to check for problems
|
# logs, and that with dmesg can be used to check for problems
|
||||||
if [ -n "${RC_DMESG_LEVEL}" -a "${RC_SYS}" != "VPS" ] ; then
|
if [ -n "${RC_DMESG_LEVEL}" -a "${RC_SYS}" != "VPS" ]; then
|
||||||
dmesg -n "${RC_DMESG_LEVEL}"
|
dmesg -n "${RC_DMESG_LEVEL}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -105,10 +106,10 @@ check_statedir /proc
|
|||||||
# /proc actually works or not. We to this by comparing uptime to one a second
|
# /proc actually works or not. We to this by comparing uptime to one a second
|
||||||
# ago
|
# ago
|
||||||
mountproc=true
|
mountproc=true
|
||||||
if [ -e /proc/uptime ] ; then
|
if [ -e /proc/uptime ]; then
|
||||||
up="$(cat /proc/uptime)"
|
up="$(cat /proc/uptime)"
|
||||||
sleep 1
|
sleep 1
|
||||||
if [ "${up}" = "$(cat /proc/uptime)" ] ; then
|
if [ "${up}" = "$(cat /proc/uptime)" ]; then
|
||||||
eerror "You have cruft in /proc that should be deleted"
|
eerror "You have cruft in /proc that should be deleted"
|
||||||
else
|
else
|
||||||
einfo "/proc is already mounted, skipping"
|
einfo "/proc is already mounted, skipping"
|
||||||
@ -121,8 +122,11 @@ if ${mountproc} ; then
|
|||||||
procfs="proc"
|
procfs="proc"
|
||||||
[ "${RC_UNAME}" = "GNU/kFreeBSD" ] && proc="linprocfs"
|
[ "${RC_UNAME}" = "GNU/kFreeBSD" ] && proc="linprocfs"
|
||||||
ebegin "Mounting ${procfs} at /proc"
|
ebegin "Mounting ${procfs} at /proc"
|
||||||
mntcmd="$(fstabinfo --mountcmd /proc)"
|
if fstabinfo --quiet /proc; then
|
||||||
eval try mount -n ${mntcmd:--t ${procfs} -o noexec,nosuid,nodev proc /proc}
|
try mount -n /proc
|
||||||
|
else
|
||||||
|
try mount -n -t "${procfs}" -o noexec,nosuid,nodev proc /proc
|
||||||
|
fi
|
||||||
eend $?
|
eend $?
|
||||||
fi
|
fi
|
||||||
unset mountproc
|
unset mountproc
|
||||||
@ -130,7 +134,7 @@ unset mountproc
|
|||||||
# Read off the kernel commandline to see if there's any special settings
|
# Read off the kernel commandline to see if there's any special settings
|
||||||
# especially check to see if we need to set the CDBOOT environment variable
|
# especially check to see if we need to set the CDBOOT environment variable
|
||||||
# Note: /proc MUST be mounted
|
# Note: /proc MUST be mounted
|
||||||
if [ -r /sbin/livecd-functions.sh ] ; then
|
if [ -r /sbin/livecd-functions.sh ]; then
|
||||||
. /sbin/livecd-functions.sh
|
. /sbin/livecd-functions.sh
|
||||||
livecd_read_commandline
|
livecd_read_commandline
|
||||||
fi
|
fi
|
||||||
@ -138,12 +142,15 @@ fi
|
|||||||
[ "$(KV_to_int "$(uname -r)")" -ge "$(KV_to_int "2.6.0")" ]
|
[ "$(KV_to_int "$(uname -r)")" -ge "$(KV_to_int "2.6.0")" ]
|
||||||
K26=$?
|
K26=$?
|
||||||
|
|
||||||
if [ "${RC_UNAME}" != "GNU/kFreeBSD" -a "${RC_SYS}" != "VPS" -a "${K26}" = "0" ] ; then
|
if [ "${RC_UNAME}" != "GNU/kFreeBSD" -a "${RC_SYS}" != "VPS" -a "${K26}" = "0" ]; then
|
||||||
if [ -d /sys ] ; then
|
if [ -d /sys ]; then
|
||||||
if ! mountinfo --quiet /sys ; then
|
if ! mountinfo --quiet /sys; then
|
||||||
ebegin "Mounting sysfs at /sys"
|
ebegin "Mounting sysfs at /sys"
|
||||||
mntcmd="$(fstabinfo --mountcmd /sys)"
|
if fstabinfo --quiet /sys; then
|
||||||
eval try mount -n ${mntcmd:--t sysfs -o noexec,nosuid,nodev sysfs /sys}
|
try mount -n /sys
|
||||||
|
else
|
||||||
|
try mount -n -t sysfs -o noexec,nosuid,nodev sysfs /sys
|
||||||
|
fi
|
||||||
eend $?
|
eend $?
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@ -153,7 +160,7 @@ fi
|
|||||||
|
|
||||||
check_statedir /dev
|
check_statedir /dev
|
||||||
devfs_mounted=
|
devfs_mounted=
|
||||||
if [ -e /dev/.devfsd ] ; then
|
if [ -e /dev/.devfsd ]; then
|
||||||
# make sure devfs is actually mounted and it isnt a bogus file
|
# make sure devfs is actually mounted and it isnt a bogus file
|
||||||
devfs_mounted=$(mountinfo --fstype-regex devfs)
|
devfs_mounted=$(mountinfo --fstype-regex devfs)
|
||||||
fi
|
fi
|
||||||
@ -163,10 +170,10 @@ fi
|
|||||||
# - check boot parameters
|
# - check boot parameters
|
||||||
# - make sure the required binaries exist
|
# - make sure the required binaries exist
|
||||||
# - make sure the kernel has support
|
# - make sure the kernel has support
|
||||||
if [ "${RC_DEVICES}" = "static" -o "${RC_SYS}" = "VPS" ] ; then
|
if [ "${RC_DEVICES}" = "static" -o "${RC_SYS}" = "VPS" ]; then
|
||||||
ebegin "Using existing device nodes in /dev"
|
ebegin "Using existing device nodes in /dev"
|
||||||
eend 0
|
eend 0
|
||||||
elif [ "${RC_UNAME}" = "GNU/kFreeBSD" ] ; then
|
elif [ "${RC_UNAME}" = "GNU/kFreeBSD" ]; then
|
||||||
ebegin "Using kFreeBSD devfs in /dev"
|
ebegin "Using kFreeBSD devfs in /dev"
|
||||||
eend 0
|
eend 0
|
||||||
else
|
else
|
||||||
@ -177,15 +184,15 @@ else
|
|||||||
auto|*) managers="udev devfs mdev";;
|
auto|*) managers="udev devfs mdev";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
for m in ${managers} ; do
|
for m in ${managers}; do
|
||||||
# Check common manager prerequisites and kernel params
|
# Check common manager prerequisites and kernel params
|
||||||
if get_bootparam "no${m}" || ! has_addon ${m}-start ; then
|
if get_bootparam "no${m}" || ! has_addon ${m}-start; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
# Check specific manager prerequisites
|
# Check specific manager prerequisites
|
||||||
case ${m} in
|
case ${m} in
|
||||||
udev|mdev)
|
udev|mdev)
|
||||||
if [ -n "${devfs_mounted}" -o "${K26}" != 0 ] ; then
|
if [ -n "${devfs_mounted}" -o "${K26}" != 0 ]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@ -201,24 +208,27 @@ fi
|
|||||||
|
|
||||||
# Mount the new fancy pants /dev/pts whenever possible
|
# Mount the new fancy pants /dev/pts whenever possible
|
||||||
if grep -Eq "[[:space:]]+devpts$" /proc/filesystems && \
|
if grep -Eq "[[:space:]]+devpts$" /proc/filesystems && \
|
||||||
! mountinfo -q /dev/pts ; then
|
! mountinfo -q /dev/pts; then
|
||||||
if [ ! -d /dev/pts ] && \
|
if [ ! -d /dev/pts ] && \
|
||||||
[ "${devfs}" = "yes" -o "${udev}" = "yes" ] ; then
|
[ "${devfs}" = "yes" -o "${udev}" = "yes" ]; then
|
||||||
# Make sure we have /dev/pts
|
# Make sure we have /dev/pts
|
||||||
mkdir -p /dev/pts >/dev/null 2>/dev/null || \
|
mkdir -p /dev/pts >/dev/null 2>/dev/null || \
|
||||||
ewarn "Could not create /dev/pts!"
|
ewarn "Could not create /dev/pts!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d /dev/pts ] ; then
|
if [ -d /dev/pts ]; then
|
||||||
ebegin "Mounting devpts at /dev/pts"
|
ebegin "Mounting devpts at /dev/pts"
|
||||||
mntcmd="$(fstabinfo --mountcmd /dev/pts)"
|
if fstabinfo --quiet /dev/pts; then
|
||||||
eval try mount -n ${mntcmd:--t devpts -o gid=5,mode=0620,noexec,nosuid devpts /dev/pts}
|
try mount -n /dev/pts
|
||||||
|
else
|
||||||
|
try mount -n -t devpts -o gid=5,mode=0620,noexec,nosuid devpts /dev/pts
|
||||||
|
fi
|
||||||
eend $?
|
eend $?
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If booting off CD, we want to update inittab before setting the runlevel
|
# If booting off CD, we want to update inittab before setting the runlevel
|
||||||
if [ -f /sbin/livecd-functions.sh -a -n "${CDBOOT}" ] ; then
|
if [ -f /sbin/livecd-functions.sh -a -n "${CDBOOT}" ]; then
|
||||||
ebegin "Updating inittab"
|
ebegin "Updating inittab"
|
||||||
livecd_fix_inittab
|
livecd_fix_inittab
|
||||||
eend $?
|
eend $?
|
||||||
|
@ -67,7 +67,6 @@ static struct mntent *getmntfile (const char *file)
|
|||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
#define getoptstring "mop:t:" getoptstring_COMMON
|
#define getoptstring "mop:t:" getoptstring_COMMON
|
||||||
static struct option longopts[] = {
|
static struct option longopts[] = {
|
||||||
{ "mountcmd", 0, NULL, 'm'},
|
|
||||||
{ "options", 0, NULL, 'o'},
|
{ "options", 0, NULL, 'o'},
|
||||||
{ "passno", 1, NULL, 'p'},
|
{ "passno", 1, NULL, 'p'},
|
||||||
{ "fstype", 1, NULL, 't'},
|
{ "fstype", 1, NULL, 't'},
|
||||||
@ -84,7 +83,6 @@ static const char * const longopts_help[] = {
|
|||||||
#include "_usage.c"
|
#include "_usage.c"
|
||||||
|
|
||||||
#define OUTPUT_FILE (1 << 1)
|
#define OUTPUT_FILE (1 << 1)
|
||||||
#define OUTPUT_MOUNTCMD (1 << 2)
|
|
||||||
#define OUTPUT_OPTIONS (1 << 3)
|
#define OUTPUT_OPTIONS (1 << 3)
|
||||||
#define OUTPUT_PASSNO (1 << 4)
|
#define OUTPUT_PASSNO (1 << 4)
|
||||||
|
|
||||||
@ -109,10 +107,6 @@ int fstabinfo (int argc, char **argv)
|
|||||||
longopts, (int *) 0)) != -1)
|
longopts, (int *) 0)) != -1)
|
||||||
{
|
{
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'm':
|
|
||||||
output = OUTPUT_MOUNTCMD;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
output = OUTPUT_OPTIONS;
|
output = OUTPUT_OPTIONS;
|
||||||
break;
|
break;
|
||||||
@ -185,11 +179,6 @@ int fstabinfo (int argc, char **argv)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
switch (output) {
|
switch (output) {
|
||||||
case OUTPUT_MOUNTCMD:
|
|
||||||
printf ("-o %s -t %s '%s' '%s'\n", ENT_OPTS (ent),
|
|
||||||
ENT_TYPE (ent), ENT_DEVICE (ent), ENT_FILE (ent));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case OUTPUT_OPTIONS:
|
case OUTPUT_OPTIONS:
|
||||||
printf ("%s\n", ENT_OPTS (ent));
|
printf ("%s\n", ENT_OPTS (ent));
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user