git: 81cee1350ff8 - stable/14 - kcmp(2): implement for linuxkpi cdevs

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Wed, 31 Jan 2024 00:46:14 UTC
The branch stable/14 has been updated by kib:

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

commit 81cee1350ff87537f8203d2db0e8ed2acdff7aef
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-01-19 21:54:03 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2024-01-30 20:24:43 +0000

    kcmp(2): implement for linuxkpi cdevs
    
    (cherry picked from commit 41fb6dc3d4df632ffacf91b5631a718442d129d5)
---
 sys/compat/linuxkpi/common/src/linux_compat.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c
index b913ae602ab3..69a17ea1a4a4 100644
--- a/sys/compat/linuxkpi/common/src/linux_compat.c
+++ b/sys/compat/linuxkpi/common/src/linux_compat.c
@@ -1899,6 +1899,19 @@ linux_iminor(struct inode *inode)
 	return (minor(ldev->dev));
 }
 
+static int
+linux_file_kcmp(struct file *fp1, struct file *fp2, struct thread *td)
+{
+	struct linux_file *filp1, *filp2;
+
+	if (fp2->f_type != DTYPE_DEV)
+		return (3);
+
+	filp1 = fp1->f_data;
+	filp2 = fp2->f_data;
+	return (kcmp_cmp((uintptr_t)filp1->f_cdev, (uintptr_t)filp2->f_cdev));
+}
+
 struct fileops linuxfileops = {
 	.fo_read = linux_file_read,
 	.fo_write = linux_file_write,
@@ -1913,6 +1926,7 @@ struct fileops linuxfileops = {
 	.fo_chmod = invfo_chmod,
 	.fo_chown = invfo_chown,
 	.fo_sendfile = invfo_sendfile,
+	.fo_cmp = linux_file_kcmp,
 	.fo_flags = DFLAG_PASSABLE,
 };