diff options
| author | Konstantin Belousov <kib@FreeBSD.org> | 2024-01-19 22:37:39 +0000 |
|---|---|---|
| committer | Konstantin Belousov <kib@FreeBSD.org> | 2024-01-30 20:24:43 +0000 |
| commit | 0b864eb03f6621d9d0f122e6b18360a4778a4647 (patch) | |
| tree | 189c05e11ec3a09d48bba48a3124eca797d1e6bf | |
| parent | 81cee1350ff87537f8203d2db0e8ed2acdff7aef (diff) | |
kcmp(2): implement for procdesc
(cherry picked from commit f006524d6d696cc2a10b9e90a9a6ea412f1839eb)
| -rw-r--r-- | sys/kern/sys_procdesc.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/kern/sys_procdesc.c b/sys/kern/sys_procdesc.c index ac94c3b44730..e8e0efd5bb00 100644 --- a/sys/kern/sys_procdesc.c +++ b/sys/kern/sys_procdesc.c @@ -97,6 +97,7 @@ static fo_kqfilter_t procdesc_kqfilter; static fo_stat_t procdesc_stat; static fo_close_t procdesc_close; static fo_fill_kinfo_t procdesc_fill_kinfo; +static fo_cmp_t procdesc_cmp; static struct fileops procdesc_ops = { .fo_read = invfo_rdwr, @@ -111,6 +112,7 @@ static struct fileops procdesc_ops = { .fo_chown = invfo_chown, .fo_sendfile = invfo_sendfile, .fo_fill_kinfo = procdesc_fill_kinfo, + .fo_cmp = procdesc_cmp, .fo_flags = DFLAG_PASSABLE, }; @@ -555,3 +557,15 @@ procdesc_fill_kinfo(struct file *fp, struct kinfo_file *kif, kif->kf_un.kf_proc.kf_pid = pdp->pd_pid; return (0); } + +static int +procdesc_cmp(struct file *fp1, struct file *fp2, struct thread *td) +{ + struct procdesc *pdp1, *pdp2; + + if (fp2->f_type != DTYPE_PROCDESC) + return (3); + pdp1 = fp1->f_data; + pdp2 = fp2->f_data; + return (kcmp_cmp((uintptr_t)pdp1->pd_pid, (uintptr_t)pdp2->pd_pid)); +} |
