If it's in fstab, let mount work everything out instead of us.

This commit is contained in:
Roy Marples 2007-09-26 10:09:27 +00:00
parent 675d0a94c7
commit 46af0c7ddb
2 changed files with 48 additions and 49 deletions

View File

@ -31,7 +31,6 @@ single_user() {
mount_svcdir() {
local fs= fsopts="-o rw,noexec,nodev,nosuid" devdir="none" devtmp="none" x=
local svcsize=${svcsize:-1024}
local mntcmd=$(fstabinfo --mountcmd "${RC_SVCDIR}")
if grep -Eq "[[:space:]]+tmpfs$" /proc/filesystems; then
fs="tmpfs"
@ -56,11 +55,6 @@ mount_svcdir() {
single_user
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
if [ -e "${RC_SVCDIR}"/deptree ]; then
dotmp=true
@ -68,7 +62,14 @@ mount_svcdir() {
cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/depconfig \
"${RC_SVCDIR}"/nettree "${RC_LIBDIR}"/tmp 2>/dev/null
fi
eval try mount -n ${mntcmd}
# 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 \
"${RC_LIBDIR}"/tmp/nettree "${RC_SVCDIR}" 2>/dev/null
@ -121,8 +122,11 @@ if ${mountproc} ; then
procfs="proc"
[ "${RC_UNAME}" = "GNU/kFreeBSD" ] && proc="linprocfs"
ebegin "Mounting ${procfs} at /proc"
mntcmd="$(fstabinfo --mountcmd /proc)"
eval try mount -n ${mntcmd:--t ${procfs} -o noexec,nosuid,nodev proc /proc}
if fstabinfo --quiet /proc; then
try mount -n /proc
else
try mount -n -t "${procfs}" -o noexec,nosuid,nodev proc /proc
fi
eend $?
fi
unset mountproc
@ -142,8 +146,11 @@ if [ "${RC_UNAME}" != "GNU/kFreeBSD" -a "${RC_SYS}" != "VPS" -a "${K26}" = "0" ]
if [ -d /sys ]; then
if ! mountinfo --quiet /sys; then
ebegin "Mounting sysfs at /sys"
mntcmd="$(fstabinfo --mountcmd /sys)"
eval try mount -n ${mntcmd:--t sysfs -o noexec,nosuid,nodev sysfs /sys}
if fstabinfo --quiet /sys; then
try mount -n /sys
else
try mount -n -t sysfs -o noexec,nosuid,nodev sysfs /sys
fi
eend $?
fi
else
@ -211,8 +218,11 @@ if grep -Eq "[[:space:]]+devpts$" /proc/filesystems && \
if [ -d /dev/pts ]; then
ebegin "Mounting devpts at /dev/pts"
mntcmd="$(fstabinfo --mountcmd /dev/pts)"
eval try mount -n ${mntcmd:--t devpts -o gid=5,mode=0620,noexec,nosuid devpts /dev/pts}
if fstabinfo --quiet /dev/pts; then
try mount -n /dev/pts
else
try mount -n -t devpts -o gid=5,mode=0620,noexec,nosuid devpts /dev/pts
fi
eend $?
fi
fi

View File

@ -67,7 +67,6 @@ static struct mntent *getmntfile (const char *file)
#include "_usage.h"
#define getoptstring "mop:t:" getoptstring_COMMON
static struct option longopts[] = {
{ "mountcmd", 0, NULL, 'm'},
{ "options", 0, NULL, 'o'},
{ "passno", 1, NULL, 'p'},
{ "fstype", 1, NULL, 't'},
@ -84,7 +83,6 @@ static const char * const longopts_help[] = {
#include "_usage.c"
#define OUTPUT_FILE (1 << 1)
#define OUTPUT_MOUNTCMD (1 << 2)
#define OUTPUT_OPTIONS (1 << 3)
#define OUTPUT_PASSNO (1 << 4)
@ -109,10 +107,6 @@ int fstabinfo (int argc, char **argv)
longopts, (int *) 0)) != -1)
{
switch (opt) {
case 'm':
output = OUTPUT_MOUNTCMD;
break;
case 'o':
output = OUTPUT_OPTIONS;
break;
@ -185,11 +179,6 @@ int fstabinfo (int argc, char **argv)
continue;
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:
printf ("%s\n", ENT_OPTS (ent));
break;