-
Notifications
You must be signed in to change notification settings - Fork 581
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
Conversation
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 takesstruct io_comp_batch *
andunsigned int flags
setlease
now usesstruct file_lease **
andint
instead oflong
Let me know if this approach fits the documentation style you prefer, or if you'd suggest any adjustments.
There was a problem hiding this comment.
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.
Any progress? |
592f0f9
to
4316b4c
Compare
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. |
4316b4c
to
d012bf8
Compare
lkmpg.tex
Outdated
\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} |
There was a problem hiding this comment.
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>
d012bf8
to
c98224e
Compare
Thank @Jordymalone for contributing! |
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.