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/fat32/dos83.go b/osbase/fat32/dos83.go
index 1d988be..b8d219d 100644
--- a/osbase/fat32/dos83.go
+++ b/osbase/fat32/dos83.go
@@ -28,12 +28,12 @@
// well as valid ASCII
var validDOSName = regexp.MustCompile(`^^([A-Z0-9!#$%&'()@^_\x60{}~-]{0,8})(\.[A-Z0-9!#$%&'()-@^_\x60{}~-]{1,3})?$`)
-func makeUniqueDOSNames(inodes []*Inode) error {
+func makeUniqueDOSNames(nodes []*node) error {
taken := make(map[[11]byte]bool)
- var lossyNameInodes []*Inode
+ var lossyNameNodes []*node
// Make two passes to ensure that names can always be passed through even
// if they would conflict with a generated name.
- for _, i := range inodes {
+ for _, i := range nodes {
for j := range i.dosName {
i.dosName[j] = ' '
}
@@ -54,7 +54,7 @@
taken[i.dosName] = true
continue
}
- lossyNameInodes = append(lossyNameInodes, i)
+ lossyNameNodes = append(lossyNameNodes, i)
}
// Willfully ignore the recommended short name generation algorithm as it
// requires tons of bookkeeping and doesn't result in stable names so
@@ -63,7 +63,7 @@
// of that because of long file name entries), so 4 hex characters
// guarantee uniqueness, regardless of the rest of name.
var nameIdx int
- for _, i := range lossyNameInodes {
+ for _, i := range lossyNameNodes {
nameUpper := strings.ToUpper(i.Name)
dotParts := strings.Split(nameUpper, ".")
for j := range dotParts {