buflen now includes the space required for the null terminator, so up
to buflen-1 characters are returned. Previously fgets could write
buf[buflen], one byte beyond the caller-nominated length. All
in-tree callers passed sizeof(buf)-1 to compensate, but
posix_compat's apfs_fgets forwards its C-style size argument
directly, so a caller supplying a size-byte buffer could have that
buffer overrun by one byte on an over-long line.
Update callers to pass the full buffer size; usable capacity is
unchanged.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
use correct read status for nor flash
implement format on littlefs
optimize device calls in littlefs flash usage
check for fileops allowed in littlefs
littlefs optimization and support for mtime
normally fgets is on a buffered FILE handle. For AP_Filesystem we use
an unbuffered file descriptor. This means we were reading one byte at
a time from the file
this uses lseek to make fgets() much more efficient by reading the max
buffer size at a time in the file
Improves safety of use and clarity of users. Termination is not
included in the reported size to avoid changing user behavior or
misrepresenting the file contents.
Adds virtual directory entries for these virtual filesystems in /
RTL> ftp list
RTL> Listing /
D @MISSION
D @PARAM
D @ROMFS
D @SYS
D APM
D log
V5_BT.dfu 10541
bootlog.txt 297
dataman 350216
message-intervals-chan0.txt 7
Total size 352.60 kByte
ftp list @MISSION
RTL> Listing @MISSION
LIST: OP seq:7 sess:2 opcode:129 req_opcode:3 size:2 bc:0 ofs:0 plen=2 [2]
ftp list @ROMFS
RTL> Listing @ROMFS
bootloader.bin 16448
hwdef.dat 5743
io_firmware.bin 40880
Total size 61.59 kByte
This PR also makes us *much* more lenient in what we accept for looking at virtual filesystems, so
ftp list @SYS
ftp list /@SYS
ftp list @SYS/
ftp list /@SYS/
should all work
these are causing some boards to crash on startup. Tested with a
QiotekZealotH743 which doesn't get out of setup_usb_strings()
once we have debugged this we can re-add the functionality