File: module-setup.sh

package info (click to toggle)
dracut 109-7
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,756 kB
  • sloc: sh: 24,508; ansic: 5,234; makefile: 346; perl: 186; python: 48; javascript: 19
file content (80 lines) | stat: -rwxr-xr-x 1,777 bytes parent folder | download | duplicates (2)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash

echo_fs_helper() {
    local fs=$2
    case "$fs" in
        xfs)
            echo -n " xfs_db xfs_repair xfs_check xfs_metadump "
            ;;
        ext?)
            echo -n " e2fsck "
            ;;
        jfs)
            echo -n " jfs_fsck "
            ;;
        btrfs)
            echo -n " btrfsck "
            ;;
    esac

    echo -n " fsck.$fs "
    return 0
}

include_fs_helper_modules() {
    local fs=$2
    case "$fs" in
        xfs | btrfs | ext4 | ext3)
            instmods crc32c
            ;;
        f2fs)
            instmods crc32
            ;;
        vfat)
            instmods "=fs/nls"
            ;;
    esac
}

# called by dracut
installkernel() {
    # xfs/btrfs/ext4 need crc32c, f2fs needs crc32,
    # vfat needs charsets for codepage= and iocharset=
    if [[ $hostonly_mode == "strict" ]]; then
        for_each_host_dev_fs include_fs_helper_modules
        :
    else
        hostonly='' instmods crc32c crc32 "=fs/nls"
    fi
}

# called by dracut
install() {
    local _helpers

    inst "$moddir/fs-lib.sh" "/lib/fs-lib.sh"
    : > "${initdir}"/etc/fstab.empty

    [[ $nofscks == "yes" ]] && return

    if [[ $fscks == "${fscks#*[^ ]*}" ]]; then
        _helpers=(
            /sbin/fsck* /usr/sbin/fsck*
            xfs_db xfs_check xfs_repair xfs_metadump
            e2fsck jfs_fsck btrfsck
        )
        if [[ $hostonly_mode == "strict" ]]; then
            read -r -a _helpers < <(for_each_host_dev_fs echo_fs_helper)
        fi
    else
        read -r -a _helpers <<< "$fscks"
    fi

    _helpers+=(umount mount)

    if [[ ${_helpers[*]} == *e2fsck* ]] && [[ -e "${dracutsysrootdir-}/etc/e2fsck.conf" ]]; then
        inst_simple /etc/e2fsck.conf
    fi

    inst_multiple -o "${_helpers[@]}" fsck
}