|
��������
streamio - ���������� ������������������
���������
#include <stropts.h> int ioctl (fildes, command, arg) int fildes, command;
��������
���������� ������������������ [��. intro(2)]
�������� fildes - ��� ���������� ��������� �����, ������������ �����. �������� command ������ ����������� �������, ��� ������� ����. �������� arg ������ �������������� ��������� ��� ���� �������. ��� ��������� arg ������� �� �������. ������ ��� int ��� ��������� �� �����-���� ���������.
��������� ���������� ������������������ �������������� � ������� ���������� ������ ioctl(2), ������, ��������� � ioctl(2), ��������� � � ���������� ������������������. � ���������� � ���� ������� ��������� ����� ����� ����������� ��������, � ���������� errno ������� �������� EINVAL, ���� �����, ������������ ������������ �����, ������������������, ���� �������� command ����� ��������, �� ���������� � ����� ������.
������ ����� �������������� �������� � ���������� ���������������. � ���� ������ ������ ��� ������� �������� ���������, ���������� ��� ������, ������ ������, ���������� errno ������������� ��������, ������ ���������� ���� ������, � ��������������� ��������� ����� ����������� ��������.
��������� ������� ���������� ������ ioctl(2) ��������� �� ���� �����������������.
��������, �������� �������� ������ SIGPOLL, ������ ����������� ������ ������� I_SETSIG. ���� ��������� ��������� ��������� ������������ �� ����� � ��� �� �������� ������ � ���� �� ������, ��� ����������� ������� ������� ����� ������� ����.
���� �������� arg ����� 0, ������� ��������� �� ������ ���������, ������� ����� �������� ������ SIGPOLL.
��� ������� ���������� errno ��������� ���� �� ��������� ��������:
��� ������� ���������� errno ��������� ���� �� ��������� ��������:
��� ������� ���������� errno ��������� ���� �� ��������� ��������:
struct strpeek { struct strbuf ctlbuf; struct strbuf databuf; long flags; };���� ctlbuf.maxlen � databuf.maxlen [��. getmsg(2)] ������ ���� ����������� ������� ���������� ����������� ���� �� ����������� ������� � ������� ������ ��������������. ���� ���� flags ����� �������� RS_HIPRI, �� ������� �� ������ ������ ����� ����������� ������ ������������ ���������.
������� I_PEEK ���������� �������� 1, ���� ��������� ���� ���������. ��������� ����� 0, ���� � ������� �� ������ ������ ��� ��������� ��� ���� ���������� ���� RS_HIPRI, � � ������� �� ������ ������ ��� ������������ ���������. �������� ��������� �� ������������. ��� �������� ���� ctlbuf ������ ���������� �� ����������� �������, databuf - �� ������� ������, flags �������� �������� 0 ��� RS_HIPRI.
��� ������� ���������� errno ��������� ��������� ��������:
��� ������� ���������� errno ��������� ��������� ��������:
��� ������� ���������� errno ��������� ��������� ��������:
��� ������� ���������� errno ��������� ��������� ��������:
�������� arg ��������� �� ��������� ���� struct strfdinsert:
struct strfdinsert { struct strbuf ctlbuf; struct strbuf databuf; long flags; int fildes; int offset; };���� ctlbuf.len [��. putmsg(2)] ������ ����� ��������, ������ ������� ��������� ���� ���������� ���� � ����������� ������� ���������. ���� fildes ������ ���������� ����� ������� ������. ���� offset, ������� ������ ���� ��������� �� ������� �����, ������ �������� �� ������ ����������� ������� ������ ������, ���� ������� I_FDINSERT ������� ��������� �� ��������� ������� ������ �������� ������, ������������� fildes. ���� databuf.len ������ ����� ��������, ������ ���������� ���� � ������� ������ ���������, ��� �������� 0, ���� ������� ������ �����������.
���� flags ������ ��� ����������� ���������. ���� ���� flags ����� �������� 0, ���������� �������������� ���������, � ���� ���� flags ����� �������� RS_HIPRI, ���������� ������������ ���������. ��� �������������� ���������, � ������ ���� ������� �� ������ ������ ���������, ������� I_FDINSERT ������������� � �������� ���������� �����. ��� ������������ ��������� ���������� � ���� ������ �� ����������. ���� ��� ������ ���������� ���� O_NDELAY, �� ��� �������������� ���������, � ������ ���� ������� �� ������ ������ ���������, ������� I_FDINSERT �� �����������, � ����������� �������� � ������������� ���������� errno �������� EAGAIN.
������� I_FDINSERT �������� ��������� ������ �������, � �����, ��� ����������� �� �������������� ��������� � ��������� ����� O_NDELAY, ��������������� � �������� ��������� ������ ��� ��������� � ������ (���� ��� ���� �� ���������� ���������� ��������� ��������).
��� ������� ���������� errno ��������� ���� �� ��������� ��������:
����������� ������� ������������� ��� ������� ����������� ��������� ��� ������������ ������� ��� ��������� ������. ���������� ���������� ���� �� ������ �� ��� ���, ���� �� ���������� ������, ������� �� ���������� � ������ �������� ��������� �����. ������� I_STR ����������� �� ��� ���, ���� �� ������ ���������, �������������� ���������� ������������ �������� ��� ����������� ���, ���� ������� ������������ ������ �������. � ������ ��������� ������� ������� ����������� �������� � ������������� ���������� errno �������� ETIME.
������ ���� ������� I_STR ����� ���� �������� � ������, ��� ����������� ������� I_STR ����������� �� ��� ���, ���� ����� �� �������� ������� I_STR �� ������ �� ������. ����� �������� �� ��������� ����� 15 ��������. ������� ����� O_NDELAY [��. open(2)] � ���� ������� ������������.
�������� arg ������ ��������� �� ��������� ���� struct strioctl:
struct strioctl { int ic_cmd; /* ������� */ int ic_timout; /* ����� �������� */ int ic_len; /* ����� ������ */ char *ic_dp; /* ��������� �� ������ */ };� ���� ic_cmd �������� ���������� �������, ��������������� ������ ��� �������� ������. � ���� ic_timeout �������� ����� ��������: -1 - �����������, 0 - �� ���������, > 0 - ��������� ���������� ������. � ���� ic_len �������� ����� ������������ ������, � � ���� ic_dp - ��������� �� ������. ���� ic_len ������������ ��� ���� �����: �� ����� � ��� �������� ����� ������������ ������, � �� ������ � ���� ������������ ����� ������. �����, �� ������� ��������� ���� ic_dp, ������ ����� ����������� ������ ��� ������ ������ ������ �� ������ ������ ��� �������� ������.
����� ����������� ���������� �� ��������� strioctl � ������ ����������� ������������ ��������� � �������� ��� ��������� ����.
��� ������� ���������� errno ��������� ���� �� ��������� ��������:
������� I_SENDFD ��������� ��������� ��������� ����� � ������������ arg. ����������� ���������, � ������� ������������ ���� ���������, � ����� ������������� ������������ � ������������� ������ ��������, ������������ ������� I_SENDFD. ��������� ���������� ��������������� � ������� �� ������ [��. intro(2)] ������ ������ �� ������ ����� ���������, � ������� ������ ������ �����.
��� ������� ���������� errno ��������� ���� �� ��������� ��������:
struct strrecvfd { int fd; unsigned short uid; unsigned short gid; char fill [8]; };� ���� fd ������������ ���������� �����. � ���� uid � gid - ������������� ������������ � ������������� ������ ��������, ������������ ������� I_SENDFD.
���� ����������� ���� O_NDELAY [��. open(2)], ������� I_RECVFD ����������� �� ��� ���, ���� �� ������ �����-������ ���������. ���� ���� O_NDELAY ������������, � � ������ ��� ������� ���������, ������� I_RECVFD ����������� �������� � ������������� ���������� errno �������� EAGAIN.
���� ���������� ��������� ������������� ������� �������� I_SENDFD, ���������� ����� ���������� �����, ��������� �������� ������� � ���������. ����� ���������� ���������� � ���� fd ��������� ���� strrecvfd, �� ������� ��������� �������� arg.
��� ������� ���������� errno ��������� ���� �� ��������� ��������:
��� ������� ���������� errno ��������� ���� �� ��������� ��������:
��� ������� ���������� errno ��������� ���� �� ��������� ��������:
��. �����
intro(2), close(2), fcntl(2), getmsg(2), ioctl(2),
open(2), poll(2), putmsg(2), read(2), signal(2),
sigset(2), write(2) � ����������� ������������.
�����������
���� �� ��������� ���������, �� � ������ ������ ���������, ������������ ��������� ������� ioctl, ����� 0. �
������ ������� ������������ -1, � ���������� errno
������������� ��� ������.
|