push dkl init boot logic here
This commit is contained in:
26
losetup.go
Normal file
26
losetup.go
Normal 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, "")
|
||||
}
|
Reference in New Issue
Block a user