Today I'll continue describing functions from GNU LibC's Linux port which uses more magic numbers... Same of these may be yet more syscall wrappers!

`wait4_time64` wraps the "wait4" or "waitid" syscalls possibly with some bittwiddling format conversion & NULL checks.

`timer_delete` wraps the "timer_delete" syscall with input conversion & a mutex-locked linked-list. `timer_create` has more input conversion and starts a helper thread with it's data under a once flag before recalling the syscall.

`tcsendbreak` wraps "ioctl(TSCBRK)" if input < 0 or with unit conversion "ioctl(TCSBRKP)" if supported. Otherwise errors.

`tcgetattr` wraps "ioctl(TCGETS)" if successful with output conversion with bitmasks & `memcpy`s.

`cfget(i/o)speed` wraps `struct termios` properties with bitmasks. `cfset(o/i)speed` does same with some additional validation.

`sigaction` wraps "rt_sigaction" syscall with, if valid, conversion between given `struct sigaction`s & a `struct kernel_sigaction`.

2/3?

Follow

`getentropy` wraps repeated "getrandom" syscalls until the provided buffer is filled.

`spawni[x]` wraps numerous syscalls to configure the childprocess environment (including `mmap`ing the stack) & call the configured exec syscall.

There's conversion functions between `struct __msqid64_ds` & `struct kernel_msqid64_ds` involving bitshifts. `msgctl_syscall` wraps "msgctl" or "ipc(IPCOP_msgctl)", which `msgctl64` wraps with format conversion under different conditions.

3/4

There's conversion functions between `struct __shmid64_ds` & `struct_kernel_shmid64_ds`. `shmctl_syscall` wraps "shcmctl" or "ipc(IPCOP_shmctl)", which `shmctl64` wraps with format conversion under different conditions. Same situation with `struct __shmid64_ds` & `struct shmid_ds`. And between `struct __semid64_ds` & `struct kernel_semid64_ds`, as well as `struct __semid64_ds` & `struct semid_ds`. As per `struct __msqid64_ds & `struct msqid_ds`

4/5

`getdents` wraps "getdents64" syscall with repeated response parsing involving `memmove`s & `lseek64`s upon error.

`create_thread` wraps "sched_setaffinity", "tgkill", and/or "sched_setscheduler" under different conditions with locking, input validation, & input reformatting.

`mq_notify` conditionally wraps a corresponding syscall, possibly with an atomically initialized helper pthread with signals blocked to manage a `AF_NETLINK` socket running callbacks in in new pthreads upon each message.

`getifaddrs` wraps a `PF_NETLINK` socket with a couple of requests, responses parsing with subsequent multipass multi-conditional reformatting & validation. Includes corresponding routines to free any memory this allocated.

6/6 Fin for today! Tomorrow: functions wrapping filesystem-based kernel APIs.

Sign in to participate in the conversation
FLOSS.social

For people who care about, support, or build Free, Libre, and Open Source Software (FLOSS).