Skip to content

Commit

Permalink
kcmp(2): implement for procdesc
Browse files Browse the repository at this point in the history
Reviewed by:	brooks, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D43518
  • Loading branch information
kostikbel committed Jan 24, 2024
1 parent 41fb6dc commit f006524
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions sys/kern/sys_procdesc.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,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,
Expand All @@ -108,6 +109,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,
};

Expand Down Expand Up @@ -552,3 +554,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));
}

0 comments on commit f006524

Please sign in to comment.