Skip to content

Commit 592f0f9

Browse files
Align struct file_operations with upstream v6.14
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]>
1 parent 0337d8d commit 592f0f9

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

lkmpg.tex

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -908,46 +908,52 @@ \subsection{The file\_operations Structure}
908908

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

913913
\begin{code}
914914
struct file_operations {
915915
struct module *owner;
916+
fop_flags_t fop_flags;
916917
loff_t (*llseek) (struct file *, loff_t, int);
917918
ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
918919
ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
919920
ssize_t (*read_iter) (struct kiocb *, struct iov_iter *);
920921
ssize_t (*write_iter) (struct kiocb *, struct iov_iter *);
921-
int (*iopoll)(struct kiocb *kiocb, bool spin);
922-
int (*iterate) (struct file *, struct dir_context *);
922+
int (*iopoll)(struct kiocb *kiocb, struct io_comp_batch *,
923+
unsigned int flags);
923924
int (*iterate_shared) (struct file *, struct dir_context *);
924925
__poll_t (*poll) (struct file *, struct poll_table_struct *);
925926
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
926927
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
927928
int (*mmap) (struct file *, struct vm_area_struct *);
928-
unsigned long mmap_supported_flags;
929929
int (*open) (struct inode *, struct file *);
930930
int (*flush) (struct file *, fl_owner_t id);
931931
int (*release) (struct inode *, struct file *);
932932
int (*fsync) (struct file *, loff_t, loff_t, int datasync);
933933
int (*fasync) (int, struct file *, int);
934934
int (*lock) (struct file *, int, struct file_lock *);
935-
ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
936935
unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
937936
int (*check_flags)(int);
938937
int (*flock) (struct file *, int, struct file_lock *);
939938
ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int);
940939
ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int);
941-
int (*setlease)(struct file *, long, struct file_lock **, void **);
940+
void (*splice_eof)(struct file *file);
941+
int (*setlease)(struct file *, int, struct file_lease **, void **);
942942
long (*fallocate)(struct file *file, int mode, loff_t offset,
943943
loff_t len);
944944
void (*show_fdinfo)(struct seq_file *m, struct file *f);
945+
#ifndef CONFIG_MMU
946+
unsigned (*mmap_capabilities)(struct file *);
947+
#endif
945948
ssize_t (*copy_file_range)(struct file *, loff_t, struct file *,
946949
loff_t, size_t, unsigned int);
947950
loff_t (*remap_file_range)(struct file *file_in, loff_t pos_in,
948951
struct file *file_out, loff_t pos_out,
949952
loff_t len, unsigned int remap_flags);
950953
int (*fadvise)(struct file *, loff_t, loff_t, int);
954+
int (*uring_cmd)(struct io_uring_cmd *ioucmd, unsigned int issue_flags);
955+
int (*uring_cmd_iopoll)(struct io_uring_cmd *, struct io_comp_batch *,
956+
unsigned int poll_flags);
951957
} __randomize_layout;
952958
\end{code}
953959

0 commit comments

Comments
 (0)