Skip to content

Answer unknown ioctl commands quietly with -ENOTTY - #31

Merged
JohnAmadis merged 2 commits into
masterfrom
claude/sweet-tesla-mlran5
Sep 30, 2026
Merged

JohnAmadis merged 2 commits into
masterfrom
claude/sweet-tesla-mlran5

Conversation

@JohnAmadis

@JohnAmadis JohnAmadis commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem

dmdevfs now probes every node with the standard DMDRVI_IOCTL_BLOCK_GET_INFO (0x100) and DMDRVI_IOCTL_MONITOR_GET_POLICY (0x200) commands to classify it. dmclk logged Invalid ioctl command 256/512 in dmclk_dmdrvi_ioctl for every probe.

Changes

  • Unknown command → -ENOTTY, no log. This is the dmdrvi convention for commands a driver does not implement, and dmdevfs reads any non-zero result as "not this class". The range check now also rejects values below the first command, such as 0 or negative numbers. Before, those fell through to read_configuration/update_configuration and logged errors there.
  • Private commands now start at DMDRVI_IOCTL_CUSTOM_BASE. They used to start at 1, which collides with the standard DMDRVI_IOCTL_NET_* range (0x01..0x05). dmclk.h now includes dmdrvi_ioctl.h.
  • docs/api-reference.md: the enum copy is updated, including the previously missing dmclk_ioctl_cmd_get_domain_frequency.

⚠️ The numeric values of dmclk_ioctl_cmd_t change. Callers that use the enum names (tests, README, docs) only need a rebuild; hard-coded numbers must be updated. Out-of-repo code that includes dmclk.h now needs the dmdrvi headers on its include path.

Testing

A syntax-only compile (gcc -fsyntax-only -Wall) against the dmdrvi/dmod headers is clean. A full module build and a hardware run were not done here.

Same fix as choco-technologies/dmtty#4 and choco-technologies/dmdma#4.

🤖 Generated with Claude Code

https://claude.ai/code/session_016sVYVjrMNmMfPjWQkkGJTM

dmdevfs now probes every node with the standard DMDRVI_IOCTL_BLOCK_GET_INFO
(0x100) and DMDRVI_IOCTL_MONITOR_GET_POLICY (0x200) commands to classify it,
so dmclk logged an "Invalid ioctl command" error for every probe. Unknown
commands are not an error for a driver: return -ENOTTY without logging, as
dmdrvi documents.

Also move dmclk's private commands to DMDRVI_IOCTL_CUSTOM_BASE (0x1000):
they started at 1, colliding with the standard DMDRVI_IOCTL_NET_* range
(0x01..), so a generic network probe would have been misread as a dmclk
command. Callers using the enum names only need a rebuild.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016sVYVjrMNmMfPjWQkkGJTM
Number the private ioctl commands from the dmdrvi_ioctl.h constant itself
rather than repeating its value, so they follow dmdrvi if the base ever
moves. This makes the public header include dmdrvi_ioctl.h, so every
in-repo target that includes it now also pulls in the dmdrvi module
headers. The _Static_assert that guarded the copied value is no longer
needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016sVYVjrMNmMfPjWQkkGJTM
@JohnAmadis
JohnAmadis merged commit 26742d4 into master Sep 30, 2026
4 checks 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.

2 participants