Re: Syscalls: eventfd and timerfd

From: Jake Freeland <jake_at_technologyfriends.net>
Date: Tue, 10 Jan 2023 23:40:14 UTC
On Tue, Jan 10, 2023 at 5:30 PM Mateusz Guzik <mjguzik@gmail.com> wrote:

> It is added with a non-standard entry point.
>
> If you git log -p sys/kern/sys_eventfd.c you will see:
>

Thanks. This pointed me in the right direction. That commit contains
almost everything I need to continue.

Jake Freeland


>
> commit 7a202823aa54ba18c485bdbcf355269bcfee1ab9
> Author: Konstantin Belousov <kib@FreeBSD.org>
> Date:   Wed Dec 23 16:14:04 2020 +0200
>
>     Expose eventfd in the native API/ABI using a new __specialfd syscall
>
> then if you git grep __specialfd:
> lib/libc/gen/eventfd.c: return (__sys___specialfd(SPECIALFD_EVENTFD,
> &args, sizeof(args)));
> lib/libc/include/libc_private.h:int             __sys___specialfd(int,
> const void *, __size_t);
> sys/compat/freebsd32/freebsd32_syscall.h:#define
> FREEBSD32_SYS___specialfd       577
> sys/compat/freebsd32/freebsd32_syscalls.c:      "__specialfd",
>          /* 577 = __specialfd */
> sys/compat/freebsd32/freebsd32_sysent.c:        { .sy_narg =
> AS(__specialfd_args), .sy_call = (sy_call_t *)sys___specialfd,
> .sy_auevent = AUE_SPECIALFD, .sy_flags = SYF_CAPENABLED, .sy_thrcnt =
> SY_THR_STATIC },    /* 577 = __specialfd */
> sys/compat/freebsd32/freebsd32_systrace_args.c: /* __specialfd */
> sys/compat/freebsd32/freebsd32_systrace_args.c:         struct
> __specialfd_args *p = params;
> sys/compat/freebsd32/freebsd32_systrace_args.c: /* __specialfd */
> sys/compat/freebsd32/freebsd32_systrace_args.c: /* __specialfd */
> sys/kern/init_sysent.c: { .sy_narg = AS(__specialfd_args), .sy_call =
> (sy_call_t *)sys___specialfd, .sy_auevent = AUE_SPECIALFD, .sy_flags =
> SYF_CAPENABLED, .sy_thrcnt = SY_THR_STATIC },    /* 577 = __specialfd
> */
> sys/kern/sys_generic.c:sys___specialfd(struct thread *td, struct
> __specialfd_args *args)
> sys/kern/syscalls.c:    "__specialfd",                  /* 577 =
> __specialfd */
> sys/kern/syscalls.master:               int __specialfd(
> sys/kern/systrace_args.c:       /* __specialfd */
> sys/kern/systrace_args.c:               struct __specialfd_args *p =
> params;
> sys/kern/systrace_args.c:       /* __specialfd */
> sys/kern/systrace_args.c:       /* __specialfd */
> sys/sys/syscall.h:#define       SYS___specialfd 577
> sys/sys/syscall.mk:     __specialfd.o \
> sys/sys/sysproto.h:struct __specialfd_args {
> sys/sys/sysproto.h:int  sys___specialfd(struct thread *, struct
> __specialfd_args *);
> sys/sys/sysproto.h:#define      SYS_AUE___specialfd     AUE_SPECIALFD
>
> On 1/11/23, Jake Freeland <jake@technologyfriends.net> wrote:
> > Hi there,
> >
> > I am currently working on moving the linux_compat implementation of
> > timerfd (in sys/compat/linux/linux_event.c) into its own FreeBSD syscall
> > similar to what was done for eventfd. This is my first time implementing
> > a syscall, so I have been following the eventfd implementation as a
> > reference. I noticed that the eventfd syscall entries are absent from
> > sys/kern/syscalls.master and I am not sure why. Was eventfd never
> > formally added as a syscall entry or am I missing something? I was
> > planning on adding timerfd entries to syscalls.master, but now I am
> > unsure how to proceed.
> >
> > I apologize for my ignorance. This process is new to me.
> >
> > Thank you,
> > Jake Freeland
> >
>
>
> --
> Mateusz Guzik <mjguzik gmail.com>
>