Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 692196 | Differences between
and this patch

Collapse All | Expand All

(-)a/defaults/initrd.scripts (-25 / +53 lines)
Lines 1755-1785 get_mounts_list() Link Here
1755
		' ${NEW_ROOT}/etc/initramfs.mounts
1755
		' ${NEW_ROOT}/etc/initramfs.mounts
1756
}
1756
}
1757
1757
1758
get_mount_fstype()
1758
get_col_by_mount() {
1759
{
1759
        # Get a column for a mountpoint from fstab-like input
1760
	[ -e "${NEW_ROOT}"/etc/fstab ] || return 1
1760
        awk -v fs="$1" -v i="$2" '
1761
	awk -v fs="$1" '
1761
                /^[[:blank:]]*#/ { next }
1762
		/^[[:blank:]]*#/ { next }
1762
                $2 == fs { print $i }'
1763
		$2 == fs { print $3 }
1763
}
1764
		' ${NEW_ROOT}/etc/fstab
1764
1765
}
1765
is_zfs() {
1766
1766
        # Check if mountpoint belongs to zfs
1767
get_mount_options()
1767
        local TYPE
1768
{
1768
        TYPE="$(
1769
	[ -e "${NEW_ROOT}"/etc/fstab ] || return 1
1769
                zfs list -H -o type,mountpoint \
1770
	awk -v fs="$1" '
1770
                | get_col_by_mount "$1" "1"
1771
		/^[[:blank:]]*#/ { next }
1771
        )"
1772
		$2 == fs { print $4 }
1772
        [ -n "${TYPE}" ] && return 0 || return 1
1773
		' ${NEW_ROOT}/etc/fstab
1773
}
1774
}
1774
1775
1775
get_mount_fstype() {
1776
get_mount_device()
1776
        local FSTYPE
1777
{
1777
        # Look for the type in fstab
1778
	[ -e "${NEW_ROOT}"/etc/fstab ] || return 1
1778
        [ -e "${NEW_ROOT}/etc/fstab" ] || return 1
1779
	awk -v fs="$1" '
1779
        FSTYPE="$(
1780
		/^[[:blank:]]*#/ { next }
1780
                < "${NEW_ROOT}/etc/fstab" get_col_by_mount "$1" "3"
1781
		$2 == fs { print $1 }
1781
        )"
1782
		' ${NEW_ROOT}/etc/fstab
1782
        # Set type for zfs without an entry in fstab
1783
        [ -z "${FSTYPE}" ] && is_zfs "$1" && FSTYPE="zfs"
1784
        echo "${FSTYPE}"
1785
}
1786
1787
get_mount_options() {
1788
        local OPTIONS
1789
        # Look for the options in fstab
1790
        [ -e "${NEW_ROOT}/etc/fstab" ] || return 1
1791
        OPTIONS="$(
1792
                < "${NEW_ROOT}/etc/fstab" get_col_by_mount "$1" "4"
1793
        )"
1794
        # Set options for zfs without an entry in fstab
1795
        [ -z "${OPTIONS}" ] && is_zfs "$1" && OPTIONS="rw,zfsutil"
1796
        echo "${OPTIONS}"
1797
}
1798
1799
get_mount_device() {
1800
        local DEVICE
1801
        # Look for the device in fstab
1802
        [ -e "${NEW_ROOT}/etc/fstab" ] || return 1
1803
        DEVICE="$(
1804
                < "${NEW_ROOT}/etc/fstab" get_col_by_mount "$1" "1"
1805
        )"
1806
        # Allow for zfs to also be used without fstab
1807
        [ -z "${DEVICE}" ] && DEVICE="$(
1808
                zfs list -H -o name,mountpoint | get_col_by_mount "$1" "1"
1809
        )"
1810
        echo "${DEVICE}"
1783
}
1811
}
1784
1812
1785
# If the kernel is handed a mount option is does not recognize, it WILL fail to
1813
# If the kernel is handed a mount option is does not recognize, it WILL fail to

Return to bug 692196