git: e4345a107bb4 - stable/13 - file: add fo_cmp method

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sun, 11 Feb 2024 01:52:45 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=e4345a107bb4492a9b43d45f5afc9d36061bee1a

commit e4345a107bb4492a9b43d45f5afc9d36061bee1a
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-01-19 21:01:35 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-02-11 01:40:29 +0000

    file: add fo_cmp method
    
    (cherry picked from commit 168c7580c6328342945db0e19a0791466bb07624)
---
 sys/sys/file.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/sys/sys/file.h b/sys/sys/file.h
index ca8a229b994a..4b291459395f 100644
--- a/sys/sys/file.h
+++ b/sys/sys/file.h
@@ -128,6 +128,8 @@ typedef int fo_add_seals_t(struct file *fp, int flags);
 typedef int fo_get_seals_t(struct file *fp, int *flags);
 typedef int fo_fallocate_t(struct file *fp, off_t offset, off_t len,
 		    struct thread *td);
+typedef int fo_cmp_t(struct file *fp, struct file *fp1, struct thread *td);
+typedef int fo_spare_t(struct file *fp);
 typedef	int fo_flags_t;
 
 struct fileops {
@@ -149,6 +151,8 @@ struct fileops {
 	fo_add_seals_t	*fo_add_seals;
 	fo_get_seals_t	*fo_get_seals;
 	fo_fallocate_t	*fo_fallocate;
+	fo_cmp_t	*fo_cmp;
+	fo_spare_t	*fo_spares[7];	/* Spare slots */
 	fo_flags_t	fo_flags;	/* DFLAG_* below */
 };
 
@@ -477,6 +481,15 @@ fo_fallocate(struct file *fp, off_t offset, off_t len, struct thread *td)
 	return ((*fp->f_ops->fo_fallocate)(fp, offset, len, td));
 }
 
+static __inline int
+fo_cmp(struct file *fp1, struct file *fp2, struct thread *td)
+{
+
+	if (fp1->f_ops->fo_cmp == NULL)
+		return (ENODEV);
+	return ((*fp1->f_ops->fo_cmp)(fp1, fp2, td));
+}
+
 #endif /* _KERNEL */
 
 #endif /* !SYS_FILE_H */