Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fat32.Filesystem fails silently when writing files to a directory with many items #109

Open
RafaelMarinheiro opened this issue Apr 9, 2021 · 2 comments

Comments

@RafaelMarinheiro
Copy link

I'm trying to write a program that formats an SD card and writes the contents of https://github.com/raspberrypi/firmware/tree/master/boot/ to it. The core of the code is:

	d, _ := diskfs.Open(dev)
	sectorSize := 512
	ptable := &mbr.Table{
		LogicalSectorSize:  sectorSize,
		PhysicalSectorSize: sectorSize,
		Partitions: []*mbr.Partition{
			{
				Type:  mbr.Fat32LBA,
				Start: 4 * MiB / uint32(sectorSize),
				Size:  2 * GiB / uint32(sectorSize),
			},
		},
	}
	_ := d.Partition(ptable)
	fs, _ := d.CreateFilesystem(disk.FilesystemSpec{
		Partition: 1, FSType: filesystem.TypeFat32, 
	})
	for _, file := range files {
		dest, _ := fs.OpenFile(...)
		_, _ = dest.Write(file.data)
	}

Error handling has been abbreviated as well as directory creation, but both are there in my code.

Once I try to write the files in https://github.com/raspberrypi/firmware/tree/master/boot/overlays (219 entries) to /overlays the code does not report any errors, however only the first ~50-ish files are properly written. Files that are supposedly written later, but to a different directory, are still written correctly.

IMHO this is particularly bad because both fs.OpenFile and dest.Write fail silently, so the caller/user will just notice this much after the program has executed.

@deitch
Copy link
Collaborator

deitch commented Apr 11, 2021

Do they not report errors? The above code ignores the errors:

		dest, _ := fs.OpenFile(...)
		_, _ = dest.Write(file.data)

Is there a way to reproduce the problem without an SD card? It would be great to have a standalone program that reproduces it.

@deitch
Copy link
Collaborator

deitch commented Apr 13, 2021

Now that #110 is in, can we see if we can reproduce this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants