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 (-15 / +46 lines)
Lines 2554-2581 get_mounts_list() { Link Here
2554
		' ${NEW_ROOT}/etc/initramfs.mounts
2554
		' ${NEW_ROOT}/etc/initramfs.mounts
2555
}
2555
}
2556
2556
2557
get_col_by_mount() {
2558
        # Get a column for a mountpoint from fstab-like input
2559
        awk -v fs="$1" -v i="$2" '
2560
                /^[[:blank:]]*#/ { next }
2561
                $2 == fs { print $i }'
2562
}
2563
2564
is_zfs() {
2565
        # Check if mountpoint belongs to zfs
2566
        local TYPE
2567
        TYPE="$(
2568
                zfs list -H -o type,mountpoint \
2569
                | get_col_by_mount "$1" "1"
2570
        )"
2571
        [ -n "${TYPE}" ] && return 0 || return 1
2572
}
2573
2557
get_mount_fstype() {
2574
get_mount_fstype() {
2558
	[ -e "${NEW_ROOT}"/etc/fstab ] || return 1
2575
        local FSTYPE
2559
	awk -v fs="$1" '
2576
        # Look for the type in fstab
2560
		/^[[:blank:]]*#/ { next }
2577
        [ -e "${NEW_ROOT}/etc/fstab" ] || return 1
2561
		$2 == fs { print $3 }
2578
        FSTYPE="$(
2562
		' ${NEW_ROOT}/etc/fstab
2579
                < "${NEW_ROOT}/etc/fstab" get_col_by_mount "$1" "3"
2580
        )"
2581
        # Set type for zfs without an entry in fstab
2582
        [ -z "${FSTYPE}" ] && is_zfs "$1" && FSTYPE="zfs"
2583
        echo "${FSTYPE}"
2563
}
2584
}
2564
2585
2565
get_mount_options() {
2586
get_mount_options() {
2566
	[ -e "${NEW_ROOT}"/etc/fstab ] || return 1
2587
        local OPTIONS
2567
	awk -v fs="$1" '
2588
        # Look for the options in fstab
2568
		/^[[:blank:]]*#/ { next }
2589
        [ -e "${NEW_ROOT}/etc/fstab" ] || return 1
2569
		$2 == fs { print $4 }
2590
        OPTIONS="$(
2570
		' ${NEW_ROOT}/etc/fstab
2591
                < "${NEW_ROOT}/etc/fstab" get_col_by_mount "$1" "4"
2592
        )"
2593
        # Set options for zfs without an entry in fstab
2594
        [ -z "${OPTIONS}" ] && is_zfs "$1" && OPTIONS="rw,zfsutil"
2595
        echo "${OPTIONS}"
2571
}
2596
}
2572
2597
2573
get_mount_device() {
2598
get_mount_device() {
2574
	[ -e "${NEW_ROOT}"/etc/fstab ] || return 1
2599
        local DEVICE
2575
	awk -v fs="$1" '
2600
        # Look for the device in fstab
2576
		/^[[:blank:]]*#/ { next }
2601
        [ -e "${NEW_ROOT}/etc/fstab" ] || return 1
2577
		$2 == fs { print $1 }
2602
        DEVICE="$(
2578
		' ${NEW_ROOT}/etc/fstab
2603
                < "${NEW_ROOT}/etc/fstab" get_col_by_mount "$1" "1"
2604
        )"
2605
        # Allow for zfs to also be used without fstab
2606
        [ -z "${DEVICE}" ] && DEVICE="$(
2607
                zfs list -H -o name,mountpoint | get_col_by_mount "$1" "1"
2608
        )"
2609
        echo "${DEVICE}"
2579
}
2610
}
2580
2611
2581
# If the kernel is handed a mount option is does not recognize, it WILL fail to
2612
# If the kernel is handed a mount option is does not recognize, it WILL fail to

Return to bug 692196