xref: /illumos-gate/usr/src/uts/common/sys/stropts.h (revision e4d060fb4c00d44cd578713eb9a921f594b733b8)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
22 /*	  All Rights Reserved  	*/
23 
24 
25 /*
26  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
27  * Use is subject to license terms.
28  */
29 
30 #ifndef _SYS_STROPTS_H
31 #define	_SYS_STROPTS_H
32 
33 #pragma ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 11.20	*/
34 
35 #include <sys/feature_tests.h>
36 #include <sys/types.h>
37 /*
38  * For FMNAMESZ define.
39  */
40 #include <sys/conf.h>
41 
42 #ifdef	__cplusplus
43 extern "C" {
44 #endif
45 
46 /*
47  * Write options
48  */
49 #define	SNDZERO		0x001		/* send a zero length message */
50 #define	SNDPIPE		0x002		/* send SIGPIPE on write and */
51 					/* putmsg if sd_werror is set */
52 
53 /*
54  * Read options
55  */
56 #define	RNORM		0x000		/* read msg norm */
57 #define	RMSGD		0x001		/* read msg discard */
58 #define	RMSGN		0x002		/* read msg no discard */
59 
60 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
61 #define	RMODEMASK	0x003		/* all above bits */
62 #endif
63 
64 /*
65  * These next three read options are added for the sake of
66  * user-level transparency.  RPROTDAT will cause the stream head
67  * to treat the contents of M_PROTO and M_PCPROTO message blocks
68  * as data.  RPROTDIS will prevent the stream head from failing
69  * a read with EBADMSG if an M_PROTO or M_PCPROTO message is on
70  * the front of the stream head read queue.  Rather, the protocol
71  * blocks will be silently discarded and the data associated with
72  * the message (in linked M_DATA blocks), if any, will be delivered
73  * to the user.  RPROTNORM sets the default behavior, where read
74  * will fail with EBADMSG if an M_PROTO or M_PCPROTO are at the
75  * stream head.
76  */
77 #define	RPROTDAT	0x004		/* read protocol messages as data */
78 #define	RPROTDIS	0x008		/* discard protocol messages, but */
79 					/* read data portion */
80 #define	RPROTNORM	0x010
81 
82 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
83 #define	RPROTMASK	0x01c		/* all RPROT bits */
84 
85 /*
86  * The next read option is used so that a TPI aware module can tell the
87  * stream head to not flush M_PCPROTO messages when processing a read side
88  * flush. This will avoid problems where a flush removes a T_OK_ACK.
89  */
90 #define	RFLUSHMASK	0x020		/* all RFLUSH bits */
91 
92 #define	RFLUSHPCPROT	0x020		/* do not flush PCPROTOs */
93 
94 #endif
95 
96 /*
97  * Error options
98  */
99 
100 /*
101  * Error options to adjust the stream head error behavior with respect
102  * to M_ERROR message for read and write side errors respectively.
103  * The normal case is that the read/write side error is
104  * persistent and these options allow the application or streams module/driver
105  * to specify that errors are nonpersistent. In this case the error is cleared
106  * after having been returned to read(), getmsg(), ioctl(), write(), putmsg(),
107  * etc.
108  */
109 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
110 #define	RERRNORM	0x001		/* Normal, persistent read errors */
111 #define	RERRNONPERSIST	0x002		/* Nonpersistent read errors */
112 
113 #define	RERRMASK	(RERRNORM|RERRNONPERSIST)
114 
115 #define	WERRNORM	0x004		/* Normal, persistent write errors */
116 #define	WERRNONPERSIST	0x008		/* Nonpersistent write errors */
117 
118 #define	WERRMASK	(WERRNORM|WERRNONPERSIST)
119 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
120 
121 /*
122  * Flush options
123  */
124 
125 #define	FLUSHR		0x01		/* flush read queue */
126 #define	FLUSHW		0x02		/* flush write queue */
127 #define	FLUSHRW		0x03		/* flush both queues */
128 #define	FLUSHBAND	0x04		/* flush only band specified */
129 					/* in next byte */
130 /*
131  * Copy options for M_SETOPS/SO_COPYOPT
132  */
133 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
134 #define	ZCVMSAFE	0x01		/* safe to borrow file (segmapped) */
135 					/* pages instead of bcopy */
136 #define	ZCVMUNSAFE	0x02		/* unsafe to borrow file pages */
137 #define	COPYCACHED	0x04		/* copy should NOT bypass cache */
138 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
139 
140 /*
141  * Events for which the SIGPOLL signal is to be sent.
142  */
143 #define	S_INPUT		0x0001		/* any msg but hipri on read Q */
144 #define	S_HIPRI		0x0002		/* high priority msg on read Q */
145 #define	S_OUTPUT	0x0004		/* write Q no longer full */
146 #define	S_MSG		0x0008		/* signal msg at front of read Q */
147 #define	S_ERROR		0x0010		/* error msg arrived at stream head */
148 #define	S_HANGUP	0x0020		/* hangup msg arrived at stream head */
149 #define	S_RDNORM	0x0040		/* normal msg on read Q */
150 #define	S_WRNORM	S_OUTPUT
151 #define	S_RDBAND	0x0080		/* out of band msg on read Q */
152 #define	S_WRBAND	0x0100		/* can write out of band */
153 #define	S_BANDURG	0x0200		/* modifier to S_RDBAND, to generate */
154 					/* SIGURG instead of SIGPOLL */
155 
156 /*
157  * Flags for getmsg() and putmsg() syscall arguments.
158  * "RS" stands for recv/send.  The system calls were originally called
159  * recv() and send(), but were renamed to avoid confusion with the BSD
160  * calls of the same name.  A value of zero will cause getmsg() to return
161  * the first message on the stream head read queue and putmsg() to send
162  * a normal priority message.
163  *
164  * Flags for strmakemsg() arguments (should define strmakemsg() flags).
165  * Used to determine the message type of the control part of a message,
166  * if RS_HIPRI, M_PCPROTO, else M_PROTO.
167  */
168 
169 #define	RS_HIPRI	0x01		/* send/recv high priority message */
170 #define	STRUIO_POSTPONE	0x08		/* postpone copyin() for struio() */
171 
172 /*
173  * Flags for getpmsg() and putpmsg() syscall arguments.
174  */
175 
176 /*
177  * These are settable by the user and will be set on return
178  * to indicate the priority of message received.
179  */
180 #define	MSG_HIPRI	0x01		/* send/recv high priority message */
181 #define	MSG_ANY		0x02		/* recv any messages */
182 #define	MSG_BAND	0x04		/* recv messages from specified band */
183 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
184 /*
185  * This is a private flag passed by libc to kernel to
186  * identify that it is a XPG4_2 application. No
187  * applications need to know about this flag.
188  */
189 #define	MSG_XPG4	0x08
190 #endif
191 
192 #ifdef _KERNEL
193 
194 /*
195  * Additional private flags for kstrgetmsg and kstrputmsg.
196  * These must be bit-wise distinct from the above MSG flags.
197  */
198 #define	MSG_IPEEK	0x10		/* Peek - don't remove the message */
199 #define	MSG_DISCARDTAIL	0x20		/* Discard tail if it doesn't fit */
200 #define	MSG_HOLDSIG	0x40		/* Ignore signals. */
201 #define	MSG_IGNERROR	0x80		/* Ignore stream head errors */
202 #define	MSG_DELAYERROR	0x100		/* Delay error check until we sleep */
203 #define	MSG_IGNFLOW	0x200		/* Ignore flow control */
204 #define	MSG_NOMARK	0x400		/* Do not read if message is marked */
205 
206 #endif /* _KERNEL */
207 
208 /*
209  * Flags returned as value of getmsg() and getpmsg() syscall.
210  */
211 #define	MORECTL		1		/* more ctl info is left in message */
212 #define	MOREDATA	2		/* more data is left in message */
213 
214 /*
215  * Define to indicate that all multiplexors beneath a stream should
216  * be unlinked.
217  */
218 #define	MUXID_ALL	(-1)
219 
220 /*
221  * Flag definitions for the I_ATMARK ioctl.
222  */
223 #define	ANYMARK		0x01
224 #define	LASTMARK	0x02
225 
226 /*
227  *  Stream Ioctl defines
228  */
229 #define	STR		('S'<<8)
230 /* (STR|000) in use */
231 #define	I_NREAD		(STR|01)
232 #define	I_PUSH		(STR|02)
233 #define	I_POP		(STR|03)
234 #define	I_LOOK		(STR|04)
235 #define	I_FLUSH		(STR|05)
236 #define	I_SRDOPT	(STR|06)
237 #define	I_GRDOPT	(STR|07)
238 #define	I_STR		(STR|010)
239 #define	I_SETSIG	(STR|011)
240 #define	I_GETSIG	(STR|012)
241 #define	I_FIND		(STR|013)
242 #define	I_LINK		(STR|014)
243 #define	I_UNLINK	(STR|015)
244 /* (STR|016) in use */
245 #define	I_PEEK		(STR|017)
246 #define	I_FDINSERT	(STR|020)
247 #define	I_SENDFD	(STR|021)
248 
249 #if defined(_KERNEL)
250 #define	I_RECVFD	(STR|022)
251 #define	I_E_RECVFD	(STR|016)
252 #else	/* user level definition */
253 #define	I_RECVFD	(STR|016)	/* maps to kernel I_E_RECVFD */
254 #endif /* defined(_KERNEL) */
255 
256 #define	I_SWROPT	(STR|023)
257 #define	I_GWROPT	(STR|024)
258 #define	I_LIST		(STR|025)
259 #define	I_PLINK		(STR|026)
260 #define	I_PUNLINK	(STR|027)
261 #define	I_ANCHOR	(STR|030)
262 #define	I_FLUSHBAND	(STR|034)
263 #define	I_CKBAND	(STR|035)
264 #define	I_GETBAND	(STR|036)
265 #define	I_ATMARK	(STR|037)
266 #define	I_SETCLTIME	(STR|040)
267 #define	I_GETCLTIME	(STR|041)
268 #define	I_CANPUT	(STR|042)
269 #define	I_SERROPT	(STR|043)
270 #define	I_GERROPT	(STR|044)
271 #define	I_ESETSIG	(STR|045)
272 #define	I_EGETSIG	(STR|046)
273 
274 #define	__I_PUSH_NOCTTY	(STR|047)	/* push module, no cntrl tty */
275 
276 /*
277  * IOCTLs (STR|050) - (STR|055) are available for use.
278  */
279 
280 #define	_I_MUXID2FD	(STR|056)	/* Private: get a fd from a muxid */
281 #define	_I_INSERT	(STR|057)	/* Private: insert a module */
282 #define	_I_REMOVE	(STR|060)	/* Private: remove a module */
283 #define	_I_GETPEERCRED	(STR|061)	/* Private: get peer cred */
284 #define	_I_PLINK_LH	(STR|062)	/* Private: Layered Driver ioctl */
285 #define	_I_CMD		(STR|063) 	/* Private: send ioctl via M_CMD */
286 
287 /*
288  * User level ioctl format for ioctls that go downstream (I_STR)
289  */
290 struct strioctl {
291 	int 	ic_cmd;			/* command */
292 	int	ic_timout;		/* timeout value */
293 	int	ic_len;			/* length of data */
294 	char	*ic_dp;			/* pointer to data */
295 };
296 
297 #if defined(_SYSCALL32)
298 
299 struct strioctl32 {
300 	int32_t 	ic_cmd;			/* command */
301 	int32_t		ic_timout;		/* timeout value */
302 	int32_t		ic_len;			/* length of data */
303 	caddr32_t	ic_dp;			/* pointer to data */
304 };
305 
306 #endif /* _SYSCALL32 */
307 
308 /*
309  * Value for timeouts (ioctl, select) that denotes infinity
310  */
311 #define	_INFTIM		-1
312 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
313 #define	INFTIM		_INFTIM
314 #endif
315 
316 #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
317 /*
318  * For _I_CMD: similar to strioctl, but with included buffer (to avoid copyin/
319  * copyout from another address space).  NOTE: the size of this structure must
320  * be less than libproc.h`MAXARGL for pr_ioctl() to handle it.
321  */
322 #define	STRCMDBUFSIZE			2048
323 typedef struct strcmd {
324 	int 	sc_cmd;			/* ioctl command */
325 	int	sc_timeout;		/* timeout value (in seconds) */
326 	int	sc_len;			/* length of data */
327 	int	sc_pad;
328 	char	sc_buf[STRCMDBUFSIZE];	/* data buffer */
329 } strcmd_t;
330 #endif
331 
332 /*
333  * Stream buffer structure for putmsg and getmsg system calls
334  */
335 struct strbuf {
336 	int	maxlen;		/* no. of bytes in buffer */
337 	int	len;		/* no. of bytes returned */
338 	caddr_t	buf;		/* pointer to data */
339 };
340 
341 #if defined(_SYSCALL32)
342 
343 struct strbuf32 {
344 	int32_t	maxlen;		/* no. of bytes in buffer */
345 	int32_t	len;		/* no. of bytes returned */
346 	caddr32_t buf;		/* pointer to data */
347 };
348 #endif /* _SYSCALL32 */
349 
350 /*
351  * Stream I_PEEK ioctl format
352  */
353 struct strpeek {
354 	struct strbuf	ctlbuf;
355 	struct strbuf	databuf;
356 	t_uscalar_t	flags;
357 };
358 
359 #if defined(_SYSCALL32)
360 
361 struct strpeek32 {
362 	struct strbuf32	ctlbuf;
363 	struct strbuf32	databuf;
364 	uint32_t	flags;
365 };
366 
367 #endif /* _SYSCALL32 */
368 
369 /*
370  * Stream I_FDINSERT ioctl format
371  */
372 struct strfdinsert {
373 	struct strbuf	ctlbuf;
374 	struct strbuf	databuf;
375 	t_uscalar_t	flags;
376 	int		fildes;
377 	int		offset;
378 };
379 
380 #if defined(_SYSCALL32)
381 
382 struct strfdinsert32 {
383 	struct strbuf32	ctlbuf;
384 	struct strbuf32	databuf;
385 	uint32_t	flags;
386 	int32_t		fildes;
387 	int32_t		offset;
388 };
389 
390 #endif /* _SYSCALL32 */
391 
392 /*
393  * Receive file descriptor structure
394  */
395 #if defined(_KERNEL)
396 
397 struct o_strrecvfd {	/* SVR3 syscall structure */
398 	int fd;
399 	o_uid_t uid;		/* always ushort */
400 	o_gid_t gid;
401 	char fill[8];
402 };
403 
404 /*
405  * Although EFT is enabled in the kernel we kept the following definition
406  * to support an EFT application on a 4.0 non-EFT system.
407  */
408 struct k_strrecvfd {	/* SVR4 expanded syscall interface structure */
409 	struct file *fp;
410 	uid_t uid;
411 	gid_t gid;
412 	char fill[8];
413 };
414 
415 /*
416  * Private _I_GETPEERCRED data.
417  */
418 
419 typedef struct k_peercred {
420 	cred_t	*pc_cr;
421 	pid_t	pc_cpid;
422 } k_peercred_t;
423 
424 #endif	/* defined(_KERNEL) */
425 
426 struct strrecvfd {
427 	int fd;
428 	uid_t uid;
429 	gid_t gid;
430 #if defined(_XPG4_2)
431 	char __fill[8];
432 #else
433 	char fill[8];
434 #endif
435 };
436 
437 
438 /*
439  * For I_LIST ioctl.
440  */
441 struct str_mlist {
442 	char l_name[FMNAMESZ+1];
443 };
444 
445 struct str_list {
446 	int sl_nmods;
447 	struct str_mlist *sl_modlist;
448 };
449 
450 #if defined(_SYSCALL32)
451 
452 struct str_list32 {
453 	int32_t 	sl_nmods;
454 	caddr32_t 	sl_modlist;
455 };
456 
457 #endif /* _SYSCALL32 */
458 
459 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
460 /*
461  * Private, for _I_INSERT/_I_REMOVE ioctl.
462  */
463 struct strmodconf {
464 	int	pos;			/* Position to be inserted/removed. */
465 	caddr_t	mod_name;		/* Name of module. */
466 };
467 
468 #if defined(_SYSCALL32)
469 
470 struct strmodconf32 {
471 	int32_t		pos;
472 	caddr32_t	mod_name;
473 };
474 
475 #endif /* _SYSCALL32 */
476 #endif /* (_XPG4_2) || defined(__EXTENSIONS__) */
477 
478 /*
479  * For I_FLUSHBAND ioctl.  Describes the priority
480  * band for which the operation applies.
481  */
482 struct bandinfo {
483 	unsigned char	bi_pri;
484 	int		bi_flag;
485 };
486 
487 
488 /*
489  * The argument for I_ESETSIG and I_EGETSIG ioctls.
490  */
491 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
492 struct strsigset {
493 	pid_t		ss_pid;		/* pgrp if negative */
494 	int		ss_events;	/* S_ events */
495 };
496 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
497 
498 #ifdef	_XPG4_2
499 #ifdef	__PRAGMA_REDEFINE_EXTNAME
500 
501 #pragma	redefine_extname putmsg		__xpg4_putmsg
502 #pragma	redefine_extname putpmsg	__xpg4_putpmsg
503 
504 #else	/* __PRAGMA_REDEFINE_EXTNAME */
505 
506 #define	putmsg	__xpg4_putmsg
507 #define	putpmsg	__xpg4_putpmsg
508 
509 #endif	/* __PRAGMA_REDEFINE_EXTNAME */
510 #endif	/* _XPG4_2 */
511 
512 #ifdef	__cplusplus
513 }
514 #endif
515 
516 #endif	/* _SYS_STROPTS_H */
517