push dkl init boot logic here

This commit is contained in:
Mikaël Cluseau
2023-12-04 13:59:37 +01:00
parent 1555419549
commit 898c43b954
9 changed files with 141 additions and 50 deletions

26
losetup.go Normal file
View File

@ -0,0 +1,26 @@
package main
import (
"syscall"
"github.com/freddierice/go-losetup/v2"
)
var loDevices = map[string]losetup.Device{}
func losetupAttach(file string) losetup.Device {
if _, ok := loDevices[file]; !ok {
dev, err := losetup.Attach(file, 0, true)
if err != nil {
fatalf("failed to attach %q to a loop device: %v", file, err)
}
loDevices[file] = dev
}
return loDevices[file]
}
func mountSquahfs(source, target string) {
dev := losetupAttach(source)
mount(dev.Path(), target, "squashfs", syscall.MS_RDONLY, "")
}