docs/how-to-build.md: use proper markup for directory names
[unleashed/tickless.git] / include / sys / stropts.h
blobe6b3e59dee568881eae7ffb2cd55b2b7395a3389
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
21 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
22 /* All Rights Reserved */
26 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
30 #ifndef _SYS_STROPTS_H
31 #define _SYS_STROPTS_H
33 #include <sys/feature_tests.h>
34 #include <sys/types.h>
36 * For FMNAMESZ define.
38 #include <sys/conf.h>
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
45 * Write options
47 #define SNDZERO 0x001 /* send a zero length message */
48 #define SNDPIPE 0x002 /* send SIGPIPE on write and */
49 /* putmsg if sd_werror is set */
52 * Read options
54 #define RNORM 0x000 /* read msg norm */
55 #define RMSGD 0x001 /* read msg discard */
56 #define RMSGN 0x002 /* read msg no discard */
58 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
59 #define RMODEMASK 0x003 /* all above bits */
60 #endif
63 * These next three read options are added for the sake of
64 * user-level transparency. RPROTDAT will cause the stream head
65 * to treat the contents of M_PROTO and M_PCPROTO message blocks
66 * as data. RPROTDIS will prevent the stream head from failing
67 * a read with EBADMSG if an M_PROTO or M_PCPROTO message is on
68 * the front of the stream head read queue. Rather, the protocol
69 * blocks will be silently discarded and the data associated with
70 * the message (in linked M_DATA blocks), if any, will be delivered
71 * to the user. RPROTNORM sets the default behavior, where read
72 * will fail with EBADMSG if an M_PROTO or M_PCPROTO are at the
73 * stream head.
75 #define RPROTDAT 0x004 /* read protocol messages as data */
76 #define RPROTDIS 0x008 /* discard protocol messages, but */
77 /* read data portion */
78 #define RPROTNORM 0x010
80 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
81 #define RPROTMASK 0x01c /* all RPROT bits */
84 * The next read option is used so that a TPI aware module can tell the
85 * stream head to not flush M_PCPROTO messages when processing a read side
86 * flush. This will avoid problems where a flush removes a T_OK_ACK.
88 #define RFLUSHMASK 0x020 /* all RFLUSH bits */
90 #define RFLUSHPCPROT 0x020 /* do not flush PCPROTOs */
92 #endif
95 * Error options
99 * Error options to adjust the stream head error behavior with respect
100 * to M_ERROR message for read and write side errors respectively.
101 * The normal case is that the read/write side error is
102 * persistent and these options allow the application or streams module/driver
103 * to specify that errors are nonpersistent. In this case the error is cleared
104 * after having been returned to read(), getmsg(), ioctl(), write(), putmsg(),
105 * etc.
107 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
108 #define RERRNORM 0x001 /* Normal, persistent read errors */
109 #define RERRNONPERSIST 0x002 /* Nonpersistent read errors */
111 #define RERRMASK (RERRNORM|RERRNONPERSIST)
113 #define WERRNORM 0x004 /* Normal, persistent write errors */
114 #define WERRNONPERSIST 0x008 /* Nonpersistent write errors */
116 #define WERRMASK (WERRNORM|WERRNONPERSIST)
117 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
120 * Flush options
123 #define FLUSHR 0x01 /* flush read queue */
124 #define FLUSHW 0x02 /* flush write queue */
125 #define FLUSHRW 0x03 /* flush both queues */
126 #define FLUSHBAND 0x04 /* flush only band specified */
127 /* in next byte */
129 * Copy options for M_SETOPS/SO_COPYOPT
131 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
132 #define ZCVMSAFE 0x01 /* safe to borrow file (segmapped) */
133 /* pages instead of bcopy */
134 #define ZCVMUNSAFE 0x02 /* unsafe to borrow file pages */
135 #define COPYCACHED 0x04 /* copy should NOT bypass cache */
136 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
139 * Events for which the SIGPOLL signal is to be sent.
141 #define S_INPUT 0x0001 /* any msg but hipri on read Q */
142 #define S_HIPRI 0x0002 /* high priority msg on read Q */
143 #define S_OUTPUT 0x0004 /* write Q no longer full */
144 #define S_MSG 0x0008 /* signal msg at front of read Q */
145 #define S_ERROR 0x0010 /* error msg arrived at stream head */
146 #define S_HANGUP 0x0020 /* hangup msg arrived at stream head */
147 #define S_RDNORM 0x0040 /* normal msg on read Q */
148 #define S_WRNORM S_OUTPUT
149 #define S_RDBAND 0x0080 /* out of band msg on read Q */
150 #define S_WRBAND 0x0100 /* can write out of band */
151 #define S_BANDURG 0x0200 /* modifier to S_RDBAND, to generate */
152 /* SIGURG instead of SIGPOLL */
155 * Flags for getmsg() and putmsg() syscall arguments.
156 * "RS" stands for recv/send. The system calls were originally called
157 * recv() and send(), but were renamed to avoid confusion with the BSD
158 * calls of the same name. A value of zero will cause getmsg() to return
159 * the first message on the stream head read queue and putmsg() to send
160 * a normal priority message.
162 * Flags for strmakemsg() arguments (should define strmakemsg() flags).
163 * Used to determine the message type of the control part of a message,
164 * if RS_HIPRI, M_PCPROTO, else M_PROTO.
167 #define RS_HIPRI 0x01 /* send/recv high priority message */
168 #define STRUIO_POSTPONE 0x08 /* postpone copyin() for struio() */
171 * Flags for getpmsg() and putpmsg() syscall arguments.
175 * These are settable by the user and will be set on return
176 * to indicate the priority of message received.
178 #define MSG_HIPRI 0x01 /* send/recv high priority message */
179 #define MSG_ANY 0x02 /* recv any messages */
180 #define MSG_BAND 0x04 /* recv messages from specified band */
181 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
183 * This is a private flag passed by libc to kernel to
184 * identify that it is a XPG4_2 application. No
185 * applications need to know about this flag.
187 #define MSG_XPG4 0x08
188 #endif
190 #ifdef _KERNEL
193 * Additional private flags for kstrgetmsg and kstrputmsg.
194 * These must be bit-wise distinct from the above MSG flags.
196 #define MSG_IPEEK 0x10 /* Peek - don't remove the message */
197 #define MSG_DISCARDTAIL 0x20 /* Discard tail if it doesn't fit */
198 #define MSG_HOLDSIG 0x40 /* Ignore signals. */
199 #define MSG_IGNERROR 0x80 /* Ignore stream head errors */
200 #define MSG_DELAYERROR 0x100 /* Delay error check until we sleep */
201 #define MSG_IGNFLOW 0x200 /* Ignore flow control */
202 #define MSG_NOMARK 0x400 /* Do not read if message is marked */
204 #endif /* _KERNEL */
207 * Flags returned as value of getmsg() and getpmsg() syscall.
209 #define MORECTL 1 /* more ctl info is left in message */
210 #define MOREDATA 2 /* more data is left in message */
213 * Define to indicate that all multiplexors beneath a stream should
214 * be unlinked.
216 #define MUXID_ALL (-1)
219 * Flag definitions for the I_ATMARK ioctl.
221 #define ANYMARK 0x01
222 #define LASTMARK 0x02
225 * Stream Ioctl defines
227 #define STR ('S'<<8)
228 /* (STR|000) in use */
229 #define I_NREAD (STR|01)
230 #define I_PUSH (STR|02)
231 #define I_POP (STR|03)
232 #define I_LOOK (STR|04)
233 #define I_FLUSH (STR|05)
234 #define I_SRDOPT (STR|06)
235 #define I_GRDOPT (STR|07)
236 #define I_STR (STR|010)
237 #define I_SETSIG (STR|011)
238 #define I_GETSIG (STR|012)
239 #define I_FIND (STR|013)
240 #define I_LINK (STR|014)
241 #define I_UNLINK (STR|015)
242 /* (STR|016) in use */
243 #define I_PEEK (STR|017)
244 #define I_FDINSERT (STR|020)
245 #define I_SENDFD (STR|021)
247 #if defined(_KERNEL)
248 #define I_RECVFD (STR|022)
249 #define I_E_RECVFD (STR|016)
250 #else /* user level definition */
251 #define I_RECVFD (STR|016) /* maps to kernel I_E_RECVFD */
252 #endif /* defined(_KERNEL) */
254 #define I_SWROPT (STR|023)
255 #define I_GWROPT (STR|024)
256 #define I_LIST (STR|025)
257 #define I_PLINK (STR|026)
258 #define I_PUNLINK (STR|027)
259 #define I_ANCHOR (STR|030)
260 #define I_FLUSHBAND (STR|034)
261 #define I_CKBAND (STR|035)
262 #define I_GETBAND (STR|036)
263 #define I_ATMARK (STR|037)
264 #define I_SETCLTIME (STR|040)
265 #define I_GETCLTIME (STR|041)
266 #define I_CANPUT (STR|042)
267 #define I_SERROPT (STR|043)
268 #define I_GERROPT (STR|044)
269 #define I_ESETSIG (STR|045)
270 #define I_EGETSIG (STR|046)
272 #define __I_PUSH_NOCTTY (STR|047) /* push module, no cntrl tty */
275 * IOCTLs (STR|050) - (STR|055) are available for use.
278 #define _I_MUXID2FD (STR|056) /* Private: get a fd from a muxid */
279 #define _I_INSERT (STR|057) /* Private: insert a module */
280 #define _I_REMOVE (STR|060) /* Private: remove a module */
281 #define _I_GETPEERCRED (STR|061) /* Private: get peer cred */
282 #define _I_PLINK_LH (STR|062) /* Private: Layered Driver ioctl */
283 #define _I_CMD (STR|063) /* Private: send ioctl via M_CMD */
286 * User level ioctl format for ioctls that go downstream (I_STR)
288 struct strioctl {
289 int ic_cmd; /* command */
290 int ic_timout; /* timeout value */
291 int ic_len; /* length of data */
292 char *ic_dp; /* pointer to data */
295 #if defined(_SYSCALL32)
297 struct strioctl32 {
298 int32_t ic_cmd; /* command */
299 int32_t ic_timout; /* timeout value */
300 int32_t ic_len; /* length of data */
301 caddr32_t ic_dp; /* pointer to data */
304 #endif /* _SYSCALL32 */
307 * Value for timeouts (ioctl, select) that denotes infinity
309 #define _INFTIM -1
310 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
311 #define INFTIM _INFTIM
312 #endif
314 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
316 * For _I_CMD: similar to strioctl, but with included buffer (to avoid copyin/
317 * copyout from another address space). NOTE: the size of this structure must
318 * be less than libproc.h`MAXARGL for pr_ioctl() to handle it.
320 #define STRCMDBUFSIZE 2048
321 typedef struct strcmd {
322 int sc_cmd; /* ioctl command */
323 int sc_timeout; /* timeout value (in seconds) */
324 int sc_len; /* length of data */
325 int sc_pad;
326 char sc_buf[STRCMDBUFSIZE]; /* data buffer */
327 } strcmd_t;
328 #endif
331 * Stream buffer structure for putmsg and getmsg system calls
333 struct strbuf {
334 int maxlen; /* no. of bytes in buffer */
335 int len; /* no. of bytes returned */
336 caddr_t buf; /* pointer to data */
339 #if defined(_SYSCALL32)
341 struct strbuf32 {
342 int32_t maxlen; /* no. of bytes in buffer */
343 int32_t len; /* no. of bytes returned */
344 caddr32_t buf; /* pointer to data */
346 #endif /* _SYSCALL32 */
349 * Stream I_PEEK ioctl format
351 struct strpeek {
352 struct strbuf ctlbuf;
353 struct strbuf databuf;
354 t_uscalar_t flags;
357 #if defined(_SYSCALL32)
359 struct strpeek32 {
360 struct strbuf32 ctlbuf;
361 struct strbuf32 databuf;
362 uint32_t flags;
365 #endif /* _SYSCALL32 */
368 * Stream I_FDINSERT ioctl format
370 struct strfdinsert {
371 struct strbuf ctlbuf;
372 struct strbuf databuf;
373 t_uscalar_t flags;
374 int fildes;
375 int offset;
378 #if defined(_SYSCALL32)
380 struct strfdinsert32 {
381 struct strbuf32 ctlbuf;
382 struct strbuf32 databuf;
383 uint32_t flags;
384 int32_t fildes;
385 int32_t offset;
388 #endif /* _SYSCALL32 */
391 * Receive file descriptor structure
393 #if defined(_KERNEL)
395 struct o_strrecvfd { /* SVR3 syscall structure */
396 int fd;
397 o_uid_t uid; /* always ushort */
398 o_gid_t gid;
399 char fill[8];
403 * Although EFT is enabled in the kernel we kept the following definition
404 * to support an EFT application on a 4.0 non-EFT system.
406 struct k_strrecvfd { /* SVR4 expanded syscall interface structure */
407 struct file *fp;
408 uid_t uid;
409 gid_t gid;
410 char fill[8];
414 * Private _I_GETPEERCRED data.
417 typedef struct k_peercred {
418 cred_t *pc_cr;
419 pid_t pc_cpid;
420 } k_peercred_t;
422 #endif /* defined(_KERNEL) */
424 struct strrecvfd {
425 int fd;
426 uid_t uid;
427 gid_t gid;
428 #if defined(_XPG4_2)
429 char __fill[8];
430 #else
431 char fill[8];
432 #endif
437 * For I_LIST ioctl.
439 struct str_mlist {
440 char l_name[FMNAMESZ+1];
443 struct str_list {
444 int sl_nmods;
445 struct str_mlist *sl_modlist;
448 #if defined(_SYSCALL32)
450 struct str_list32 {
451 int32_t sl_nmods;
452 caddr32_t sl_modlist;
455 #endif /* _SYSCALL32 */
457 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
459 * Private, for _I_INSERT/_I_REMOVE ioctl.
461 struct strmodconf {
462 int pos; /* Position to be inserted/removed. */
463 caddr_t mod_name; /* Name of module. */
466 #if defined(_SYSCALL32)
468 struct strmodconf32 {
469 int32_t pos;
470 caddr32_t mod_name;
473 #endif /* _SYSCALL32 */
474 #endif /* (_XPG4_2) || defined(__EXTENSIONS__) */
477 * For I_FLUSHBAND ioctl. Describes the priority
478 * band for which the operation applies.
480 struct bandinfo {
481 unsigned char bi_pri;
482 int bi_flag;
487 * The argument for I_ESETSIG and I_EGETSIG ioctls.
489 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
490 struct strsigset {
491 pid_t ss_pid; /* pgrp if negative */
492 int ss_events; /* S_ events */
494 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
496 #ifdef _XPG4_2
497 #ifdef __PRAGMA_REDEFINE_EXTNAME
499 #pragma redefine_extname putmsg __xpg4_putmsg
500 #pragma redefine_extname putpmsg __xpg4_putpmsg
502 #else /* __PRAGMA_REDEFINE_EXTNAME */
504 #define putmsg __xpg4_putmsg
505 #define putpmsg __xpg4_putpmsg
507 #endif /* __PRAGMA_REDEFINE_EXTNAME */
508 #endif /* _XPG4_2 */
510 #ifdef __cplusplus
512 #endif
514 #endif /* _SYS_STROPTS_H */