VMSPLICE(2) | Linux Programmer's Manual | VMSPLICE(2) |
vmsplice - ユーザーページをパイプに継ぎ合わせる
#define _GNU_SOURCE /* feature_test_macros(7) 参照 */ #include <fcntl.h> #include <sys/uio.h>
ssize_t vmsplice(int fd, const struct iovec *iov, unsigned long nr_segs, unsigned int flags);
If fd is opened for writing, the vmsplice() system call maps nr_segs ranges of user memory described by iov into a pipe. If fd is opened for reading, the vmsplice() system call fills nr_segs ranges of user memory described by iov from a pipe. The file descriptor fd must refer to a pipe.
ポインター iov は iovec 構造体の配列を指す。 iovec 構造体は <sys/uio.h> で以下のように定義されている:
struct iovec { void *iov_base; /* 開始アドレス */ size_t iov_len; /* バイト数 */ };
flags 引数には、以下の値の 0 個以上をビット毎の論理和の形で指定する。
成功して完了すると、 vmsplice() はパイプに転送したバイト数を返す。 エラーの場合、 vmplice() は -1 を返し、 errno をエラーを示す値に設定する。
vmsplice() システムコールは Linux 2.6.17 で初めて登場した。 ライブラリによるサポートは glibc バージョン 2.5 で追加された。
このシステムコールは Linux 固有である。
指定されたセグメント数が上限に達した場合、 vmsplice() は他のベクトル形式の read/write を行う関数と同じ動作をする。 上限は IOV_MAX であり、 <limits.h> で定義されている。現時点では、この値は 1024 である。
vmsplice() really supports true splicing only from user memory to a pipe. In the opposite direction, it actually just copies the data to userspace. But this makes the interface nice and symmetric and enables people to build on vmsplice() with room for future improvement in performance.
splice(2), tee(2), pipe(7)
この man ページは Linux man-pages プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は https://www.kernel.org/doc/man-pages/ に書かれている。
2019-03-06 | Linux |