kcmp(2): implement for devfs files

Compare not vnodes, which are different between mount points, but
actual cdev referenced by the devfs node.

Reviewed by:	brooks, markj
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D43518
This commit is contained in:
Konstantin Belousov 2024-01-19 23:36:50 +02:00
parent f04220c1b0
commit 5c41d888de

View file

@ -2010,6 +2010,14 @@ dev2udev(struct cdev *x)
return (cdev2priv(x)->cdp_inode);
}
static int
devfs_cmp_f(struct file *fp1, struct file *fp2, struct thread *td)
{
if (fp2->f_type != DTYPE_VNODE || fp2->f_ops != &devfs_ops_f)
return (3);
return (kcmp_cmp((uintptr_t)fp1->f_data, (uintptr_t)fp2->f_data));
}
static struct fileops devfs_ops_f = {
.fo_read = devfs_read_f,
.fo_write = devfs_write_f,
@ -2025,6 +2033,7 @@ static struct fileops devfs_ops_f = {
.fo_seek = vn_seek,
.fo_fill_kinfo = vn_fill_kinfo,
.fo_mmap = devfs_mmap_f,
.fo_cmp = devfs_cmp_f,
.fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE
};