git: f04220c1b064 - main - kcmp(2): implement for vnode files
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 24 Jan 2024 05:12:20 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f04220c1b0641fa68d01dc85d9fef706b02f4079 commit f04220c1b0641fa68d01dc85d9fef706b02f4079 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-01-19 21:24:31 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-01-24 05:11:26 +0000 kcmp(2): implement for vnode files Reviewed by: brooks, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D43518 --- sys/kern/kern_descrip.c | 1 + sys/kern/vfs_vnops.c | 9 +++++++++ sys/sys/vnode.h | 1 + 3 files changed, 11 insertions(+) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index e8e08f57196b..65b1f74d310b 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -5285,6 +5285,7 @@ struct fileops path_fileops = { .fo_chown = badfo_chown, .fo_sendfile = badfo_sendfile, .fo_fill_kinfo = vn_fill_kinfo, + .fo_cmp = vn_cmp, .fo_flags = DFLAG_PASSABLE, }; diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 40596263d551..dc2efee038bb 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -123,6 +123,7 @@ struct fileops vnops = { .fo_mmap = vn_mmap, .fo_fallocate = vn_fallocate, .fo_fspacectl = vn_fspacectl, + .fo_cmp = vn_cmp, .fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE }; @@ -4228,3 +4229,11 @@ vn_lktype_write(struct mount *mp, struct vnode *vp) return (LK_SHARED); return (LK_EXCLUSIVE); } + +int +vn_cmp(struct file *fp1, struct file *fp2, struct thread *td) +{ + if (fp2->f_type != DTYPE_VNODE) + return (3); + return (kcmp_cmp((uintptr_t)fp1->f_vnode, (uintptr_t)fp2->f_vnode)); +} diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index c244eb13294d..987cf995f606 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -818,6 +818,7 @@ int vn_vget_ino_gen(struct vnode *vp, vn_get_ino_t alloc, void *alloc_arg, int lkflags, struct vnode **rvp); int vn_utimes_perm(struct vnode *vp, struct vattr *vap, struct ucred *cred, struct thread *td); +int vn_cmp(struct file *, struct file *, struct thread *td); int vn_io_fault_uiomove(char *data, int xfersize, struct uio *uio); int vn_io_fault_pgmove(vm_page_t ma[], vm_offset_t offset, int xfersize,