Skip to content

Clarify ioctl third argument as untyped pointer #314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wurrrrrrrrrr
Copy link
Contributor

This pull request updates the documentation for the ioctl function, correcting the description of its third parameter. The original text incorrectly described it as being of type long. It is actually an untyped pointer to memory, traditionally declared as char *argp before void * was valid in C.

Upstream reference:https://man7.org/linux/man-pages/man2/ioctl.2.html

This change improves technical accuracy and helps developers understand how to properly pass data—particularly pointers to structures—from user space to the kernel using ioctl.

Summary by Bito

This pull request revises the ioctl function documentation to clarify the nature of the third argument. It corrects a common misconception by specifying that the parameter is a memory pointer rather than a numeric value. The updated explanation improves clarity for developers using ioctl interfaces in kernel modules and drivers.

Unit tests added: False

Estimated effort to review (1–5, lower is better): 2

Correct the description of the third parameter passed to the ioctl
function. It was previously described as being of type long, but it is
actually an untyped pointer to memory, traditionally declared as
char *argp from before void * was valid in C.

This change improves technical accuracy and helps developers understand
how to correctly pass data—especially structures—between user space and
the kernel using ioctl.
Copy link

Code Review Agent Run Status

  • Limitations and other issues: ❌ Failure - Bito Code Review Skipped - No Changes

    Bito didn't review because we did not see any changes in the PR to review.
    To trigger review again, type /review in the comment and save.
    You can change the settings here, or contact the agent instance creator at [email protected].

@visitorckw
Copy link
Contributor

This pull request updates the documentation for the ioctl function, correcting the description of its third parameter. The original text incorrectly described it as being of type long. It is actually an untyped pointer to memory, traditionally declared as char *argp before void * was valid in C.

Upstream reference:https://man7.org/linux/man-pages/man2/ioctl.2.html

Thanks for the PR.

However, IIUC, the man page you linked describes the C library's ioctl wrapper, not the kernel's system call interface.

In the Linux kernel, the third argument is of type unsigned long. If historically it used to be a different type, could you clarify when that changed (e.g., from which kernel version)?

Also, IIUC, while the third argument is often used as a pointer, it can also simply carry other types of data, such as an integer representing a command or a value.

@wurrrrrrrrrr
Copy link
Contributor Author

Thanks for the detailed explanation!

I see — the man page I initially referred to describes the libc wrapper, where the third argument is traditionally documented as char *argp for historical reasons (before void * was introduced in C).
In the kernel syscall interface, the third argument is actually an unsigned long, which can carry either a pointer or a value depending on the ioctl command.

Thanks again for pointing this out.

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