Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 29, 2025

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 to dmdrvi_open() (context + flags → device handle)
  • _fclose: Maps to dmdrvi_close() with proper cleanup of duplicated path string
  • _fread/_fwrite: Call dmdrvi_read()/dmdrvi_write() which return size_t bytes transferred
  • _getc/_putc: Thin wrappers around read/write for single byte operations

Position & Status Operations

  • _lseek/_tell: Return error (character devices are non-seekable)
  • _eof: Returns 0 (streaming devices have no EOF concept)
  • _size: Queries dmdrvi_stat() if available

Buffer & Management Operations

  • _fflush/_sync: Call dmdrvi_flush() when available
  • _unlink/_rename: Return error (device nodes are immutable)

Key Design Decisions

Added file_handle_t structure to track:

typedef struct {
    driver_node_t* driver;      // Associated driver
    void* driver_handle;        // Device handle from dmdrvi_open
    const char* path;           // Duplicated path string
    int mode;                   // Open mode flags
    int attr;                   // File attributes
} file_handle_t;

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

This section details on the original issue you should resolve

<issue_title>Dodać implementację brakujących funkcji interfejsowych</issue_title>
<issue_description>Większość funkcji już została zaimplementowana, trzeba teraz dodać te brakujące</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits December 29, 2025 15:27
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Copilot AI changed the title [WIP] Add implementation for missing interface functions Implement missing DMFSI interface functions for device driver file operations Dec 29, 2025
Copilot AI requested a review from JohnAmadis December 29, 2025 15:35
@JohnAmadis JohnAmadis marked this pull request as ready for review December 30, 2025 09:10
@JohnAmadis JohnAmadis merged commit 762f111 into main Dec 30, 2025
1 check passed
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

Successfully merging this pull request may close these issues.

Dodać implementację brakujących funkcji interfejsowych

2 participants