MCPcopy Create free account
hub / github.com/F-Stack/f-stack / cap_ioctl_check

Function cap_ioctl_check

freebsd/kern/sys_capability.c:359–385  ·  view source on GitHub ↗

* Test whether a capability grants the given ioctl command. * If descriptor doesn't have CAP_IOCTL, then ioctls list is empty and * ENOTCAPABLE will be returned. */

Source from the content-addressed store, hash-verified

357 * ENOTCAPABLE will be returned.
358 */
359int
360cap_ioctl_check(struct filedesc *fdp, int fd, u_long cmd)
361{
362 struct filedescent *fdep;
363 u_long *cmds;
364 ssize_t ncmds;
365 long i;
366
367 KASSERT(fd >= 0 && fd < fdp->fd_nfiles,
368 ("%s: invalid fd=%d", __func__, fd));
369
370 fdep = fdeget_locked(fdp, fd);
371 KASSERT(fdep != NULL,
372 ("%s: invalid fd=%d", __func__, fd));
373
374 ncmds = fdep->fde_nioctls;
375 if (ncmds == -1)
376 return (0);
377
378 cmds = fdep->fde_ioctls;
379 for (i = 0; i < ncmds; i++) {
380 if (cmds[i] == cmd)
381 return (0);
382 }
383
384 return (ENOTCAPABLE);
385}
386
387/*
388 * Check if the current ioctls list can be replaced by the new one.

Callers 1

kern_ioctlFunction · 0.85

Calls 1

fdeget_lockedFunction · 0.85

Tested by

no test coverage detected