git: 7d2b98e645ce - stable/13 - kcmp(2): implement for generic file types
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 11 Feb 2024 01:52:49 UTC
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7d2b98e645ce9454b84f7d1d193d98d0880c4627 commit 7d2b98e645ce9454b84f7d1d193d98d0880c4627 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-01-19 21:44:37 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-02-11 01:40:29 +0000 kcmp(2): implement for generic file types (cherry picked from commit f28526e9466cd60ed33053e922238ba1c9040341) --- sys/kern/kern_event.c | 1 + sys/kern/sys_eventfd.c | 1 + sys/kern/sys_generic.c | 8 ++++++++ sys/kern/sys_pipe.c | 1 + sys/kern/sys_socket.c | 1 + sys/kern/tty_pts.c | 1 + sys/kern/uipc_mqueue.c | 1 + sys/kern/uipc_sem.c | 1 + sys/kern/uipc_shm.c | 1 + sys/sys/file.h | 1 + 10 files changed, 17 insertions(+) diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 0bf84389a6ee..3fb576648fee 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -140,6 +140,7 @@ static struct fileops kqueueops = { .fo_chmod = invfo_chmod, .fo_chown = invfo_chown, .fo_sendfile = invfo_sendfile, + .fo_cmp = file_kcmp_generic, .fo_fill_kinfo = kqueue_fill_kinfo, }; diff --git a/sys/kern/sys_eventfd.c b/sys/kern/sys_eventfd.c index 3a5f1dca6df9..47d422f1fc90 100644 --- a/sys/kern/sys_eventfd.c +++ b/sys/kern/sys_eventfd.c @@ -77,6 +77,7 @@ static struct fileops eventfdops = { .fo_chown = invfo_chown, .fo_sendfile = invfo_sendfile, .fo_fill_kinfo = eventfd_fill_kinfo, + .fo_cmp = file_kcmp_generic, .fo_flags = DFLAG_PASSABLE }; diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index cbb17026894b..32f137f0cb4c 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -2090,3 +2090,11 @@ sys_kcmp(struct thread *td, struct kcmp_args *uap) return (kern_kcmp(td, uap->pid1, uap->pid2, uap->type, uap->idx1, uap->idx2)); } + +int +file_kcmp_generic(struct file *fp1, struct file *fp2, struct thread *td) +{ + if (fp1->f_type != fp2->f_type) + return (3); + return (kcmp_cmp((uintptr_t)fp1->f_data, (uintptr_t)fp2->f_data)); +} diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index edd9ce9534d3..19f5f07d7523 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -168,6 +168,7 @@ struct fileops pipeops = { .fo_chown = pipe_chown, .fo_sendfile = invfo_sendfile, .fo_fill_kinfo = pipe_fill_kinfo, + .fo_cmp = file_kcmp_generic, .fo_flags = DFLAG_PASSABLE }; diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c index c54a729fa12c..cf65edb9ef0a 100644 --- a/sys/kern/sys_socket.c +++ b/sys/kern/sys_socket.c @@ -112,6 +112,7 @@ struct fileops socketops = { .fo_sendfile = invfo_sendfile, .fo_fill_kinfo = soo_fill_kinfo, .fo_aio_queue = soo_aio_queue, + .fo_cmp = file_kcmp_generic, .fo_flags = DFLAG_PASSABLE }; diff --git a/sys/kern/tty_pts.c b/sys/kern/tty_pts.c index 1351560ba05a..3a6a71dfd7e8 100644 --- a/sys/kern/tty_pts.c +++ b/sys/kern/tty_pts.c @@ -611,6 +611,7 @@ static struct fileops ptsdev_ops = { .fo_chown = invfo_chown, .fo_sendfile = invfo_sendfile, .fo_fill_kinfo = ptsdev_fill_kinfo, + .fo_cmp = file_kcmp_generic, .fo_flags = DFLAG_PASSABLE, }; diff --git a/sys/kern/uipc_mqueue.c b/sys/kern/uipc_mqueue.c index 0d0758011731..2038de9324fc 100644 --- a/sys/kern/uipc_mqueue.c +++ b/sys/kern/uipc_mqueue.c @@ -2667,6 +2667,7 @@ static struct fileops mqueueops = { .fo_chown = mqf_chown, .fo_sendfile = invfo_sendfile, .fo_fill_kinfo = mqf_fill_kinfo, + .fo_cmp = file_kcmp_generic, .fo_flags = DFLAG_PASSABLE, }; diff --git a/sys/kern/uipc_sem.c b/sys/kern/uipc_sem.c index ad0f3e1f1d00..7cb25749ad9c 100644 --- a/sys/kern/uipc_sem.c +++ b/sys/kern/uipc_sem.c @@ -153,6 +153,7 @@ static struct fileops ksem_ops = { .fo_chown = ksem_chown, .fo_sendfile = invfo_sendfile, .fo_fill_kinfo = ksem_fill_kinfo, + .fo_cmp = file_kcmp_generic, .fo_flags = DFLAG_PASSABLE }; diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index def8c35025c1..1df3a0967b09 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -165,6 +165,7 @@ struct fileops shm_ops = { .fo_get_seals = shm_get_seals, .fo_add_seals = shm_add_seals, .fo_fallocate = shm_fallocate, + .fo_cmp = file_kcmp_generic, .fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE, }; diff --git a/sys/sys/file.h b/sys/sys/file.h index 4b291459395f..9ae31974745a 100644 --- a/sys/sys/file.h +++ b/sys/sys/file.h @@ -277,6 +277,7 @@ fo_seek_t vn_seek; fo_fill_kinfo_t vn_fill_kinfo; fo_kqfilter_t vn_kqfilter_opath; int vn_fill_kinfo_vnode(struct vnode *vp, struct kinfo_file *kif); +int file_kcmp_generic(struct file *fp1, struct file *fp2, struct thread *td); void finit(struct file *, u_int, short, void *, struct fileops *); void finit_vnode(struct file *, u_int, void *, struct fileops *);