![]() |
posix-next API 0.1.0
Out-of-tree Zephyr POSIX module
|
POSIX Device Input and Output option group. More...
Files | |
| file | poll.h |
| POSIX poll API (<poll.h>) | |
| file | select.h |
| POSIX select API (<sys/select.h>) | |
Data Structures | |
| struct | sigset_t |
| Type representing a set of signals (bitmask). More... | |
Macros | |
| #define | O_CLOEXEC ZVFS_O_CLOEXEC |
| Close file descriptor on exec (open() flag). | |
| #define | O_CREAT ZVFS_O_CREAT |
| Create file if it does not exist (open() flag). | |
| #define | O_DIRECTORY ZVFS_O_DIRECTORY |
| Fail if path does not name a directory (open() flag). | |
| #define | O_EXCL ZVFS_O_EXCL |
| Exclusive creation: fail if file already exists (open() flag, with O_CREAT). | |
| #define | O_NOCTTY ZVFS_O_NOCTTY |
| Do not assign a controlling terminal (open() flag). | |
| #define | O_NOFOLLOW ZVFS_O_NOFOLLOW |
| Do not follow symbolic links (open() flag). | |
| #define | O_TRUNC ZVFS_O_TRUNC |
| Truncate file to zero length on open (open() flag). | |
| #define | O_TTY_INIT ZVFS_O_TTY_INIT |
| Initialise terminal to conforming state (open() flag). | |
| #define | O_APPEND ZVFS_O_APPEND |
| Write operations append to end of file. | |
| #define | O_DSYNC ZVFS_O_DSYNC |
| Write I/O completes as defined for synchronised I/O data integrity. | |
| #define | O_NONBLOCK ZVFS_O_NONBLOCK |
| Non-blocking I/O mode. | |
| #define | O_RSYNC ZVFS_O_RSYNC |
| Synchronised read I/O (same as O_SYNC for reads). | |
| #define | O_SYNC ZVFS_O_SYNC |
| Write I/O completes as defined for synchronised I/O file integrity. | |
| #define | O_EXEC ZVFS_O_EXEC |
| Open for execute only (no read, write, or search). | |
| #define | O_RDONLY ZVFS_O_RDONLY |
| Open for reading only. | |
| #define | O_RDWR ZVFS_O_RDWR |
| Open for reading and writing. | |
| #define | O_SEARCH ZVFS_O_SEARCH |
| Open directory for search only. | |
| #define | O_WRONLY ZVFS_O_WRONLY |
| Open for writing only. | |
| #define | O_ACCMODE (ZVFS_O_RDONLY | ZVFS_O_RDWR | ZVFS_O_WRONLY) |
| Mask to extract the file access mode from open flags. | |
| #define | pollfd zvfs_pollfd |
| Poll file descriptor structure (alias for zvfs_pollfd). | |
| #define | POLLIN ZVFS_POLLIN |
| Data other than high-priority data may be read without blocking. | |
| #define | POLLRDNORM ZVFS_POLLRDNORM |
| Normal data may be read without blocking. | |
| #define | POLLRDBAND ZVFS_POLLRDBAND |
| Priority data may be read without blocking. | |
| #define | POLLPRI ZVFS_POLLPRI |
| High-priority data may be read without blocking. | |
| #define | POLLOUT ZVFS_POLLOUT |
| Normal data may be written without blocking. | |
| #define | POLLWRNORM ZVFS_POLLWRNORM |
| Equivalent to POLLOUT. | |
| #define | POLLWRBAND ZVFS_POLLWRBAND |
| Priority data may be written. | |
| #define | POLLERR ZVFS_POLLERR |
| An error has occurred on the file descriptor (output only). | |
| #define | POLLHUP ZVFS_POLLHUP |
| The file descriptor has been hung up (output only). | |
| #define | POLLNVAL ZVFS_POLLNVAL |
| The file descriptor is not open (output only). | |
| #define | EFD_SEMAPHORE ZVFS_EFD_SEMAPHORE |
| Semaphore-mode flag: each read decrements the counter by 1 instead of resetting to 0. | |
| #define | EFD_NONBLOCK ZVFS_EFD_NONBLOCK |
| Non-blocking flag: reads and writes return EAGAIN instead of blocking. | |
| #define | FD_SETSIZE ZVFS_FD_SETSIZE |
| Maximum number of file descriptors in an fd_set. | |
| #define | SIGRTMAX (SIGRTMIN + CONFIG_POSIX_RTSIG_MAX) |
| Largest real-time signal number. | |
| #define | STDERR_FILENO 2 |
| File descriptor for standard error. | |
| #define | STDIN_FILENO 0 |
| File descriptor for standard input. | |
| #define | STDOUT_FILENO 1 |
| File descriptor for standard output. | |
| #define | _POSIX_VDISABLE ('\0') |
| Value used to disable a special character in a terminal. | |
Typedefs | |
| typedef int | nfds_t |
| Type for the number of file descriptors passed to poll(). | |
| typedef zvfs_eventfd_t | eventfd_t |
| Counter value type for eventfd operations. | |
| typedef long | suseconds_t |
| Microsecond time component type. | |
| typedef struct zvfs_fd_set | fd_set |
| Set of file descriptors for select()/pselect(). | |
Functions | |
| int | creat (const char *path, mode_t mode) |
| Create or truncate a file. | |
| int | open (const char *name, int flags,...) |
| Open or create a file. | |
| int | openat (int fd, const char *path, int oflag,...) |
| Open or create a file relative to a directory file descriptor. | |
| int | poll (struct zvfs_pollfd *fds, nfds_t nfds, int timeout) |
| Wait for events on a set of file descriptors. | |
| int | eventfd (unsigned int initval, int flags) |
| Create a file descriptor for event notification. | |
| int | eventfd_read (int fd, eventfd_t *value) |
| Read the current counter value from an eventfd. | |
| int | eventfd_write (int fd, eventfd_t value) |
| Add a value to an eventfd counter. | |
| int | pselect (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timespec *timeout, const sigset_t *sigmask) |
| Synchronous multiplexed I/O with signal-mask and nanosecond timeout. | |
| int | select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *timeout) |
| Synchronous multiplexed I/O (legacy interface, use pselect() for new code). | |
| void | FD_CLR (int fd, fd_set *fdset) |
| Remove a file descriptor from an fd_set. | |
| int | FD_ISSET (int fd, fd_set *fdset) |
| Test whether a file descriptor is in an fd_set. | |
| void | FD_SET (int fd, fd_set *fdset) |
| Add a file descriptor to an fd_set. | |
| void | FD_ZERO (fd_set *fdset) |
| Clear all file descriptors from an fd_set. | |
| int | close (int fildes) |
| Close a file descriptor. | |
| int | isatty (int fildes) |
| Determine whether a file descriptor refers to a terminal. | |
| ssize_t | pread (int fildes, void *buf, size_t nbyte, off_t offset) |
| Read from a file at a given offset without changing the file offset. | |
| ssize_t | pwrite (int fildes, const void *buf, size_t nbyte, off_t offset) |
| Write to a file at a given offset without changing the file offset. | |
| ssize_t | read (int fildes, void *buf, size_t nbyte) |
| Read from a file descriptor. | |
| char * | ttyname (int fildes) |
| Get the name of the terminal associated with a file descriptor. | |
| ssize_t | write (int fildes, const void *buf, size_t nbyte) |
| Write to a file descriptor. | |
POSIX Device Input and Output option group.
Covers open(), close(), read(), write(), pread(), pwrite(), isatty(), ttyname(), ttyname_r(), and related device-I/O primitives.
| #define _POSIX_VDISABLE ('\0') |
| #define EFD_NONBLOCK ZVFS_EFD_NONBLOCK |
| #define EFD_SEMAPHORE ZVFS_EFD_SEMAPHORE |
| #define FD_SETSIZE ZVFS_FD_SETSIZE |
| #define O_ACCMODE (ZVFS_O_RDONLY | ZVFS_O_RDWR | ZVFS_O_WRONLY) |
| #define O_APPEND ZVFS_O_APPEND |
| #define O_CLOEXEC ZVFS_O_CLOEXEC |
| #define O_CREAT ZVFS_O_CREAT |
| #define O_DIRECTORY ZVFS_O_DIRECTORY |
| #define O_DSYNC ZVFS_O_DSYNC |
| #define O_EXCL ZVFS_O_EXCL |
| #define O_EXEC ZVFS_O_EXEC |
| #define O_NOCTTY ZVFS_O_NOCTTY |
| #define O_NOFOLLOW ZVFS_O_NOFOLLOW |
| #define O_RSYNC ZVFS_O_RSYNC |
| #define O_SEARCH ZVFS_O_SEARCH |
| #define O_SYNC ZVFS_O_SYNC |
| #define O_TRUNC ZVFS_O_TRUNC |
| #define O_TTY_INIT ZVFS_O_TTY_INIT |
| #define POLLERR ZVFS_POLLERR |
| #define pollfd zvfs_pollfd |
| #define POLLHUP ZVFS_POLLHUP |
| #define POLLIN ZVFS_POLLIN |
| #define POLLNVAL ZVFS_POLLNVAL |
| #define POLLOUT ZVFS_POLLOUT |
| #define POLLPRI ZVFS_POLLPRI |
| #define POLLRDBAND ZVFS_POLLRDBAND |
| #define POLLRDNORM ZVFS_POLLRDNORM |
| #define POLLWRBAND ZVFS_POLLWRBAND |
| #define SIGRTMAX (SIGRTMIN + CONFIG_POSIX_RTSIG_MAX) |
| #define STDERR_FILENO 2 |
| #define STDOUT_FILENO 1 |
| typedef zvfs_eventfd_t eventfd_t |
| typedef struct zvfs_fd_set fd_set |
| typedef int nfds_t |
| typedef long suseconds_t |
| int close | ( | int | fildes | ) |
Close a file descriptor.
| int creat | ( | const char * | path, |
| mode_t | mode | ||
| ) |
Create or truncate a file.
Equivalent to open(path, O_WRONLY|O_CREAT|O_TRUNC, mode).
| path | File path. |
| mode | Permission bits applied if the file is created. |
| int eventfd | ( | unsigned int | initval, |
| int | flags | ||
| ) |
Create a file descriptor for event notification.
The returned file descriptor can be used with POSIX read()/write() or with eventfd_read()/eventfd_write(). It also integrates with poll(), allowing a writing thread to wake a polling thread simply by writing to the eventfd.
When using read()/write(), the buffer size must be exactly 8 bytes or the call will fail with EINVAL.
| initval | Initial counter value. |
| flags | 0, EFD_SEMAPHORE, EFD_NONBLOCK, or their combination. |
| int eventfd_read | ( | int | fd, |
| eventfd_t * | value | ||
| ) |
Read the current counter value from an eventfd.
In normal mode the counter is reset to 0; in EFD_SEMAPHORE mode it is decremented by 1. Blocks if the counter is 0 (unless EFD_NONBLOCK).
| fd | Eventfd file descriptor. |
| value | Output: counter value read. |
| int eventfd_write | ( | int | fd, |
| eventfd_t | value | ||
| ) |
Add a value to an eventfd counter.
Wakes any thread blocked in eventfd_read(), read(), or poll() on fd.
| fd | Eventfd file descriptor. |
| value | Value to add to the counter. |
| void FD_CLR | ( | int | fd, |
| fd_set * | fdset | ||
| ) |
Remove a file descriptor from an fd_set.
| fd | File descriptor to clear. |
| fdset | File descriptor set to modify. |
| int FD_ISSET | ( | int | fd, |
| fd_set * | fdset | ||
| ) |
Test whether a file descriptor is in an fd_set.
| fd | File descriptor to test. |
| fdset | File descriptor set. |
fd is set, 0 otherwise. | void FD_SET | ( | int | fd, |
| fd_set * | fdset | ||
| ) |
Add a file descriptor to an fd_set.
| fd | File descriptor to add. |
| fdset | File descriptor set to modify. |
| void FD_ZERO | ( | fd_set * | fdset | ) |
Clear all file descriptors from an fd_set.
| fdset | File descriptor set to clear. |
| int isatty | ( | int | fildes | ) |
Determine whether a file descriptor refers to a terminal.
| int open | ( | const char * | name, |
| int | flags, | ||
| ... | |||
| ) |
Open or create a file.
| name | File path. |
| flags | Access and creation flags (O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, …). |
| ... | If O_CREAT: mode_t mode. |
| int openat | ( | int | fd, |
| const char * | path, | ||
| int | oflag, | ||
| ... | |||
| ) |
Open or create a file relative to a directory file descriptor.
| fd | Directory file descriptor, or AT_FDCWD. |
| path | File path (relative to fd, or absolute). |
| oflag | Access and creation flags. |
| ... | If O_CREAT: mode_t mode. |
| int poll | ( | struct zvfs_pollfd * | fds, |
| nfds_t | nfds, | ||
| int | timeout | ||
| ) |
Wait for events on a set of file descriptors.
Examines each file descriptor in fds for the events specified in its events field. Blocks until at least one descriptor is ready, the timeout expires, or a signal is caught.
| fds | Array of struct pollfd descriptors to monitor. |
| nfds | Number of entries in fds. |
| timeout | Timeout in milliseconds; -1 to block indefinitely, 0 to return immediately. |
revents on success, 0 on timeout, or -1 with errno set on failure. | ssize_t pread | ( | int | fildes, |
| void * | buf, | ||
| size_t | nbyte, | ||
| off_t | offset | ||
| ) |
Read from a file at a given offset without changing the file offset.
| int pselect | ( | int | nfds, |
| fd_set * | readfds, | ||
| fd_set * | writefds, | ||
| fd_set * | exceptfds, | ||
| const struct timespec * | timeout, | ||
| const sigset_t * | sigmask | ||
| ) |
Synchronous multiplexed I/O with signal-mask and nanosecond timeout.
| nfds | Highest-numbered file descriptor in any set + 1. |
| readfds | Set of file descriptors to watch for readability, or NULL. |
| writefds | Set of file descriptors to watch for writability, or NULL. |
| exceptfds | Set of file descriptors to watch for exceptions, or NULL. |
| timeout | Maximum wait time, or NULL to block indefinitely. |
| sigmask | Signal mask to apply during the wait, or NULL. |
| ssize_t pwrite | ( | int | fildes, |
| const void * | buf, | ||
| size_t | nbyte, | ||
| off_t | offset | ||
| ) |
Write to a file at a given offset without changing the file offset.
| ssize_t read | ( | int | fildes, |
| void * | buf, | ||
| size_t | nbyte | ||
| ) |
Read from a file descriptor.
| int select | ( | int | nfds, |
| fd_set * | readfds, | ||
| fd_set * | writefds, | ||
| fd_set * | errorfds, | ||
| struct timeval * | timeout | ||
| ) |
Synchronous multiplexed I/O (legacy interface, use pselect() for new code).
| nfds | Highest-numbered file descriptor in any set + 1. |
| readfds | Set of file descriptors to watch for readability, or NULL. |
| writefds | Set of file descriptors to watch for writability, or NULL. |
| errorfds | Set of file descriptors to watch for errors, or NULL. |
| timeout | Maximum wait time, or NULL to block indefinitely. |
| char * ttyname | ( | int | fildes | ) |
Get the name of the terminal associated with a file descriptor.
| ssize_t write | ( | int | fildes, |
| const void * | buf, | ||
| size_t | nbyte | ||
| ) |
Write to a file descriptor.