Skip to content

Align struct file_operations with upstream v6.14 #311

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

Jordymalone
Copy link
Contributor

@Jordymalone Jordymalone commented Apr 24, 2025

Chapter 6, "Character Device Drivers", section 6.1 still showed the v5.4 layout of 'struct file_operations'. Replace it with the version shipped in upstream Linux v6.14, keeping the example buildable and the API in step with modern kernels.

Upstream reference: https://elixir.bootlin.com/linux/v6.14/source/include/linux/fs.h#L2131

Summary by Bito

This pull request updates the 'struct file_operations' documentation to align with Linux kernel version 6.14, replacing the outdated reference to version 5.4. Enhancements include modifications to function pointers and the addition of new fields, improving API clarity for character device driver developers.

Unit tests added: False

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

Chapter 6, "Character Device Drivers", section 6.1 still showed the v5.4
layout of 'struct file_operations'. Replace it with the version shipped
in upstream Linux v6.14, keeping the example buildable and the API in
step with modern kernels.

Co-authored-by: EricccTaiwan <[email protected]>
@@ -908,46 +908,52 @@ \subsection{The file\_operations Structure}

For example, every character driver needs to define a function that reads from the device.
The \cpp|file_operations| structure holds the address of the module's function that performs that operation.
Here is what the definition looks like for kernel 5.4:
Here is what the definition looks like for kernel 6.14:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't do that. Linux v5.4 is a long-term support kernel. LKMPG maintains compatibility with LTS kernels, which means all content should be compatible with Linux v5.4 and newer versions, rather than focusing exclusively on recent Linux releases. Instead of modifying the struct definitions, please document any changes to member fields in the descriptions.

Copy link
Contributor Author

@Jordymalone Jordymalone Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your clarification! That make sense.
I just want to confirm that my understanding aligns with your intent:

I’ll revert the struct file_operations example to the original Linux 5.4 definition (undoing my earlier changes) so it stays compatible with all LTS kernels.

To cover newer kernels without breaking the build, I’ll add a short note right after the code that lists the fields added, removed, or modified since 5.4.

As of Linux kernel 6.12, several member fields have been added or removed, or had their prototypes changed:

  • Added: fop_flags, splice_eof, uring_cmd, uring_cmd_iopoll, mmap_capabilities
  • Removed: iterate, sendpage, mmap_supported_flags (!CONFIG_MMU)
  • Modified:
    • iopoll now takes struct io_comp_batch * and unsigned int flags
    • setlease now uses struct file_lease ** and int instead of long

Let me know if this approach fits the documentation style you prefer, or if you'd suggest any adjustments.

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