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

Merged
merged 1 commit into from
Aug 6, 2025

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 documentation for 'struct file_operations' to align with changes in Linux kernel version 6.14, enhancing clarity for developers by detailing modifications to member fields and ensuring accuracy with modern kernel APIs.

lkmpg.tex Outdated
@@ -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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Go ahead on top of Linux v5.4 codebase.

@jserv
Copy link
Contributor

jserv commented Aug 5, 2025

Any progress?

@Jordymalone
Copy link
Contributor Author

Any progress?

Thanks for the ping and sorry for the long delay.

I've just pushed the updated version with the revised commit message as we discussed. The main text now remains on the v5.4 baseline, and a footnote has been added to summarize the API changes in modern kernels.

lkmpg.tex Outdated
Comment on lines 961 to 969
\begin{itemize}
\item Added: \texttt{fop\_flags}, \texttt{splice\_eof}, \texttt{uring\_cmd}, \texttt{uring\_cmd\_iopoll}, \texttt{mmap\_capabilities}
\item Removed: \texttt{iterate}, \texttt{sendpage}, \texttt{mmap\_supported\_flags} (!CONFIG\_MMU)
\item Modified:
\begin{itemize}
\item \texttt{iopoll} now takes \texttt{struct io\_comp\_batch *} and \texttt{unsigned int flag}
\item \texttt{setlease} now uses \texttt{struct file\_lease **} and \texttt{int} instead of \texttt{long}
\end{itemize}
\end{itemize}
Copy link
Contributor

Choose a reason for hiding this comment

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

Keep footnotes lean still informative. Don't place items here. Instead, plaintext with notation works.

The main text's 'struct file_operations' example is intentionally kept
at the v5.4 LTS version to ensure compatibility with the guide's code.

To bridge the gap with modern kernels, a new footnote is introduced. It
summarizes the evolution of the struct up to Linux v6.12, documenting
key additions, removals, and modifications to its members. This
provides crucial context for readers working with newer kernel versions.

Co-authored-by: EricccTaiwan <yphbchou0911@gmail.com>
@Jordymalone Jordymalone requested a review from jserv August 6, 2025 03:13
@jserv jserv merged commit 78a7265 into sysprog21:master Aug 6, 2025
1 check passed
@jserv
Copy link
Contributor

jserv commented Aug 6, 2025

Thank @Jordymalone for contributing!

@Jordymalone Jordymalone deleted the sync_code_version branch August 6, 2025 03:23
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