summaryrefslogtreecommitdiffstats
path: root/install/block
blob: d9c627fe0367b180780df62cffed433c374096d8 (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
#!/bin/bash

build() {
    local filter
    local -A blockdevs

    # pata, sata, scsi, nvme
    for filter in 'scsi/.*ata' '/(block|scsi|fusion|nvme)/' 'ata/[ps]ata_' \
            'ata/(ahci|pdc_adma|ata_piix|ata_generic)'; do
        add_checked_modules "$filter" && blockdevs['sd_mod']=1
    done

    # usb
    if add_checked_modules -f '(_cs|sl811_hcd|isp116x_hcd)' '/usb/host'; then
        blockdevs+=(['usb_storage?']=1 ['sd_mod?']=1 ['sr_mod?']=1)
        add_checked_modules '/drivers/usb/storage/'
    fi

    # firewire
    if add_checked_modules '/drivers/firewire/'; then
        blockdevs+=(['firewire-sbp2?']=1 ['sd_mod?']=1 ['sr_mod?']=1)
    fi

    # mmc
    if add_checked_modules '/(mmc|tifm_)'; then
        blockdevs+=(['mmc_block?']=1)
    fi

    # virtio
    if add_checked_modules 'virtio'; then
        blockdevs['virtio_blk?']=1
    fi

    map add_module "${!blockdevs[@]}"
}

help() {
    cat <<HELPEOF
This hook loads the necessary modules for most block devices using pata, sata,
scsi, firewire, usb, or mmc. Detection will take place at runtime. To minimize
the modules in the image, add the autodetect hook too.
HELPEOF
}

# vim: set ft=sh ts=4 sw=4 et: