mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-26 03:09:34 +03:00
Additional SYSV init script fixes (3).
* In read_mtab(), fix problems (!?) in the mounts file. It will record 'rpool 1' as 'rpool\0401' instead of 'rpool\00401' which seems to be the correct (at least as far as 'printf' is concerned). Use this using the external 'echo' command (and not the one built in to the shell) because the internal one would interpret the backslash code (incorrectly), giving us a instead. * Remove reregister_mounts() - no longer needed. * For Gentoo, the zfs_log_failure_msg() should use eend(), not eerror() (which requires an error message, which we don't have). Signed-off-by: Turbo Fredriksson <turbo@bayour.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #3488 Closes #3509 Closes #3514
This commit is contained in:
parent
216f9d04a6
commit
16421a1dc8
@ -68,7 +68,7 @@ elif type einfo > /dev/null 2>&1 ; then
|
|||||||
# Gentoo functions
|
# Gentoo functions
|
||||||
zfs_log_begin_msg() { ebegin "$1"; }
|
zfs_log_begin_msg() { ebegin "$1"; }
|
||||||
zfs_log_end_msg() { eend "$1"; }
|
zfs_log_end_msg() { eend "$1"; }
|
||||||
zfs_log_failure_msg() { eerror "$1"; }
|
zfs_log_failure_msg() { eend "$1"; }
|
||||||
# zfs_log_progress_msg() { echo -n "$1"; }
|
# zfs_log_progress_msg() { echo -n "$1"; }
|
||||||
zfs_log_progress_msg() { echo -n; }
|
zfs_log_progress_msg() { echo -n; }
|
||||||
else
|
else
|
||||||
@ -304,42 +304,6 @@ checksystem()
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
reregister_mounts()
|
|
||||||
{
|
|
||||||
local fs mntpnt fstype opts rest tmpdir
|
|
||||||
tmpdir=removethismountpointhoweverpossible
|
|
||||||
|
|
||||||
while read -r fs mntpnt fstype opts rest ; do
|
|
||||||
fs=$(printf '%b\n' "$fs")
|
|
||||||
mntpnt=$(printf '%b\n' "$mntpnt")
|
|
||||||
if [ "$fstype" = "zfs" ] ; then
|
|
||||||
if [ "$mntpnt" = "/" ] ; then
|
|
||||||
mount -f -o zfsutil -t zfs --move / /$tmpdir
|
|
||||||
umount --fake /$tmpdir
|
|
||||||
else
|
|
||||||
umount --fake "$mntpnt"
|
|
||||||
fi
|
|
||||||
elif echo "$fs" | grep -qE "^/dev/(zd|zvol)" ; then
|
|
||||||
if [ "$mntpnt" = "/" ] ; then
|
|
||||||
mount -f -t "$fstype" --move / /$tmpdir
|
|
||||||
umount --fake /$tmpdir
|
|
||||||
else
|
|
||||||
umount --fake "$mntpnt"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done < /proc/mounts
|
|
||||||
|
|
||||||
while read -r fs mntpnt fstype opts rest ; do
|
|
||||||
fs=$(printf '%b\n' "$fs")
|
|
||||||
mntpnt=$(printf '%b\n' "$mntpnt")
|
|
||||||
if [ "$fstype" = "zfs" ] ; then
|
|
||||||
mount -f -t zfs -o zfsutil "$fs" "$mntpnt"
|
|
||||||
elif echo "$fs" | grep -q "^/dev/zd" ; then
|
|
||||||
mount -f -t "$fstype" -o "$opts" "$fs" "$mntpnt"
|
|
||||||
fi
|
|
||||||
done < /proc/mounts
|
|
||||||
}
|
|
||||||
|
|
||||||
get_root_pool()
|
get_root_pool()
|
||||||
{
|
{
|
||||||
set -- $(mount | grep ' on / ')
|
set -- $(mount | grep ' on / ')
|
||||||
@ -373,9 +337,23 @@ read_mtab()
|
|||||||
|
|
||||||
while read -r fs mntpnt fstype opts rest; do
|
while read -r fs mntpnt fstype opts rest; do
|
||||||
if echo "$fs $mntpnt $fstype $opts" | grep -qE "$match"; then
|
if echo "$fs $mntpnt $fstype $opts" | grep -qE "$match"; then
|
||||||
|
# * Fix problems (!?) in the mounts file. It will record
|
||||||
|
# 'rpool 1' as 'rpool\0401' instead of 'rpool\00401'
|
||||||
|
# which seems to be the correct (at least as far as
|
||||||
|
# 'printf' is concerned).
|
||||||
|
# * We need to use the external echo, because the
|
||||||
|
# internal one would interpret the backslash code
|
||||||
|
# (incorrectly), giving us a instead.
|
||||||
|
mntpnt=$(/bin/echo "$mntpnt" | sed "s,\\\0,\\\00,")
|
||||||
|
fs=$(/bin/echo "$fs" | sed "s,\\\0,\\\00,")
|
||||||
|
|
||||||
|
# Replace 'unwanted' characters with underscore.
|
||||||
mntpnt=$(printf '%b\n' "$mntpnt" | sed -e 's,/,_,g' \
|
mntpnt=$(printf '%b\n' "$mntpnt" | sed -e 's,/,_,g' \
|
||||||
-e 's,-,_,g' -e 's,\.,_,g')
|
-e 's,-,_,g' -e 's,\.,_,g' -e 's, ,_,g')
|
||||||
eval export MTAB_$mntpnt="$fs"
|
fs=$(printf '%b\n' "$fs")
|
||||||
|
|
||||||
|
# Set the variable.
|
||||||
|
eval export MTAB_$mntpnt=\"$fs\"
|
||||||
fi
|
fi
|
||||||
done < /proc/mounts
|
done < /proc/mounts
|
||||||
}
|
}
|
||||||
|
@ -165,15 +165,11 @@ do_start()
|
|||||||
{
|
{
|
||||||
check_module_loaded || exit 0
|
check_module_loaded || exit 0
|
||||||
|
|
||||||
# fix mtab to include already-mounted fs filesystems, in case there are any
|
case "$ZFS_MOUNT" in
|
||||||
# we ONLY do this if mtab does not point to /proc/mounts
|
[Oo][Ff][Ff]|[Nn][Oo]|''|0)
|
||||||
# which is the case in some systems (systemd may bring that soon)
|
exit 3
|
||||||
if ! readlink /etc/mtab | grep -q /proc ; then
|
;;
|
||||||
if grep -qE "(^/dev/zd|^/dev/zvol| zfs )" /proc/mounts ; then
|
esac
|
||||||
zfs_action "Registering already-mounted ZFS filesystems and volumes" \
|
|
||||||
reregister_mounts
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Ensure / exists in /etc/mtab, if not update mtab accordingly.
|
# Ensure / exists in /etc/mtab, if not update mtab accordingly.
|
||||||
# This should be handled by rc.sysinit but lets be paranoid.
|
# This should be handled by rc.sysinit but lets be paranoid.
|
||||||
@ -182,12 +178,6 @@ do_start()
|
|||||||
mount -f /
|
mount -f /
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$ZFS_MOUNT" in
|
|
||||||
[Oo][Ff][Ff]|[Nn][Oo]|''|0)
|
|
||||||
exit 3
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
do_mount
|
do_mount
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user