Re:FatFs – Generic FAT Filesystem Module
by devwastaken on Sunday January 01, 2023 @08:31PM
(#34213170)
Can this do virtual files? For example if I turned a microcontroller into a false flash drive of sorts, and wanted to generate the contents of a file on the fly and not have them at rest in a FAT system.
[ Parent
| on HN ]
This isn't really the tool for that. With FatFS, you provide a way to interact with the storage medium (disk read/write and so forth) and FatFS handles everything at the filesystem level (file open, directory listing, etc.) It would be much easier to emulate a filesystem (perhaps even copying parts of FatFS' API) than it would be to emulate a virtual disk and and access it at arm's length with FatFS.
Re:FatFs – Generic FAT Filesystem Module
by 10000truths on Sunday January 01, 2023 @11:07PM
(#34214213)
From the website:
FatFs controls the storage devices via a simple media access interface shown below.
disk_status - Get device status
disk_initialize - Initialize device
disk_read - Read data
disk_write - Write data
disk_ioctl - Control device dependent functions
get_fattime - Get current time
For your use case, you'd probably have to implement the disk_read method to dynamically generate and return your content based on the start and end sectors provided as parameters.