Commit | Line | Data |
---|---|---|
b7ae4728 BJ |
1 | .TH MPXIO 5 |
2 | .SH NAME | |
3 | mpxio \- multiplexed i/o | |
4 | .SH SYNOPSIS | |
5 | .B #include <sys/mx.h> | |
6 | .PP | |
7 | .B #include <sgtty.h> | |
8 | .SH DESCRIPTION | |
9 | Data transfers on | |
10 | mpx files | |
11 | (see | |
12 | .IR mpx (2)) | |
13 | are multiplexed by | |
14 | imposing | |
15 | a record structure on the io stream. | |
16 | Each record represents data | |
17 | from/to | |
18 | a particular channel or | |
19 | a control or status message associated with a particular channel. | |
20 | .PP | |
21 | The prototypical data record read from an mpx file is as follows | |
22 | .PP | |
23 | .in +.5i | |
24 | .nf | |
25 | struct input_record { | |
26 | short index; | |
27 | short count; | |
28 | short ccount; | |
29 | char data[]; | |
30 | }; | |
31 | .PP | |
32 | .fi | |
33 | where | |
34 | .I index | |
35 | identifies the channel, | |
36 | and | |
37 | .I count | |
38 | specifies the number of characters in | |
39 | .I data. | |
40 | If | |
41 | .I count | |
42 | is zero, | |
43 | .I ccount | |
44 | gives the size of | |
45 | .I data, | |
46 | and the record is a control or status message. | |
47 | Although | |
48 | .I count | |
49 | or | |
50 | .I ccount | |
51 | might be odd, | |
52 | the operating system aligns records | |
53 | on short (i.e. 16\-bit) boundaries | |
54 | by skipping bytes when necessary. | |
55 | .PP | |
56 | Data written to an mpx file must be formatted as an array | |
57 | of record structures defined as follows | |
58 | .PP | |
59 | .in +.5i | |
60 | .nf | |
61 | struct output_record { | |
62 | short index; | |
63 | short count; | |
64 | short ccount; | |
65 | char *data; | |
66 | }; | |
67 | .fi | |
68 | .PP | |
69 | where the data portion of the record is referred | |
70 | to indirectly and the other cells have the same interpretation | |
71 | as in | |
72 | .I input_record. | |
73 | .PP | |
74 | The | |
75 | control messages listed below may be read from | |
76 | a multiplexed file descriptor. | |
77 | They are presented as two 16-bit integers: | |
78 | the first number is the message code | |
79 | (defined in | |
80 | .IR <sys/mx.h> ), | |
81 | the second is an optional parameter meaningful | |
82 | only with M_WATCH, M_BLK, and M_SIG. | |
83 | .PP | |
84 | .in +1i | |
85 | .ti -.5i | |
86 | M_WATCH \- a process `wants to attach' on this channel. | |
87 | The second parameter is the 16-bit | |
88 | user-id of the process that executed the open. | |
89 | .br | |
90 | .ti -.5i | |
91 | M_CLOSE \- the channel is closed. | |
92 | This message is generated when the last | |
93 | file descriptor referencing | |
94 | a channel is closed. | |
95 | The | |
96 | .I detach | |
97 | command | |
98 | (see | |
99 | .IR mpx (2) | |
100 | should be used in response to this message. | |
101 | .br | |
102 | .ti -.5i | |
103 | M_EOT \- indicates logical end of file on a channel. | |
104 | If the channel is joined to a typewriter, | |
105 | EOT (control-d) | |
106 | will cause the M_EOT message | |
107 | under the conditions specified in | |
108 | .IR tty (4) | |
109 | for end of file. | |
110 | If the channel is attached to a process, | |
111 | M_EOT will be generated whenever the process | |
112 | writes zero bytes on the channel. | |
113 | .br | |
114 | .ti -.5i | |
115 | M_BLK \- if non-blocking mode has been enabled on an | |
116 | mpx file descriptor | |
117 | .I xd | |
118 | by executing | |
119 | .IR "ioctl(xd, MXNBLK, 0)" , | |
120 | write operations on the file are truncated in the kernel | |
121 | when internal queues become full. | |
122 | This is done on a per-channel basis: | |
123 | the parameter | |
124 | is a count of the number of characters | |
125 | not transferred to the channel on which | |
126 | M_BLK is received. | |
127 | .br | |
128 | .ti -.5i | |
129 | M_UBLK \- is generated for a channel | |
130 | after M_BLK when the internal queues have | |
131 | drained below a threshold. | |
132 | .br | |
133 | .ti -.5i | |
134 | M_SIG \- is generated instead of a normal asynchronous | |
135 | signal on channels that are joined to typewriters. | |
136 | The parameter is the signal number. | |
137 | .in -1i | |
138 | .PP | |
139 | Two other messages may be generated by the kernel. | |
140 | As with other messages, the first | |
141 | 16-bit quantity is the message code. | |
142 | .PP | |
143 | .in +1i | |
144 | .ti -.5i | |
145 | M_OPEN \- is generated in conjunction with | |
146 | `listener' mode (see | |
147 | .IR mpx (2)). | |
148 | The uid of the calling process follows the message code | |
149 | as with M_WATCH. | |
150 | This is followed by a null-terminated string | |
151 | which is the name of the file being opened. | |
152 | .br | |
153 | .ti -.5i | |
154 | M_IOCTL \- is generated for a channel connected | |
155 | to a process | |
156 | when that process executes the | |
157 | .I "ioctl(fd, cmd, &vec)" | |
158 | call on the channel file descriptor. | |
159 | The M_IOCTL code is followed by | |
160 | the | |
161 | .I cmd | |
162 | argument given to | |
163 | .I ioctl | |
164 | followed by | |
165 | the contents of the structure | |
166 | .I vec. | |
167 | It is assumed, | |
168 | not needing a better compromise at this time, | |
169 | that the length of | |
170 | .I vec | |
171 | is determined by | |
172 | .I "sizeof (struct sgttyb)" | |
173 | as declared in | |
174 | .IR <sgtty.h> . | |
175 | .in -1i | |
176 | .PP | |
177 | Two control messages are understood by the operating system. | |
178 | M_EOT may be sent through an mpx file to a channel. | |
179 | It is equivalent to propagating a zero-length record | |
180 | through the channel; | |
181 | i.e. the channel is allowed to drain and the process or | |
182 | device at the other end receives a zero-length | |
183 | transfer before data starts flowing through the channel again. | |
184 | M_IOCTL can also be sent through a channel. | |
185 | The format is identical to that described above. |