---
name: "cap_ioctls_get"
section: "2"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/cap_ioctls_get"
---

# cap\_ioctls\_get(2)

manage allowed ioctl commands

## NAME

**cap\_ioctls\_limit**, **cap\_ioctls\_get** – manage allowed ioctl commands

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

**#include \<sys/capsicum.h\>**

*int*\

**cap\_ioctls\_limit**(*int fd*, *const unsigned long \*cmds*, *size\_t ncmds*);

*ssize\_t*\

**cap\_ioctls\_get**(*int fd*, *unsigned long \*cmds*, *size\_t maxcmds*);

## DESCRIPTION

If a file descriptor is granted the CAP\_IOCTL capability right, the list of allowed [ioctl(2)](/ioctl/2.md) commands can be selectively reduced (but never expanded) with the **cap\_ioctls\_limit**() system call. The *cmds* argument is an array of [ioctl(2)](/ioctl/2.md) commands and the *ncmds* argument specifies the number of elements in the array. There can be up to *256* elements in the array. Including an element that has been previously revoked will generate an error. After a successful call only those listed in the array may be used.

The list of allowed ioctl commands for a given file descriptor can be obtained with the **cap\_ioctls\_get**() system call. The *cmds* argument points at memory that can hold up to *maxcmds* values. The function populates the provided buffer with up to *maxcmds* elements, but always returns the total number of ioctl commands allowed for the given file descriptor. The total number of ioctls commands for the given file descriptor can be obtained by passing NULL as the *cmds* argument and *0* as the *maxcmds* argument. If all ioctl commands are allowed (CAP\_IOCTL capability right is assigned to the file descriptor and the **cap\_ioctls\_limit**() system call was never called for this file descriptor), the **cap\_ioctls\_get**() system call will return CAP\_IOCTLS\_ALL and will not modify the buffer pointed to by the *cmds* argument.

## RETURN VALUES

The **cap\_ioctls\_limit()** function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

The **cap\_ioctls\_get**() function, if successful, returns the total number of allowed ioctl commands or the value CAP\_IOCTLS\_ALL if all ioctls commands are allowed. On failure the value *-1* is returned and the global variable errno is set to indicate the error.

## ERRORS

The **cap\_ioctls\_limit**() and **cap\_ioctls\_get**() system calls will fail if:

- \[EBADF\]

  The *fd* argument is not a valid descriptor.

- \[EFAULT\]

  The *cmds* argument points at an invalid address.

- \[ENOSYS\]

  The running kernel was compiled without **options CAPABILITY\_MODE**.

The **cap\_ioctls\_limit**() system call may also return the following errors:

- \[EINVAL\]

  The *ncmds* argument is greater than *256*.

- \[ENOTCAPABLE\]

  *cmds* would expand the list of allowed [ioctl(2)](/ioctl/2.md) commands.

## SEE ALSO

[cap\_fcntls\_limit(2)](/cap_fcntls_limit/2.md), [cap\_rights\_limit(2)](/cap_rights_limit/2.md), [ioctl(2)](/ioctl/2.md)

## HISTORY

The **cap\_ioctls\_get**() and **cap\_ioctls\_limit**() system calls first appeared in FreeBSD 8.3. Support for capabilities and capabilities mode was developed as part of the TrustedBSD Project.

## AUTHORS

This function was created by Pawel Jakub Dawidek ⟨*pawel@dawidek.net*⟩ under sponsorship of the FreeBSD Foundation.
