David Hendricks has posted comments on this change. ( https://review.coreboot.org/25706 )
Change subject: linux_mtd: Initial import ......................................................................
Patch Set 6:
(3 comments)
I'll hold off on a bit to see if Brian sees my e-mail and has any ideas
https://review.coreboot.org/#/c/25706/4/linux_mtd.c File linux_mtd.c:
https://review.coreboot.org/#/c/25706/4/linux_mtd.c@231 PS4, Line 231: perr(
Maybe there actually is an alignment requirement? In that case […]
strace showed the fread() working, but I didn't see it try to do the fwrite() after the fseek(). I'm not sure what that means, maybe fwrite() just doesn't work on certain types of files? I also tried adjusting chunksize, and reversing the size and nmemb args, but didn't have any luck there. So I sent an e-mail to one of the MTD maintainers (briannorris) in case he has any ideas.
(BTW - the error string I mentioned earlier might not be relevant since fwrite() doesn't set errno)
Since the MTD write-protect functions use a few ioctl()s, I think it would make more sense to convert from file descriptor --> stream in the cases where fread() can be used. Does that sound good?
https://review.coreboot.org/#/c/25706/5/linux_mtd.c File linux_mtd.c:
https://review.coreboot.org/#/c/25706/5/linux_mtd.c@208 PS5, Line 208: if (fread(buf + i, step, 1, dev_fp) != 1) {
`step, 1`, i.e. reading one big chunk, might be better optimized in libc.
Done
https://review.coreboot.org/#/c/25706/5/linux_mtd.c@314 PS5, Line 314:
Nit, we know both `buf` and "nor" are zero-terminated. There is no […]
Done