summaryrefslogtreecommitdiffstats
path: root/hooks/filesystems
blob: e6d980d2971dc969a856c03726de8614334cea5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# vim: set ft=sh:
run_hook ()
{
    isnumeric ()
    {
        i=0;
        while [ $i -lt ${#1} ]; do
            case ${1:$i:1} in
                [0-9A-Fa-f]) i=$(($i+1)); continue;;
                *) return 1;;
            esac
        done
        return 0
    }

    msg -n ":: Loading root filesystem module..."
    if [ "x${rootfstype}" != "x" ]; then
        FSTYPE="${rootfstype}"
    else
        if [ ! -e "${root}" ]; then
            msg "Attempting to create root device '${root}'"

            if [ "x${rootdelay}" != "x" ]; then
                msg -n "Waiting for devices to settle..."
                /bin/sleep "${rootdelay}"
                msg "done."
                export rootdelay=0
            fi

            dev_t=$( /bin/parseblock "${root}" )
            if isnumeric "${root}"; then
                export root="/dev/root"
            fi
            if [ "x${dev_t}" != "x" ]; then
                /bin/mknod "${root}" b ${dev_t} >/dev/null 2>&1
            else
                FSTYPE="unknown"
                echo "ERROR: Failed to parse block device '${root}'"
            fi
        fi

        if [ -e "${root}" ]; then
            eval $( /bin/fstype < "${root}" )
        else
            FSTYPE="unknown"
        fi

        if [ "${FSTYPE}" = "unknown" ]; then
            echo "ERROR: root fs cannot be detected. Try using the rootfstype= kernel parameter."
        fi
    fi
    msg "   ${FSTYPE}"
    kinit_params="${kinit_params} rootfstype=${FSTYPE}"
    /bin/modprobe -q "${FSTYPE}" >/dev/null 2>&1
}