DCMD_FSYS_DIRECT_IO
QNX SDP8.0Devctl and Ioctl CommandsDeveloper
Perform direct I/O
Synopsis:
#include <sys/dcmd_blk.h>
#define DCMD_FSYS_DIRECT_IO __DIOT(_DCMD_FSYS, 15, struct fs_directio)
#define DCMD_FSYS_DIRECT_IO_IOV __DIOT(_DCMD_FSYS, 38, struct fs_directio_iov)
#define DCMD_FSYS_DIRECT_IO_OLD __DIOT(_DCMD_FSYS, 15, struct fs_directio_old)
Arguments to devctl():
Argument | Value |
---|---|
filedes | A file descriptor that you obtained by opening the device. |
dcmd | DCMD_FSYS_DIRECT_IO |
dev_data_ptr | A pointer to a struct fs_directio (see below) |
n_bytes | sizeof(struct fs_directio) |
dev_info_ptr | A pointer to a 32-bit signed integer. On success, the devctl() call populates this buffer with the number of bytes successfully transferred. Pass NULL if you do not want this information. |
Description:
The DCMD_FSYS_DIRECT_IO command performs a direct I/O operation on a file. DCMD_FSYS_DIRECT_IO_IOV allows DCMD_FSYS_DIRECT_IO to be used when the client's buffers are not contiguous in memory.
Input:
fs_directio
The fs_directio structure is defined in <sys/dcmd_blk.h> as follows:
struct fs_directio {
off64_t offset;
uint32_t nbytes;
uint32_t flags;
paddr64_t paddr;
uint64_t vaddr;
};
The members include:
- offset
- The offset in the file to start the operation at.
- nbytes
- The number of bytes you want to read or write.
- flags
- The type of operation; one of:
- FS_DIO_READ — read-only
- FS_DIO_WRITE — write-only
You can OR the above with zero or one or both of the following:
- FS_DIO_SYNC — subsequent operations are complete only when the data has been successfully transferred
- FS_DIO_MAP_PHYS — map physical memory
- paddr
- The physical address of where to read or write the data.
- vaddr
- The virtual address of where to read or write the data.
fs_directio_iov
You use the fs_directio_iov structure when the client's buffers are not contiguous in memory. To use this form of the structure, use DCMD_FSYS_DIRECT_IO_IOV.The fs_directio_iov structure is defined in <sys/dcmd_blk.h> as follows:
struct fs_directio_iov {
off64_t offset;
_Uint32t nbytes;
_Uint32t flags;
_Uint32t niov;
__FLEXARY(struct __iovec64, iov);
};
The offset and flags members are as for fs_directio.
- nbytes
- The number of bytes you want to read or write. It's the sum of the lengths of each IOV specified by iov.
- nbytes
- The number of bytes you want to read or write.
- niov
- The number of elements in the iov array.
- iov
- An array of struct __iovec64. The _iov_base member of the iov holds either the paddr or the vaddr, depending on whether FS_DIO_MAP_PHYS is set in flags.
fs_directio_old
The fs_directio_old structure is similar to fs_directio, except that the paddr member is of type paddr32_t, and the vaddr member is of type uint32_t. If you want this form of the structure, use DCMD_FSYS_DIRECT_IO_OLD.Output:
None.
Example:
struct fs_directio dio;
/* Send a zero-byte read to see if direct I/O is available on the fd: */
memset(&dio, 0, sizeof dio);
dio.flags = _IO_FLAG_RD;
if (devctl(fd, DCMD_FSYS_DIRECT_IO, &dio, sizeof dio, 0) == EOK)
{
/* Direct I/O is supported. */
}
See also:
devctl() in the QNX OS C Library Reference
Page updated: