Skip to content

Commit

Permalink
Additional SYSV init script fixes (3).
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #3488
Closes #3509
Closes #3514
  • Loading branch information
FransUrbo authored and behlendorf committed Jun 25, 2015
1 parent 216f9d0 commit 16421a1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 54 deletions.
56 changes: 17 additions & 39 deletions etc/init.d/zfs-functions.in
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ elif type einfo > /dev/null 2>&1 ; then
# Gentoo functions
zfs_log_begin_msg() { ebegin "$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; }
else
Expand Down Expand Up @@ -304,42 +304,6 @@ checksystem()
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()
{
set -- $(mount | grep ' on / ')
Expand Down Expand Up @@ -373,9 +337,23 @@ read_mtab()

while read -r fs mntpnt fstype opts rest; do
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' \
-e 's,-,_,g' -e 's,\.,_,g')
eval export MTAB_$mntpnt="$fs"
-e 's,-,_,g' -e 's,\.,_,g' -e 's, ,_,g')
fs=$(printf '%b\n' "$fs")

# Set the variable.
eval export MTAB_$mntpnt=\"$fs\"
fi
done < /proc/mounts
}
Expand Down
20 changes: 5 additions & 15 deletions etc/init.d/zfs-mount.in
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,11 @@ do_start()
{
check_module_loaded || exit 0

# fix mtab to include already-mounted fs filesystems, in case there are any
# we ONLY do this if mtab does not point to /proc/mounts
# which is the case in some systems (systemd may bring that soon)
if ! readlink /etc/mtab | grep -q /proc ; then
if grep -qE "(^/dev/zd|^/dev/zvol| zfs )" /proc/mounts ; then
zfs_action "Registering already-mounted ZFS filesystems and volumes" \
reregister_mounts
fi
fi
case "$ZFS_MOUNT" in
[Oo][Ff][Ff]|[Nn][Oo]|''|0)
exit 3
;;
esac

# Ensure / exists in /etc/mtab, if not update mtab accordingly.
# This should be handled by rc.sysinit but lets be paranoid.
Expand All @@ -182,12 +178,6 @@ do_start()
mount -f /
fi

case "$ZFS_MOUNT" in
[Oo][Ff][Ff]|[Nn][Oo]|''|0)
exit 3
;;
esac

do_mount
}

Expand Down

0 comments on commit 16421a1

Please sign in to comment.