summarylogtreecommitdiffstats
path: root/loop_hook
blob: 51d93d7738b410d19fa3d37bf50ff24dc47d1c6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
run_hook() {
    case $root in
    *@*)
        rootpart=${root%%@*}
        rootimg=${root#*@}

        mkdir /new_rootpart
        if [ "$partfstype" = ntfs ]; then
            # see http://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons/
            ln -s ntfs-3g /usr/bin/@ntfs-3g
            @ntfs-3g "$rootpart" /new_rootpart -o dmask=022,fmask=133
        else
            mount ${partfstype:+-t $partfstype} "$rootpart" /new_rootpart
        fi
        modprobe loop
        root=`losetup -f`
        if ! losetup ${offset:+-o $offset} "$root" /new_rootpart/"$rootimg"; then
             err "Unable to set up root '$root' as loop of '/new_rootpart/$rootimg'"
             launch_interactive_shell
        fi
        ;;
    esac
}