Implement missing DMFSI interface functions for device driver file operations #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The dmdevfs module had 14 unimplemented DMFSI interface functions marked with TODOs. This PR completes the implementation to enable file-like operations on hardware device drivers through the dmdrvi interface.
Implementation
File I/O Operations
_fopen: Maps todmdrvi_open()(context + flags → device handle)_fclose: Maps todmdrvi_close()with proper cleanup of duplicated path string_fread/_fwrite: Calldmdrvi_read()/dmdrvi_write()which returnsize_tbytes transferred_getc/_putc: Thin wrappers around read/write for single byte operationsPosition & Status Operations
_lseek/_tell: Return error (character devices are non-seekable)_eof: Returns 0 (streaming devices have no EOF concept)_size: Queriesdmdrvi_stat()if availableBuffer & Management Operations
_fflush/_sync: Calldmdrvi_flush()when available_unlink/_rename: Return error (device nodes are immutable)Key Design Decisions
Added
file_handle_tstructure to track:Device drivers expose character device semantics (stream-oriented read/write) rather than file semantics (seekable, truncatable). Operations incompatible with this model return appropriate errors instead of failing silently.
Memory management uses DMOD allocation functions (
Dmod_Malloc,Dmod_StrDup,Dmod_Free) consistently throughout.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.