Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

dio_open(3) [php man page]

DIO_OPEN(3)								 1							       DIO_OPEN(3)

dio_open - Opens a file (creating it if necessary) at a lower level than the C library input/ouput stream functions allow.

SYNOPSIS
resource dio_open (string $filename, int $flags, [int $mode]) DESCRIPTION
dio_open(3) opens a file and returns a new file descriptor for it. PARAMETERS
o $filename - The pathname of the file to open. o $flags - The $flags parameter is a bitwise-ORed value comprising flags from the following list. This value must include one of O_RDONLY, O_WRONLY, or O_RDWR. Additionally, it may include any combination of the other flags from this list. o O_RDONLY - opens the file for read access. o O_WRONLY - opens the file for write access. o O_RDWR - opens the file for both reading and writing. o O_CREAT - creates the file, if it doesn't already exist. o O_EXCL - if both O_CREAT and O_EXCL are set and the file already exists, dio_open(3) will fail. o O_TRUNC - if the file exists and is opened for write access, the file will be truncated to zero length. o O_APPEND - write operations write data at the end of the file. o O_NONBLOCK - sets non blocking mode. o O_NOCTTY - prevent the OS from assigning the opened file as the process's controlling terminal when opening a TTY device file. o $mode - If $flags contains O_CREAT, $mode will set the permissions of the file (creation permissions). $mode is required for correct operation when O_CREAT is specified in $flags and is ignored otherwise. The actual permissions assigned to the created file will be affected by the process's umask setting as per usual. RETURN VALUES
A file descriptor or FALSE on error. EXAMPLES
Example #1 Opening a file descriptor <?php $fd = dio_open('/dev/ttyS0', O_RDWR | O_NOCTTY | O_NONBLOCK); dio_close($fd); ?> SEE ALSO
dio_close(3). PHP Documentation Group DIO_OPEN(3)

Check Out this Related Man Page

SHM_OPEN(2)						      BSD System Calls Manual						       SHM_OPEN(2)

NAME
shm_open, shm_unlink -- shared memory object operations LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <sys/types.h> #include <sys/mman.h> #include <fcntl.h> int shm_open(const char *path, int flags, mode_t mode); int shm_unlink(const char *path); DESCRIPTION
The shm_open() system call opens (or optionally creates) a POSIX shared memory object named path. The flags argument contains a subset of the flags used by open(2). An access mode of either O_RDONLY or O_RDWR must be included in flags. The optional flags O_CREAT, O_EXCL, and O_TRUNC may also be specified. If O_CREAT is specified, then a new shared memory object named path will be created if it does not exist. In this case, the shared memory object is created with mode mode subject to the process' umask value. If both the O_CREAT and O_EXCL flags are specified and a shared memory object named path already exists, then shm_open() will fail with EEXIST. Newly created objects start off with a size of zero. If an existing shared memory object is opened with O_RDWR and the O_TRUNC flag is spec- ified, then the shared memory object will be truncated to a size of zero. The size of the object can be adjusted via ftruncate(2) and queried via fstat(2). The new descriptor is set to close during execve(2) system calls; see close(2) and fcntl(2). As a FreeBSD extension, the constant SHM_ANON may be used for the path argument to shm_open(). In this case, an anonymous, unnamed shared memory object is created. Since the object has no name, it cannot be removed via a subsequent call to shm_unlink(). Instead, the shared memory object will be garbage collected when the last reference to the shared memory object is removed. The shared memory object may be shared with other processes by sharing the file descriptor via fork(2) or sendmsg(2). Attempting to open an anonymous shared memory object with O_RDONLY will fail with EINVAL. All other flags are ignored. The shm_unlink() system call removes a shared memory object named path. RETURN VALUES
If successful, shm_open() returns a non-negative integer, and shm_unlink() returns zero. Both functions return -1 on failure, and set errno to indicate the error. COMPATIBILITY
The path argument does not necessarily represent a pathname (although it does in most other implementations). Two processes opening the same path are guaranteed to access the same shared memory object if and only if path begins with a slash ('/') character. Only the O_RDONLY, O_RDWR, O_CREAT, O_EXCL, and O_TRUNC flags may be used in portable programs. The result of using open(2), read(2), or write(2) on a shared memory object, or on the descriptor returned by shm_open(), is undefined. It is also undefined whether the shared memory object itself, or its contents, persist across reboots. In FreeBSD, read(2) and write(2) on a shared memory object will fail with EOPNOTSUPP and neither shared memory objects nor their contents persist across reboots. ERRORS
The following errors are defined for shm_open(): [EINVAL] A flag other than O_RDONLY, O_RDWR, O_CREAT, O_EXCL, or O_TRUNC was included in flags. [EMFILE] The process has already reached its limit for open file descriptors. [ENFILE] The system file table is full. [EINVAL] O_RDONLY was specified while creating an anonymous shared memory object via SHM_ANON. [EFAULT] The path argument points outside the process' allocated address space. [ENAMETOOLONG] The entire pathname exceeded 1023 characters. [EINVAL] The path does not begin with a slash ('/') character. [ENOENT] O_CREAT is specified and the named shared memory object does not exist. [EEXIST] O_CREAT and O_EXCL are specified and the named shared memory object does exist. [EACCES] The required permissions (for reading or reading and writing) are denied. The following errors are defined for shm_unlink(): [EFAULT] The path argument points outside the process' allocated address space. [ENAMETOOLONG] The entire pathname exceeded 1023 characters. [ENOENT] The named shared memory object does not exist. [EACCES] The required permissions are denied. shm_unlink() requires write permission to the shared memory object. SEE ALSO
close(2), fstat(2), ftruncate(2), mmap(2), munmap(2) STANDARDS
The shm_open() and shm_unlink() functions are believed to conform to IEEE Std 1003.1b-1993 (``POSIX.1''). HISTORY
The shm_open() and shm_unlink() functions first appeared in FreeBSD 4.3. The functions were reimplemented as system calls using shared mem- ory objects directly rather than files in FreeBSD 8.0. AUTHORS
Garrett A. Wollman <wollman@FreeBSD.org> (C library support and this manual page) Matthew Dillon <dillon@FreeBSD.org> (MAP_NOSYNC) BSD
December 18, 2013 BSD
Man Page