File Descriptor and I/O Control
fcntl
Supported functionality in SCML:
ignore_flags = O_RDONLY | O_WRONLY | O_RDWR | O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC;
can_change_flags = O_APPEND | O_ASYNC | O_DIRECT | O_NOATIME | O_NONBLOCK;
// Duplicate a file descriptor
fcntl(fd, cmd = F_DUPFD | F_DUPFD_CLOEXEC, arg);
// Retrieve file descriptor flags (F_GETFD), file status flags (F_GETFL)
// or SIGIO/SIGURG owner process (F_GETOWN)
fcntl(fd, cmd = F_GETFD | F_GETFL | F_GETOWN);
// Set file descriptor flags
fcntl(fd, cmd = F_SETFD, arg = FD_CLOEXEC);
// Set file status flags
fcntl(fd, cmd = F_SETFL, arg = <ignore_flags> | <can_change_flags>);
// Manage record locks: test (F_GETLK), non-blocking set (F_SETLK), blocking set (F_SETLKW)
fcntl(fd, cmd = F_GETLK | F_SETLK | F_SETLKW, arg);
// Assign SIGIO/SIGURG owner process
fcntl(fd, cmd = F_SETOWN, arg);
// Add seals to the inode referred to
fcntl(fd, cmd = F_ADD_SEALS, arg = F_SEAL_SEAL | F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_WRITE | F_SEAL_FUTURE_WRITE);
// Get seals from the inode referred to
fcntl(fd, cmd = F_GET_SEALS);
Unsupported commands:
F_NOTIFYF_OFD_SETLK,F_OFD_SETLKWandF_OFD_GETLKF_GETOWN_EXandF_SETOWN_EXF_GETSIGandF_SETSIGF_SETLEASEandF_GETLEASEF_SETPIPE_SZandF_GETPIPE_SZF_GET_RW_HINTandF_SET_RW_HINTF_GET_FILE_RW_HINTandF_SET_FILE_RW_HINT
For more information, see the man page.
pipe and pipe2
Supported functionality in SCML:
// Create pipe
pipe(pipefd);
// Create pipe with enhanced behavior control
pipe2(pipefd, flags = O_CLOEXEC);
Silently-ignored flags:
O_DIRECTO_NONBLOCK
For more information, see the man page.
eventfd and eventfd2
Supported functionality in SCML:
// Create event notification descriptor
eventfd(initval);
// Create event notification descriptor with enhanced behavior control
eventfd2(initval, flags = EFD_CLOEXEC);
Silently-ignored flags:
EFD_NONBLOCKEFD_SEMAPHORE
For more information, see the man page.
memfd_create
Supported functionality in SCML:
// Create an anonymous file and return a file descriptor that refers to it
memfd_create(name, flags = MFD_CLOEXEC | MFD_ALLOW_SEALING);
Silently-ignored flags:
MFD_HUGETLB
Unsupported flags:
MFD_HUGE_64KBMFD_HUGE_512KBMFD_HUGE_1MBMFD_HUGE_2MBMFD_HUGE_8MBMFD_HUGE_16MBMFD_HUGE_32MBMFD_HUGE_256MBMFD_HUGE_512MBMFD_HUGE_1GBMFD_HUGE_2GBMFD_HUGE_16GB
For more information, see the man page.
fadvise64
Supported functionality in SCML:
// Announce an intention to access file data in a specific pattern in the future
fadvise64(fd, offset, len, advice = 0);
Silently-ignored flags:
POSIX_FADV_NORMALPOSIX_FADV_RANDOMPOSIX_FADV_SEQUENTIALPOSIX_FADV_WILLNEEDPOSIX_FADV_DONTNEEDPOSIX_FADV_NOREUSE
For more information, see the man page.
epoll_ctl
Supported functionality in SCML:
struct epoll_event = {
events = EPOLLIN | EPOLLOUT | EPOLLRDHUP | EPOLLPRI | EPOLLERR | EPOLLHUP |
EPOLLET | EPOLLONESHOT,
..
};
// Add, modify, or delete entries in the interest list of an epoll file descriptor
epoll_ctl(
epfd,
op = EPOLL_CTL_ADD | EPOLL_CTL_MOD | EPOLL_CTL_DEL,
fd, event = <epoll_event>
);
Unsupported flags in events:
EPOLLEXCLUSIVEEPOLLWAKEUP
For more information, see the man page.
poll and ppoll
Supported functionality in SCML:
struct pollfd = {
events = POLLIN | POLLPRI | POLLOUT | POLLRDHUP | POLLERR |
POLLHUP | POLLNVAL | POLLRDNORM,
..
};
// Wait for I/O event on a set of file descriptors
poll(fds = [ <pollfd> ], nfds, timeout);
// Wait for I/O event on a set of file descriptors with specified signals temporarily blocked
ppoll(fds = [ <pollfd> ], nfds, timeout, sigset, sigset_size);
Unsupported events:
POLLRDBANDPOLLWRNORMPOLLWRBAND
For more information, see the man page.
ioctl
Supported functionality in SCML:
tty_ops = TCGETS | TCSETS | TCSETSW | TCSETSF | TIOCGWINSZ | TIOCSWINSZ |
TIOCGPTN | FIONREAD | KDFONTOP | KDSETMODE | KDGETMODE |
KDSKBMODE | KDGKBMODE;
term_ops = TIOCGPGRP | TIOCSPGRP | TIOCSCTTY | TIOCNOTTY | TIOCGSID;
pty_master_ops = TIOCSPTLCK | TIOCGPTLCK | TIOCGPTPEER | TIOCPKT | TIOCGPKT;
// Control file descriptor flags and I/O modes
ioctl(fd, op = FIONCLEX | FIOCLEX | FIONBIO | FIOASYNC, ..);
// Control terminal devices
ioctl(fd, op = <pty_master_ops> | <tty_ops> | <term_ops>, ..);
// Control framebuffer display
ioctl(
fd,
op = FBIOGET_VSCREENINFO | FBIOPUT_VSCREENINFO | FBIOGET_FSCREENINFO |
FBIOGETCMAP | FBIOPUTCMAP | FBIOPAN_DISPLAY | FBIOBLANK,
..
);
// Control Event devices (evdev)
ioctl(
fd,
op = EVIOCGVERSION | EVIOCGID | EVIOCGNAME | EVIOCGPHYS | EVIOCGUNIQ |
EVIOCGKEY | EVIOCGLED | EVIOCGSW | EVIOCSCLOCKID | EVIOCGBIT,
..
);
// Control Trust Domain Extensions (TDX) guest devices
ioctl(fd, op = TDX_CMD_GET_REPORT0, ..);
For more information, see the man page.
ioprio_set and ioprio_get
Supported functionality in SCML:
// Set the I/O priority for a single thread
ioprio_set(which = IOPRIO_WHO_PROCESS, who, ioprio);
// Get the I/O priority for a single thread
ioprio_get(which = IOPRIO_WHO_PROCESS, who);
Unsupported selectors:
IOPRIO_WHO_PGRPIOPRIO_WHO_USER
For more information, see the man page.