git: 168c7580c632 - main - file: add fo_cmp method
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 24 Jan 2024 05:12:15 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=168c7580c6328342945db0e19a0791466bb07624
commit 168c7580c6328342945db0e19a0791466bb07624
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-01-19 21:01:35 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-01-24 05:11:26 +0000
file: add fo_cmp method
The method should return 0 if the file' underlying objects are same. In
other words, if 0 is returned, io from either of file causes
modifications of the same object.
Reviewed by: brooks, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D43518
---
sys/sys/file.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/sys/sys/file.h b/sys/sys/file.h
index 83da5105ad2b..80ed0e2db3bf 100644
--- a/sys/sys/file.h
+++ b/sys/sys/file.h
@@ -129,6 +129,7 @@ typedef int fo_fallocate_t(struct file *fp, off_t offset, off_t len,
typedef int fo_fspacectl_t(struct file *fp, int cmd,
off_t *offset, off_t *length, int flags,
struct ucred *active_cred, 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;
@@ -152,6 +153,7 @@ struct fileops {
fo_get_seals_t *fo_get_seals;
fo_fallocate_t *fo_fallocate;
fo_fspacectl_t *fo_fspacectl;
+ fo_cmp_t *fo_cmp;
fo_spare_t *fo_spares[8]; /* Spare slots */
fo_flags_t fo_flags; /* DFLAG_* below */
};
@@ -491,6 +493,15 @@ fo_fspacectl(struct file *fp, int cmd, off_t *offset, off_t *length,
active_cred, 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 */