osbase/fat32: adopt structfs
Change the external interface of the FAT32 writer to take a
structfs.Tree instead of a FAT32-specific data structure. Producers of
file system data are no longer specific to FAT32.
With these changes, the blkio package becomes obsolete. The
LazyFileReader did not actually work as intended when used with
osbase/fat32, because fat32 copies data with io.CopyN and thus stops
reading before reaching EOF, so the LazyFileReader is never closed. The
new Blob interface requires the consumer to explicitly Open and Close.
Change-Id: I9a71a5f0bddf36ac38c656659e6dcfe520b88fb0
Reviewed-on: https://review.monogon.dev/c/monogon/+/4037
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
Tested-by: Jenkins CI
diff --git a/osbase/build/mkimage/main.go b/osbase/build/mkimage/main.go
index 79e2920..bef7517 100644
--- a/osbase/build/mkimage/main.go
+++ b/osbase/build/mkimage/main.go
@@ -19,9 +19,9 @@
"log"
"os"
- "source.monogon.dev/osbase/blkio"
"source.monogon.dev/osbase/blockdev"
"source.monogon.dev/osbase/build/mkimage/osimage"
+ "source.monogon.dev/osbase/structfs"
)
func main() {
@@ -51,33 +51,30 @@
// Open the input files for osimage.Create, fill in reader objects and
// metadata in osimage.Params.
// Start with the EFI Payload the OS will boot from.
- p, err := blkio.NewFileReader(efiPayload)
+ var err error
+ cfg.EFIPayload, err = structfs.OSPathBlob(efiPayload)
if err != nil {
log.Fatalf("while opening the EFI payload at %q: %v", efiPayload, err)
}
- cfg.EFIPayload = p
- ab, err := blkio.NewFileReader(abLoaderPayload)
+ cfg.ABLoader, err = structfs.OSPathBlob(abLoaderPayload)
if err != nil {
log.Fatalf("while opening the abloader payload at %q: %v", abLoaderPayload, err)
}
- cfg.ABLoader = ab
// Attempt to open the system image if its path is set. In case the path
// isn't set, the system partition will still be created, but no
// contents will be written into it.
if systemImage != "" {
- img, err := os.Open(systemImage)
+ cfg.SystemImage, err = structfs.OSPathBlob(systemImage)
if err != nil {
log.Fatalf("while opening the system image at %q: %v", systemImage, err)
}
- defer img.Close()
- cfg.SystemImage = img
}
// Attempt to open the node parameters file if its path is set.
if nodeParams != "" {
- np, err := blkio.NewFileReader(nodeParams)
+ np, err := structfs.OSPathBlob(nodeParams)
if err != nil {
log.Fatalf("while opening node parameters at %q: %v", nodeParams, err)
}