streamio.c revision ca9327a6de44d69ddab3668cc1e143ce781387a3
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/sysmacros.h>
#include <sys/netstack.h>
#include <sys/priocntl.h>
#include <sys/strredir.h>
#include <sys/vuid_event.h>
#include <sys/sunldi_impl.h>
#include <sys/autoconf.h>
/*
* This define helps improve the readability of streams code while
* still maintaining a very old streams performance enhancement. The
* performance enhancement basically involved having all callers
* of straccess() perform the first check that straccess() will do
* locally before actually calling straccess(). (There by reducing
* the number of unnecessary calls to straccess().)
*/
straccess((x), (y)))
/*
* what is mblk_pull_len?
*
* If a streams message consists of many short messages,
* a performance degradation occurs from copyout overhead.
* To decrease the per mblk overhead, messages that are
* likely to consist of many small mblks are pulled up into
* one continuous chunk of memory.
*
* To avoid the processing overhead of examining every
* mblk, a quick heuristic is used. If the first mblk in
* the message is shorter than mblk_pull_len, it is likely
* that the rest of the mblk will be short.
*
* This heuristic was decided upon after performance tests
* indicated that anything more complex slowed down the main
* code path.
*/
#define MBLK_PULL_LEN 64
/*
* The sgttyb_handling flag controls the handling of the old BSD
* TIOCGETP, TIOCSETP, and TIOCSETN ioctls as follows:
*
* 0 - Emit no warnings at all and retain old, broken behavior.
* 1 - Emit no warnings and silently handle new semantics.
* 2 - Send cmn_err(CE_NOTE) when either TIOCSETP or TIOCSETN is used
* (once per system invocation). Handle with new semantics.
* 3 - Send SIGSYS when any TIOCGETP, TIOCSETP, or TIOCSETN call is
* made (so that offenders drop core and are easy to debug).
*
* The "new semantics" are that TIOCGETP returns B38400 for
* sg_[io]speed if the corresponding value is over B38400, and that
* TIOCSET[PN] accept B38400 in these cases to mean "retain current
* bit rate."
*/
int sgttyb_handling = 1;
static boolean_t sgttyb_complaint;
/* don't push drcompat module by default on Style-2 streams */
static int push_drcompat = 0;
/*
* id value used to distinguish between different ioctl messages
*/
static void strcleanall(struct vnode *);
/*
* qinit and module_info structures for stream head read and write queues
*/
FIFOLOWAT };
/*
* Stream head locking notes:
* There are four monitors associated with the stream head:
* 1. v_stream monitor: in stropen() and strclose() v_lock
* is held while the association of vnode and stream
* head is established or tested for.
* thread bids for exclusive access to this monitor
* for opening or closing a stream. In addition, this
* monitor is entered during pushes and pops. This
* guarantees that during plumbing operations there
* is only one thread trying to change the plumbing.
* Any other threads present in the stream are only
* using the plumbing.
* sd_lock while trying to get data from the stream
* head queue. if there is none to fulfill a read
* request, it sets RSLEEP and calls cv_wait_sig() down
* in strwaitq() to await the arrival of new data.
* when new data arrives in strrput(), sd_lock is acquired
* before testing for RSLEEP and calling cv_broadcast().
* the behavior of strwrite(), strwsrv(), and WSLEEP
* mirror this.
* 4. ioctl monitor: sd_lock is gotten to ensure that only one
* thread is doing an ioctl at a time.
*/
static int
{
int error;
return (error);
}
return (EINVAL);
}
return (EINVAL);
}
/*
* push new module and call its open routine via qattach
*/
return (error);
/*
* Check to see if caller wants a STREAMS anchor
* put at this place in the stream, and add if so.
*/
}
return (0);
}
/*
* Open a stream device.
*/
int
{
int s;
struct dlautopush dlap;
int error = 0;
int cloneopen;
if (audit_active)
/*
* If the stream already exists, wait for any open in progress
* to complete, then call the open function of each module and
* driver in the stream. Otherwise create the stream.
*/
/*
* Waiting for stream to be created to device
* due to another open.
*/
goto ckreturn;
}
goto ckreturn;
}
goto retry;
}
goto ckreturn;
}
goto ckreturn;
}
goto retry;
}
goto ckreturn;
}
} else {
goto ckreturn;
}
goto ckreturn;
}
goto retry; /* could be clone! */
}
goto ckreturn;
}
}
/*
* Open all modules and devices down stream to notify
* that another user is streaming. For modules, set the
* last argument to MODOPEN and do not pass any open flags.
* Ignore dummydev since this is not the first open.
*/
break;
}
return (error);
}
/*
* This vnode isn't streaming. SPECFS already
* checked for multiple vnodes pointing to the
* same stream, so create a stream to the driver.
*/
/*
* Initialize stream head. shalloc() has given us
* exclusive access, and we have the vnode locked;
* we can do whatever we want with stp.
*/
stp->sd_sigflags = 0;
stp->sd_pushcnt = 0;
stp->sd_qn_minpsz = 0;
/*
* This means, both for pipes and fifos
* strwrite will send SIGPIPE if the other
* end is closed. For putmsg it depends
* on whether it is a XPG4_2 application
* or not
*/
/* setq might sleep in kmem_alloc - avoid holding locks. */
/*
* Wake up others that are waiting for stream to be created.
*/
/*
* nothing is be pushed on stream yet, so
* optimized stream head packetsizes are just that
* of the read queue
*/
goto fifo_opendone;
}
/* setq might sleep in kmem_alloc - avoid holding locks. */
/*
* Open driver and create stream to it (via qattach).
*/
return (error);
}
/*
* Set sd_strtab after open in order to handle clonable drivers
*/
/*
* Historical note: dummydev used to be be prior to the initial
* open (via qattach above), which made the value seen
* inconsistent between an I_PUSH and an autopush of a module.
*/
/*
* For clone open of old style (Q not associated) network driver,
*/
" streams module");
}
if (!NETWORK_DRV(major)) {
} else {
/*
* For network devices, process differently based on the
* return value from dld_autopush():
*
* 0: the passed-in device points to a GLDv3 datalink with
* per-link autopush configuration; use that configuration
* and ignore any per-driver autopush configuration.
*
* 1: the passed-in device points to a physical GLDv3
* datalink without per-link autopush configuration. The
* passed in device was changed to refer to the actual
* physical device (if it's not already); we use that new
* device to look up any per-driver autopush configuration.
*
* -1: neither of the above cases applied; use the initial
* device to look up any per-driver autopush configuration.
*/
case 0:
zoneid);
if (error != 0)
break;
}
goto opendone;
case 1:
break;
case -1:
break;
}
}
/*
* Find the autopush configuration based on "savedev". Start with the
* global zone. If not found check in the local zone.
*/
if (zoneid == GLOBAL_ZONEID) {
/*
* None found. Also look in the zone's autopush table.
*/
if (zoneid != GLOBAL_ZONEID)
goto retryap;
}
goto opendone;
}
if (error != 0)
break;
}
/*
* let specfs know that open failed part way through
*/
if (error) {
}
/*
* Wake up others that are waiting for stream to be created.
*/
/*
* As a performance concern we are caching the values of
* q_minpsz and q_maxpsz of the module below the stream
* head in the stream head.
*/
/* do this processing here as a performance concern */
if (strmsgsz != 0) {
else
}
return (error);
}
};
};
/*
* Close a stream.
* This is called from closef() on the last close of an open stream.
* Strclean() will already have removed the siglist and pollist
* information, so all that remains is to remove all multiplexor links
* for the stream, pop all the modules (and the driver), and free the
* stream structure.
*/
int
{
int rval;
int freestp = 1;
if (audit_active)
/*
* Needed so that strpoll will return non-zero for this fd.
* Note that with POLLNOERR STRHUP does still cause POLLHUP.
*/
/*
* If the registered process or process group did not have an
* open instance of this stream then strclean would not be
* called. Thus at the time of closing all remaining siglist entries
* are removed.
*/
int waited = 1;
while (waited) {
waited = 0;
waited = 1;
}
waited = 1;
}
}
} else {
}
/* Check if an I_LINK was ever done on this stream */
netstack_t *ns;
}
/*
* Holding sd_lock prevents q_next from changing in
* this stream.
*/
/*
* sleep until awakened by strwsrv() or timeout
*/
for (;;) {
break;
}
/* ensure strwsrv gets enabled */
/* get out if we timed out or recv'd a signal */
stp->sd_closetime, 0) <= 0) {
break;
}
}
}
}
}
/*
* Since we call pollwakeup in close() now, the poll list should
* be empty in most cases. The only exception is the layered devices
* (e.g. the console drivers with redirection modules pushed on top
* of it). We have to do this after calling qdetach() because
* the redirection module won't have torn down the console
* redirection until after qdetach() has been invoked.
*/
}
/* Prevent qenable from re-enabling the stream head queue */
/*
* Wait until service procedure of each queue is
* run, if QINSERVICE is set.
*/
/*
* Now, flush both queues.
*/
/*
* If the write queue of the stream head is pointing to a
* read queue, we have a twisted stream. If the read queue
* is alive, convert the stream head queues into a dead end.
* If the read queue is dead, free the dead pair.
*/
} else { /* pipe */
freestp = 0;
/*
* The q_info pointers are never accessed when
* SQLOCK is held.
*/
}
} else {
}
}
}
if (freestp)
return (0);
}
static int
{
case M_FLUSH:
/*
* Protect against the driver passing up
* messages after it has done a qprocsoff.
*/
else
} else {
}
break;
case M_COPYIN:
case M_COPYOUT:
}
/*
* Protect against the driver passing up
* messages after it has done a qprocsoff.
*/
else
break;
case M_IOCTL:
}
/*
* Protect against the driver passing up
* messages after it has done a qprocsoff.
*/
else
break;
default:
break;
}
return (0);
}
/*
* Clean up after a process when it closes a stream. This is called
* from closef for all closes, whereas strclose is called only for the
* last close on a stream. The siglist is scanned for entries for the
* current process, and these are removed.
*/
void
{
int update = 0;
while (ssp) {
if (pssp)
else
update = 1;
} else {
}
}
if (update) {
stp->sd_sigflags = 0;
}
}
/*
* Used on the last close to remove any remaining items on the siglist.
* These could be present on the siglist due to I_ESETSIG calls that
* use process groups or processed that do not have an open file descriptor
* for this stream (Such entries would not be removed by strclean).
*/
static void
{
while (ssp) {
}
stp->sd_sigflags = 0;
}
/*
* Retrieve the next message from the logical stream head read queue
* using either rwnext (if sync stream) or getq_noenab.
* It is the callers responsibility to call qbackenable after
* it is finished with the message. The caller should not call
* qbackenable until after any putback calls to avoid spurious backenabling.
*/
mblk_t *
int *errorp)
{
int error;
/* Holding sd_lock prevents the read queue from changing */
/*
* Stream supports rwnext() for the read side.
* If this is the first time we're called by e.g. strread
* only do the downcall if there is a deferred wakeup
* (registered in sd_wakeq).
*/
if (first)
/*
* Mark that a thread is in rwnext on the read side
* to prevent strrput from nacking ioctls immediately.
* When the last concurrent rwnext returns
* the ioctls are nack'ed.
*/
stp->sd_struiodnak++;
/*
* Note: rwnext will drop sd_lock.
*/
stp->sd_struiodnak--;
while (stp->sd_struiodnak == 0 &&
/*
* Protect against the driver passing up
* messages after it has done a qprocsoff.
*/
else {
}
}
*errorp = 0;
return (bp);
}
error = 0;
/*
* The stream plumbing must have
* changed while we were away, so
* just turn off rwnext()s.
*/
error = 0;
/*
* The module might have data in transit using putnext
* Fall back on waiting + getq.
*/
error = 0;
} else {
return (NULL);
}
/*
* Try a getq in case a rwnext() generated mblk
* has bubbled up via strrput().
*/
}
*errorp = 0;
return (getq_noenab(q));
}
/*
* Copy out the message pointed to by `bp' into the uio pointed to by `uiop'.
* If the message does not fit in the uio the remainder of it is returned;
* otherwise NULL is returned. Any embedded zero-length mblk_t's are
* consumed, even if uio_resid reaches zero. On error, `*errorp' is set to
* the error code, the message is consumed, and NULL is returned.
*/
static mblk_t *
{
int error;
ptrdiff_t n;
do {
ASSERT(n > 0);
if (error != 0) {
return (NULL);
}
}
}
*errorp = 0;
return (bp);
}
/*
* Read a stream according to the mode flags in sd_flag:
*
* (default mode) - Byte stream, msg boundaries are ignored
* RD_MSGDIS (msg discard) - Read on msg boundaries and throw away
* any data remaining in msg
* RD_MSGNODIS (msg non-discard) - Read on msg boundaries and put back
* any remaining data on head of read queue
*
* Consume readable messages on the front of the queue until
* ttolwp(curthread)->lwp_count
* is satisfied, the readable messages are exhausted, or a message
* boundary is reached in a message mode. If no data was read and
* the stream was not opened with the NDELAY flag, block until data arrives.
* Otherwise return the data read and update the count.
*
* In default mode a 0 length message signifies end-of-file and terminates
* a read in progress. The 0 length message is removed from the queue
* only if it is the only message read (no data is read).
*
* An attempt to read an M_PROTO or M_PCPROTO message results in an
* EBADMSG error return, unless either RD_PROTDAT or RD_PROTDIS are set.
* If RD_PROTDAT is set, M_PROTO and M_PCPROTO messages are read as data.
* If RD_PROTDIS is set, the M_PROTO and M_PCPROTO parts of the message
* are unlinked from and M_DATA blocks in the message, the protos are
* thrown away, and the data is read.
*/
/* ARGSUSED */
int
{
queue_t *q;
int error = 0;
int first;
char rflg;
short delim;
unsigned char pri = 0;
char waitflag;
unsigned char type;
return (error);
}
if (error != 0) {
return (error);
}
}
/*
* Loop terminates when uiop->uio_resid == 0.
*/
rflg = 0;
for (;;) {
mark = 0;
delim = 0;
first = 1;
int done = 0;
if (error != 0)
goto oops;
goto oops;
}
goto oops;
}
/*
* If a read(fd,buf,0) has been done, there is no
* need to sleep. We always have zero bytes to
* return.
*/
goto oops;
}
qbackenable(q, 0);
"strread calls strwaitq:%p, %p, %p",
"strread error or done:%p, %p, %p",
error = 0;
goto oops;
}
goto oops;
}
first = 0;
}
/*
* Extract any mark information. If the message is not
* completely consumed this information will be put in the mblk
* that is putback.
* If MSGMARKNEXT is set and the message is completely consumed
* the STRATMARK flag will be set below. Likewise, if
* MSGNOTMARKNEXT is set and the message is
* completely consumed STRNOTATMARK will be set.
*
* For some unknown reason strread only breaks the read at the
* last mark.
*/
if (rflg) {
goto oops;
}
}
delim = 1;
if (STREAM_NEEDSERVICE(stp))
switch (type) {
case M_DATA:
} else if (rflg) {
/*
* If already read data put zero
* length message back on queue else
* free msg and return 0.
*/
} else {
}
error = 0;
goto oops1;
}
rflg = 1;
if (error != 0)
goto oops1;
if (bp) {
/*
* Have remaining data in message.
* Free msg if in discard mode.
*/
} else {
if (delim)
else
}
} else {
/*
* Consumed the complete message.
* Move the MSG*MARKNEXT information
* to the stream head just in case
* the read queue becomes empty.
*
* If the stream head was at the mark
* (STRATMARK) before we dropped sd_lock above
* and some data was consumed then we have
* moved past the mark thus STRATMARK is
* cleared. However, if a message arrived in
* strrput during the copyout above causing
* STRATMARK to be set we can not clear that
* flag.
*/
if (mark &
if (mark & MSGMARKNEXT) {
} else if (mark & MSGNOTMARKNEXT) {
} else {
}
}
}
/*
* Check for signal messages at the front of the read
* queue and generate the signal(s) if appropriate.
* The only signal that can be on queue is M_SIG at
* this point.
*/
bp = getq_noenab(q);
/*
* sd_lock is held so the content of the
* read queue can not change.
*/
if (STREAM_NEEDSERVICE(stp))
}
delim ||
goto oops;
}
continue;
case M_SIG:
continue;
case M_PROTO:
case M_PCPROTO:
/*
* Only data messages are readable.
* Any others generate an error, unless
* RD_PROTDIS or RD_PROTDAT is set.
*/
M_PROTO) ||
M_PCPROTO)) {
} else {
break;
}
}
/*
* clear stream head hi pri flag based on
* first message
*/
}
goto ismdata;
/*
* discard non-data messages
*/
while (bp &&
}
/*
* clear stream head hi pri flag based on
* first message
*/
}
if (bp) {
goto ismdata;
} else {
break;
}
}
/* FALLTHRU */
case M_PASSFP:
break;
}
if (rflg == 0)
goto oops1;
default:
/*
* Garbage on stream head read queue.
*/
goto oops1;
}
}
oops:
qbackenable(q, pri);
return (error);
}
/*
* Determine which wakeups and signals are needed.
* This can be replaced by a user-specified procedure for kernel users
* of STREAMS.
*/
/* ARGSUSED */
mblk_t *
{
*allmsgsigs = 0;
case M_PROTO:
} else {
}
break;
case M_PCPROTO:
*firstmsgsigs = S_HIPRI;
*pollwakeups = POLLPRI;
break;
}
return (mp);
}
/*
* Default processing of everything but M_DATA, M_PROTO, M_PCPROTO and
* M_PASSFP messages.
* Determine which wakeups and signals are needed.
* This can be replaced by a user-specified procedure for kernel users
* of STREAMS.
*/
/* ARGSUSED */
mblk_t *
{
*wakeups = 0;
*firstmsgsigs = 0;
*allmsgsigs = 0;
*pollwakeups = 0;
return (mp);
}
/*
* with messages for the stream head. Data, protocol, and in-stream
* signal messages are placed on the queue, others are handled directly.
*/
int
{
int hipri_sig;
/*
* Use rput_opt for optimized access to the SR_ flags except
* SR_POLLIN. That flag has to be checked under sd_lock since it
* is modified by strpoll().
*/
"strrput called with message type:q %p bp %p", q, bp);
/*
* Perform initial processing and pass to the parameterized functions.
*/
case M_DATA:
/*
* sockfs is the only consumer of STREOF and when it is set,
* it implies that the receiver is not interested in receiving
* any more data, hence the mblk is freed to prevent unnecessary
* message queueing at the stream head.
*/
return (0);
}
if ((rput_opt & SR_IGN_ZEROLEN) &&
/*
* Ignore zero-length M_DATA messages. These might be
* generated by some transports.
* The zero-length M_DATA messages, even if they
* are ignored, should effect the atmark tracking and
* should wake up a thread sleeping in strwaitmark.
*/
/*
* Record the position of the mark either
* in q_last or in STRATMARK.
*/
} else {
}
/*
* Record that this is not the position of
* the mark either in q_last or in
* STRNOTATMARK.
*/
} else {
}
}
cv_broadcast(&q->q_wait);
}
return (0);
}
} else {
}
if (rput_opt & SR_SIGALLDATA)
else
allmsgsigs = 0;
if ((rput_opt & SR_CONSOL_DATA) &&
/*
* Consolidate an M_DATA message onto an M_DATA,
* M_PROTO, or M_PCPROTO by merging it with q_last.
* The consolidation does not take place if
* the old message is marked with either of the
* marks or the delim flag or if the new
* message is marked with MSGMARK. The MSGMARK
* check is needed to handle the odd semantics of
* MSGMARK where essentially the whole message
* is to be treated as marked.
* Carry any MSGMARKNEXT and MSGNOTMARKNEXT from the
* new message to the front of the b_cont chain.
*/
rmvq_noenab(q, lbp);
/*
* The first message in the b_cont list
* tracks MSGMARKNEXT and MSGNOTMARKNEXT.
* We need to handle the case where we
* are appending:
*
* 1) a MSGMARKNEXT to a MSGNOTMARKNEXT.
* 2) a MSGMARKNEXT to a plain message.
* 3) a MSGNOTMARKNEXT to a plain message
* 4) a MSGNOTMARKNEXT to a MSGNOTMARKNEXT
* message.
*
* Thus we never append a MSGMARKNEXT or
* MSGNOTMARKNEXT to a MSGMARKNEXT message.
*/
}
/*
* The new message logically isn't the first
* even though the q_first check below thinks
* it is. Clear the firstmsgsigs to make it
* not appear to be first.
*/
firstmsgsigs = 0;
}
}
break;
case M_PASSFP:
allmsgsigs = 0;
} else {
}
break;
case M_PROTO:
case M_PCPROTO:
break;
default:
break;
}
/* By default generate superset of signals */
/*
* The proto and misc functions can return multiple messages
* as a b_next chain. Such messages are processed separately.
*/
hipri_sig = 0;
} else {
case M_PCPROTO:
/*
* Only one priority protocol message is allowed at the
* stream head at a time.
*/
"M_PCPROTO already at head");
goto done;
}
hipri_sig = 1;
/* FALLTHRU */
case M_DATA:
case M_PROTO:
case M_PASSFP:
/*
* Marking doesn't work well when messages
* are marked in more than one band. We only
* remember the last message received, even if
* it is placed on the queue ahead of other
* marked messages.
*/
/*
* If message is a PCPROTO message, always use
* firstmsgsigs to determine if a signal should be
* sent as strrput is the only place to send
* signals for PCPROTO. Other messages are based on
* the STRGETINPROG flag. The flag determines if
* strrput or (k)strgetmsg will be responsible for
* sending the signals, in the firstmsgsigs case.
*/
if ((hipri_sig == 1) ||
else
break;
default:
(void) strrput_nondata(q, bp);
break;
}
}
/*
*/
cv_broadcast(&q->q_wait);
}
}
if (pollwakeups != 0) {
/*
* Can't use rput_opt since it was not
* read when sd_lock was held and SR_POLLIN is changed
* by strpoll() under sd_lock.
*/
goto no_pollwake;
}
}
/*
* strsendsig can handle multiple signals with a
* single call.
*/
done:
return (0);
/*
* Any signals were handled the first time.
* Wakeups and pollwakeups are redone to avoid any race
* conditions - all the messages are not queued until the
* last message has been processed by strrput.
*/
goto one_more;
}
static void
{
/*
* Allocate a buffer large enough to hold the names of nstrpush modules
* and one driver, with spaces between and NUL terminator. If we can't
* get memory, then we'll just log the driver name.
*/
/* march down write side to print log message down to the driver */
/* make sure q_next doesn't shift around while we're grabbing data */
do {
dname = "?";
/*
* If we don't have memory, then get the driver name in
* the log where we can see it. Note that memory
* pressure is a possible cause of these sorts of bugs.
*/
if (islast) {
maxmodstr = 0;
}
} else {
if (!islast)
*mnp++ = ' ';
}
} while (!islast);
releasestr(wq);
/* Cannot happen unless stream head is corrupt. */
"Warning: stream %p received duplicate %X M_IOC%s; module list: %s",
if (maxmodstr != 0)
}
int
{
struct stroptions *sop;
unsigned char bpri;
unsigned char flushed_already = 0;
case M_ERROR:
/*
* An error has occurred downstream, the errno is in the first
* bytes of the message.
*/
unsigned char rw = 0;
} else {
}
}
} else {
}
}
if (rw) {
"strrput cv_broadcast:q %p, bp %p",
q, bp);
/*
* Send the M_FLUSH only
* for the first M_ERROR
* message on the stream
*/
if (flushed_already == rw) {
return (0);
}
/*
* Protect against the driver
* passing up messages after
* it has done a qprocsoff
*/
else
return (0);
} else
"strrput wakeup #2:q %p, bp %p", q, bp);
/*
* Send the M_FLUSH only
* for the first M_ERROR
* message on the stream
*/
if (flushed_already != FLUSHRW) {
/*
* Protect against the driver passing up
* messages after it has done a
* qprocsoff.
*/
else
return (0);
}
}
return (0);
case M_HANGUP:
/*
* send signal if controlling tty
*/
}
/*
* wake up read, write, and exception pollers and
* reset wakeup mechanism.
*/
return (0);
case M_UNHANGUP:
return (0);
case M_SIG:
/*
* Someone downstream wants to post a signal. The
* signal to post is contained in the first byte of the
* message. If the message would go on the front of
* the queue, send a signal to the process group
* (if not SIGPOLL) or to the siglist processes
* (SIGPOLL). If something is already on the queue,
* OR if we are delivering a delayed suspend (*sigh*
* another "tty" hack) and there's no one sleeping already,
* just enqueue the message.
*/
return (0);
}
/* FALLTHRU */
case M_PCSIG:
/*
* Don't enqueue, just post the signal.
*/
return (0);
case M_CMD:
return (0);
}
} else {
}
return (0);
case M_FLUSH:
/*
* Flush queues. The indication of which queues to flush
* is in the first byte of the message. If the read queue
* is specified, then flush it. If FLUSHBAND is set, just
* flush the band specified by the second byte of the message.
*
* If a module has issued a M_SETOPT to not flush hi
* priority messages off of the stream head, then pass this
* flag into the flushq code to preserve such messages.
*/
} else
else {
}
}
/*
* Protect against the driver passing up
* messages after it has done a qprocsoff.
*/
else
return (0);
}
return (0);
case M_IOCACK:
case M_IOCNAK:
/*
* If not waiting for ACK or NAK then just free msg.
* If incorrect id sequence number then just free msg.
* If already have ACK or NAK for user then this is a
* duplicate, display a warning and free the msg.
*/
/*
* Dup is when sd_iocid == ioc_id, and
* sd_iocblk == <valid ptr> or -1 (the former
* is when an ioctl has been put on the stream
* head, but has not yet been consumed, the
* later is when it has been consumed).
*/
log_dupioc(q, bp);
}
return (0);
}
/*
* Assign ACK or NAK to user and wake up.
*/
return (0);
case M_COPYIN:
case M_COPYOUT:
/*
* If not waiting for ACK or NAK then just fail request.
* If already have ACK, NAK, or copy request, then just
* fail request.
* If incorrect id sequence number then just fail request.
*/
}
return (0);
}
/*
* Assign copy request to user and wake up.
*/
return (0);
case M_SETOPTS:
/*
* Set stream head options (read option, write offset,
* the read side only).
*/
bpri = 0;
case RNORM:
break;
case RMSGD:
stp->sd_read_opt =
break;
case RMSGN:
stp->sd_read_opt =
break;
}
case RPROTNORM:
break;
case RPROTDAT:
stp->sd_read_opt =
break;
case RPROTDIS:
stp->sd_read_opt =
break;
}
case RFLUSHPCPROT:
/*
* This sets the stream head to NOT flush
* M_PCPROTO messages.
*/
break;
}
}
case RERRNORM:
break;
case RERRNONPERSIST:
break;
}
case WERRNORM:
break;
case WERRNONPERSIST:
break;
}
}
}
}
}
"allocate qband\n");
} else {
}
} else {
}
}
"allocate qband\n");
} else {
}
} else {
}
}
/* Check backenable in case the water marks changed */
qbackenable(q, bpri);
return (0);
/*
* The following set of cases deal with situations where two stream
* heads are connected to each other (twisted streams). These messages
* have no meaning at the stream head.
*/
case M_BREAK:
case M_CTL:
case M_DELAY:
case M_START:
case M_STOP:
case M_IOCDATA:
case M_STARTI:
case M_STOPI:
return (0);
case M_IOCTL:
/*
* Always NAK this condition
* (makes no sense)
* If there is one or more threads in the read side
* rwnext we have to defer the nacking until that thread
* returns (in strget).
*/
if (stp->sd_struiodnak != 0) {
/*
* Defer NAK to the streamhead. Queue at the end
* the list.
*/
if (mp)
else
return (0);
}
/*
* Protect against the driver passing up
* messages after it has done a qprocsoff.
*/
else
return (0);
default:
#ifdef DEBUG
"bad message type %x received at stream head\n",
#endif
return (0);
}
/* NOTREACHED */
}
/*
* Check if the stream pointed to by `stp' can be written to, and return an
* error code if not. If `eiohup' is set, then return EIO if STRHUP is set.
* If `sigpipeok' is set and the SW_SIGPIPE option is enabled on the stream,
* then always return EPIPE and send a SIGPIPE to the invoking thread.
*/
static int
{
int error;
/*
* For modem support, POSIX states that on writes, EIO should
* be returned if the stream has been hung up.
*/
else
if (error != 0) {
}
}
return (error);
}
/*
* Copyin and send data down a stream.
* The caller will allocate and copyin any control part that precedes the
* message and pass than in as mctl.
*
* Caller should *not* hold sd_lock.
* When EWOULDBLOCK is returned the caller has to redo the canputnext
* under sd_lock in order to avoid missing a backenabling wakeup.
*
* Use iosize = -1 to not send any M_DATA. iosize = 0 sends zero-length M_DATA.
*
* Set MSG_IGNFLOW in flags to ignore flow control for hipri messages.
* For sync streams we can only ignore flow control by reverting to using
* putnext.
*
* If sd_maxblk is less than *iosize this routine might return without
* transferring all of *iosize. In all cases, on return *iosize will contain
* the amount of data that was transferred.
*/
static int
{
int error = 0;
if (!(flags & STRUIO_POSTPONE)) {
/*
* Use regular canputnext, strmakedata, putnext sequence.
*/
if (pri == 0) {
return (EWOULDBLOCK);
}
} else {
return (EWOULDBLOCK);
}
}
&mp)) != 0) {
/*
* need to change return code to ENOMEM
* so that this is not confused with
* flow control, EAGAIN.
*/
return (ENOMEM);
else
return (error);
}
/*
* Note that for interrupt thread, the CRED() is
* NULL. Don't bother with the pid either.
*/
}
return (0);
if (flags & MSG_IGNFLOW) {
/*
* XXX Hack: Don't get stuck running service
* procedures. This is needed for sockfs when
* sending the unbind message out of the rput
* procedure - we don't want a put procedure
* to run service procedures.
*/
} else {
}
return (0);
}
/*
* Stream supports rwnext() for the write side.
*/
/*
* map EAGAIN to ENOMEM since EAGAIN means "flow controlled".
*/
}
/*
* Note that for interrupt thread, the CRED() is
* NULL. Don't bother with the pid either.
*/
}
return (0);
}
return (error);
}
/*
* The stream plumbing must have changed while
* we were away, so just turn off rwnext()s.
*/
error = 0;
/*
* Couldn't enter a perimeter or took a page fault,
* so fall-back to putnext().
*/
error = 0;
} else {
return (error);
}
/* Have to check canput before consuming data from the uio */
if (pri == 0) {
return (EWOULDBLOCK);
}
} else {
return (EWOULDBLOCK);
}
}
/* Copyin data from the uio */
return (error);
}
if (flags & MSG_IGNFLOW) {
/*
* XXX Hack: Don't get stuck running service procedures.
* This is needed for sockfs when sending the unbind message
* out of the rput procedure - we don't want a put procedure
* to run service procedures.
*/
} else {
}
return (0);
}
/*
* Write attempts to break the write request into messages conforming
* with the minimum and maximum packet sizes set downstream.
*
* Write will not block if downstream queue is full and
* O_NDELAY is set, otherwise it will block waiting for the queue to get room.
*
* A write of zero bytes gets packaged into a zero length message and sent
* downstream like any other message.
*
* If buffers of the requested sizes are not available, the write will
* sleep until the buffers become available.
*
* Write (if specified) will supply a write offset in a message if it
* makes sense. This can be specified by downstream modules as part of
* a M_SETOPTS message. Write will not supply the write offset if it
* cannot supply any data in a buffer. In other words, write will never
* send down an empty packet due to a write offset.
*/
/* ARGSUSED2 */
int
{
}
/* ARGSUSED2 */
int
{
int waitflag;
int tempmode;
int error = 0;
int b_flag;
return (error);
}
if (error != 0) {
return (error);
}
}
/* get these values from them cached in the stream head */
/*
* is non-zero, the write cannot be split into multiple messages
* and still guarantee the size constraints.
*/
if (rmax == 0) {
return (0);
}
if (rmin > 0) {
"strwrite out:q %p out %d error %d",
return (ERANGE);
}
"strwrite out:q %p out %d error %d",
return (ERANGE);
}
}
/*
* Do until count satisfied or error.
*/
else
/*
* Note that tempmode does not get used in strput/strmakedata
* but only in strwaitq. The other routines use uio_fmode
* unmodified.
*/
/* LINTED: constant in conditional context */
while (1) { /* breaks when uio_resid reaches zero */
/*
* Determine the size of the next message to be
* packaged. May have to break write into several
* messages based on max packet size.
*/
/*
* Put block downstream when flow control allows it.
*/
else
b_flag = 0;
for (;;) {
int done = 0;
if (error == 0)
break;
if (error != EWOULDBLOCK)
goto out;
/*
* Check for a missed wakeup.
* Needed since strput did not hold sd_lock across
* the canputnext.
*/
if (canputnext(wqp)) {
/* Try again */
continue;
}
"strwrite wait:q %p wait", wqp);
error = 0;
goto out;
}
"strwrite wake:q %p awakes", wqp);
goto out;
}
}
/* Recheck for errors - needed for sockets */
if (error != 0)
return (error);
}
continue;
}
break;
}
out:
/*
* For historical reasons, applications expect EAGAIN when a data
* mblk_t cannot be allocated, so change ENOMEM back to EAGAIN.
*/
return (error);
}
/*
* Stream head write service routine.
* Its job is to wake up any sleeping writers when a queue
* downstream needs data (part of the flow control in putq and getq).
* It also must wake anyone sleeping on a poll().
* For stream head right below mux module, it must also invoke put procedure
* of next downstream module.
*/
int
{
int i;
int isevent;
TR_STRWSRV, "strwsrv:q %p", q);
cv_broadcast(&q->q_wait);
}
/* The other end of a stream pipe went away. */
return (0);
}
/* Find the next module forward that has a service procedure */
claimstr(q);
goto wakeup;
}
/*
* The queue must have become full again. Set QWANTW
* again so strwsrv will be back enabled when
* the queue becomes non-full next time.
*/
} else {
}
}
isevent = 0;
i = 1;
/*
* The band must have become full again.
* Set QB_WANTW again so strwsrv will
* be back enabled when the band becomes
* non-full next time.
*/
} else {
isevent = 1;
qbf[i] = 1;
}
}
i++;
}
if (isevent) {
if (qbf[i]) {
(uchar_t)i, 0);
}
}
}
releasestr(q);
return (0);
}
/*
* Special case of strcopyin/strcopyout for copying
* struct strioctl that can deal with both data
* models.
*/
#ifdef _LP64
static int
{
struct strioctl32 strioc32;
return (EFAULT);
} else { /* NATIVE data model */
return (EFAULT);
} else {
return (0);
}
}
} else {
}
return (0);
}
static int
{
struct strioctl32 strioc32;
return (EFAULT);
} else { /* NATIVE data model */
return (EFAULT);
} else {
return (0);
}
}
} else {
}
return (0);
}
#else /* ! _LP64 */
/* ARGSUSED2 */
static int
{
}
/* ARGSUSED2 */
static int
{
}
#endif /* _LP64 */
/*
* Determine type of job control semantics expected by user. The
* possibilities are:
* JCREAD - Behaves like read() on fd; send SIGTTIN
* JCWRITE - Behaves like write() on fd; send SIGTTOU if TOSTOP set
* JCSETP - Sets a value in the stream; send SIGTTOU, ignore TOSTOP
* JCGETP - Gets a value in the stream; no signals.
* See straccess in strsubr.c for usage of these values.
*
* This routine also returns -1 for I_STR as a special case; the
* caller must call again with the real ioctl number for
* classification.
*/
static int
job_control_type(int cmd)
{
switch (cmd) {
case I_STR:
return (-1);
case I_RECVFD:
case I_E_RECVFD:
return (JCREAD);
case I_FDINSERT:
case I_SENDFD:
return (JCWRITE);
case TCSETA:
case TCSETAW:
case TCSETAF:
case TCSBRK:
case TCXONC:
case TCFLSH:
case TCDSET: /* Obsolete */
case TIOCSWINSZ:
case TCSETS:
case TCSETSW:
case TCSETSF:
case TIOCSETD:
case TIOCHPCL:
case TIOCSETP:
case TIOCSETN:
case TIOCEXCL:
case TIOCNXCL:
case TIOCFLUSH:
case TIOCSETC:
case TIOCLBIS:
case TIOCLBIC:
case TIOCLSET:
case TIOCSBRK:
case TIOCCBRK:
case TIOCSDTR:
case TIOCCDTR:
case TIOCSLTC:
case TIOCSTOP:
case TIOCSTART:
case TIOCSTI:
case TIOCSPGRP:
case TIOCMSET:
case TIOCMBIS:
case TIOCMBIC:
case TIOCREMOTE:
case TIOCSIGNAL:
case LDSETT:
case LDSMAP: /* Obsolete */
case DIOCSETP:
case I_FLUSH:
case I_SRDOPT:
case I_SETSIG:
case I_SWROPT:
case I_FLUSHBAND:
case I_SETCLTIME:
case I_SERROPT:
case I_ESETSIG:
case FIONBIO:
case FIOASYNC:
case FIOSETOWN:
case JBOOT: /* Obsolete */
case JTERM: /* Obsolete */
case JTIMOM: /* Obsolete */
case JZOMBOOT: /* Obsolete */
case JAGENT: /* Obsolete */
case JTRUN: /* Obsolete */
case JXTPROTO: /* Obsolete */
case TIOCSETLD:
return (JCSETP);
}
return (JCGETP);
}
/*
* ioctl for streams
*/
int
{
int access;
int error = 0;
int done = 0;
}
if (audit_active)
/*
* If the copy is kernel to kernel, make sure that the FNATIVE
* flag is set. After this it would be a serious error to have
* no model flag.
*/
/* We should never see these here, should be handled by iwscn */
return (EINVAL);
return (error);
}
/*
* Check for sgttyb-related ioctls first, and complain as
* necessary.
*/
switch (cmd) {
case TIOCGETP:
case TIOCSETP:
case TIOCSETN:
"application used obsolete TIOC[GS]ET");
}
if (sgttyb_handling >= 3) {
return (EIO);
}
break;
}
switch (cmd) {
case I_RECVFD:
case I_E_RECVFD:
case I_PEEK:
case I_NREAD:
case FIONREAD:
case FIORDCHK:
case I_ATMARK:
case FIONBIO:
case FIOASYNC:
if (error != 0) {
return (error);
}
}
break;
default:
if (error != 0) {
return (error);
}
}
}
switch (cmd) {
default:
/*
* The stream head has hardcoded knowledge of a
* miscellaneous collection of terminal-, keyboard- and
* mouse-related ioctls, enumerated below. This hardcoded
* knowledge allows the stream head to automatically
* convert transparent ioctl requests made by userland
* programs into I_STR ioctls which many old STREAMS
* modules and drivers require.
*
* No new ioctls should ever be added to this list.
* Instead, the STREAMS module or driver should be written
* to either handle transparent ioctls or require any
* userland programs to use I_STR ioctls (by returning
* EINVAL to any transparent ioctl requests).
*
* More importantly, removing ioctls from this list should
* be done with the utmost care, since our STREAMS modules
* and drivers *count* on the stream head performing this
* conversion, and thus may panic while processing
* transparent ioctl request for one of these ioctls (keep
* in mind that third party modules and drivers may have
* similar problems).
*/
/*
* The ioctl is a tty ioctl - set up strioc buffer
* and call strdoioctl() to do the work.
*/
return (ENXIO);
switch (cmd) {
case TCXONC:
case TCSBRK:
case TCFLSH:
case TCDSET:
{
int native_arg = (int)arg;
}
case TCSETA:
case TCSETAW:
case TCSETAF:
case TCSETS:
case TCSETSW:
case TCSETSF:
case LDSETT:
case TIOCSETP:
case TIOCSTI:
secpolicy_sti(crp) != 0) {
return (EPERM);
}
secpolicy_sti(crp) != 0) {
return (EACCES);
}
case TIOCSWINSZ:
case TIOCSSIZE:
case TIOCSSOFTCAR:
case KIOCTRANS:
case KIOCTRANSABLE:
case KIOCCMD:
case KIOCSDIRECT:
case KIOCSCOMPAT:
case KIOCSKABORTEN:
case KIOCSRPTDELAY:
case KIOCSRPTRATE:
case VUIDSFORMAT:
case TIOCSPPS:
case KIOCSETKEY:
case KIOCGETKEY:
case KIOCSKEY:
case KIOCGKEY:
case KIOCSLED:
/* arg is a pointer to char */
case MSIOSETPARMS:
case VUIDSADDR:
case VUIDGADDR:
/*
* These M_IOCTL's don't require any data to be sent
* downstream, and the driver will allocate and link
* on its own mblk_t upon M_IOCACK -- thus we set
* ic_len to zero and set ic_dp to arg so we know
* where to copyout to later.
*/
case TIOCGSOFTCAR:
case TIOCGWINSZ:
case TIOCGSIZE:
case KIOCGTRANS:
case KIOCGTRANSABLE:
case KIOCTYPE:
case KIOCGDIRECT:
case KIOCGCOMPAT:
case KIOCLAYOUT:
case KIOCGLED:
case MSIOGETPARMS:
case MSIOBUTTONS:
case VUIDGFORMAT:
case TIOCGPPS:
case TIOCGPPSEV:
case TCGETA:
case TCGETS:
case LDGETT:
case TIOCGETP:
case KIOCGRPTDELAY:
case KIOCGRPTRATE:
}
}
/*
* Unknown cmd - send it down as a transparent ioctl.
*/
case I_STR:
/*
* Stream ioctl. Read in an strioctl buffer from the user
* along with any data specified and send it downstream.
* Strdoioctl will wait allow only one ioctl message at
* a time, and waits for the acknowledgement.
*/
return (ENXIO);
copyflag);
if (error != 0)
return (error);
return (EINVAL);
if ((access != -1) &&
return (error);
}
/*
* The I_STR facility provides a trap door for malicious
* code to send down bogus streamio(7I) ioctl commands to
* unsuspecting STREAMS modules and drivers which expect to
* only get these messages from the stream head.
* Explicitly prohibit any streamio ioctls which can be
* passed downstream by the stream head. Note that we do
* not block all streamio ioctls because the ioctl
* numberspace is not well managed and thus it's possible
* that a module or driver's ioctl numbers may accidentally
* collide with them.
*/
case I_LINK:
case I_PLINK:
case I_UNLINK:
case I_PUNLINK:
case _I_GETPEERCRED:
case _I_PLINK_LH:
return (EINVAL);
}
if (error == 0) {
}
return (error);
case _I_CMD:
/*
* Like I_STR, but without using M_IOC* messages and without
*/
return (ENXIO);
return (ENOMEM);
return (EFAULT);
}
return (error);
}
*rvalp = 0;
}
return (error);
case I_NREAD:
/*
* Return number of bytes of data in first message
* in queue in "arg" and return the number of messages
* in queue in return value.
*/
{
int retval;
int count = 0;
count++;
if (stp->sd_struiordq) {
if (count == 0) {
}
}
/*
* Drop down from size_t to the "int" required by the
* interface. Cap at INT_MAX.
*/
copyflag);
if (!error)
return (error);
}
case FIONREAD:
/*
* Return number of bytes of data in all data messages
* in queue in "arg".
*/
{
int retval;
if (stp->sd_struiordq) {
}
/*
* Drop down from size_t to the "int" required by the
* interface. Cap at INT_MAX.
*/
copyflag);
*rvalp = 0;
return (error);
}
case FIORDCHK:
/*
* FIORDCHK does not use arg value (like FIONREAD),
* instead a count is returned. I_NREAD value may
* not be accurate but safe. The real thing to do is
* to add the msgdsizes of all data messages until
* a non-data message.
*/
{
if (stp->sd_struiordq) {
}
/*
* Since ioctl returns an int, and memory sizes under
* LP64 may not fit, we return INT_MAX if the count was
* actually greater.
*/
return (0);
}
case I_FIND:
/*
* Get module name.
*/
{
queue_t *q;
if (error)
/*
* Return EINVAL if we're handed a bogus module name.
*/
TR_I_CANT_FIND, "couldn't I_FIND");
return (EINVAL);
}
*rvalp = 0;
/* Look downstream to see if module is there. */
q = NULL;
break;
}
break;
}
*rvalp = (q ? 1 : 0);
return (error);
}
case I_PUSH:
case __I_PUSH_NOCTTY:
/*
* Push a module.
* For the case __I_PUSH_NOCTTY push a module but
* do not allocate controlling tty. See bugid 4025044
*/
{
return (ENXIO);
/*
* Get module name and look up in fmodsw.
*/
if (error)
NULL)
return (EINVAL);
return (error);
}
/*
* See if any more modules can be pushed on this stream.
* Note that this check must be done after strstartplumb()
* since otherwise multiple threads issuing I_PUSHes on
* the same stream will be able to exceed nstrpush.
*/
return (EINVAL);
}
/*
* Push new module and call its open routine
* via qattach(). Modules don't change device
* numbers, so just ignore dummydev here.
*/
B_FALSE)) == 0) {
/*
* try to allocate it as a controlling terminal
*/
}
}
/*
* As a performance concern we are caching the values of
* q_minpsz and q_maxpsz of the module below the stream
* head in the stream head.
*/
/* Do this processing here as a performance concern */
if (strmsgsz != 0) {
else {
}
}
return (error);
}
case I_POP:
{
queue_t *q;
return (ENXIO);
return (EINVAL);
return (error);
/*
* If there is an anchor on this stream and popping
* the current module would attempt to pop through the
* anchor, then disallow the pop unless we have sufficient
* privileges; take the cheapest (non-locking) check
* first.
*/
/*
* Anchors only apply if there's at least one
* module on the stream (sd_pushcnt > 0).
*/
if (stp->sd_pushcnt > 0 &&
return (EINVAL);
/* Audit and report error */
}
}
"I_POP:%p from %p", q, stp);
} else {
error = 0;
}
/*
* As a performance concern we are caching the values of
* q_minpsz and q_maxpsz of the module below the stream
* head in the stream head.
*/
/* Do this processing here as a performance concern */
if (strmsgsz != 0) {
else {
}
}
/* If we popped through the anchor, then reset the anchor. */
stp->sd_anchorzone = 0;
}
return (error);
}
case _I_MUXID2FD:
{
/*
* Create a fd for a I_PLINK'ed lower stream with a given
* muxid. With the fd, application can send down ioctls,
* like I_LIST, to the previously I_PLINK'ed stream. Note
* that after getting the fd, the application has to do an
* I_PUNLINK on the muxid before it can do any operation
* on the lower stream. This is required by spec1170.
*
* The fd used to do this ioctl should point to the same
* controlling device used to do the I_PLINK. If it uses
* a different stream or an invalid muxid, I_MUXID2FD will
* fail. The error code is set to EINVAL.
*
* The intended use of this interface is the following.
* An application I_PLINK'ed a stream and exits. The fd
* to the lower stream is gone. Another application
* wants to get a fd to the lower stream, it uses I_MUXID2FD.
*/
int fd;
netstack_t *ns;
/*
* Do not allow the wildcard muxid. This ioctl is not
* intended to find arbitrary link.
*/
if (muxid == 0) {
return (EINVAL);
}
return (EINVAL);
}
return (EMFILE);
}
return (0);
}
case _I_INSERT:
{
/*
* To insert a module to a given position in a stream.
* In the first release, only allow privileged user
* to use this ioctl. Furthermore, the insert is only allowed
* below an anchor if the zoneid is the same as the zoneid
* which created the anchor.
*
* Note that we do not plan to support this ioctl
* on pipes in the first release. We want to learn more
* about the implications of these ioctls before extending
* their support. And we do not think these features are
* valuable for pipes.
*
* Neither do we support O/C hot stream. Note that only
* The lower IP stream is not.
* When there is a O/C cold barrier, we only allow inserts
* above the barrier.
*/
int pos;
return (ENXIO);
return (EINVAL);
return (error);
return (EINVAL);
if (error)
return (error);
/*
* Get module name and look up in fmodsw.
*/
if (error)
NULL)
return (EINVAL);
return (error);
}
/*
* Is this _I_INSERT just like an I_PUSH? We need to know
* this because we do some optimizations if this is a
* module being pushed.
*/
/*
* Make sure pos is valid. Even though it is not an I_PUSH,
* we impose the same limit on the number of modules in a
* stream.
*/
return (EINVAL);
}
/*
* Is this insert below the anchor?
* Pushcnt hasn't been increased yet hence
* we test for greater than here, and greater or
* equal after qattach.
*/
return (EPERM);
}
}
/*
* First find the correct position this module to
* be inserted. We don't need to call claimstr()
* as the stream should not be changing at this point.
*
* Insert new module and call its open routine
* via qattach(). Modules don't change device
* numbers, so just ignore dummydev here.
*/
}
return (error);
}
/*
* As a performance concern we are caching the values of
* q_minpsz and q_maxpsz of the module below the stream
* head in the stream head.
*/
if (!is_insert) {
/* Do this processing here as a performance concern */
if (strmsgsz != 0) {
} else {
}
}
}
/*
* Need to update the anchor value if this module is
* inserted below the anchor point.
*/
}
return (0);
}
case _I_REMOVE:
{
/*
* To remove a module with a given name in a stream. The
* caller of this ioctl needs to provide both the name and
* the position of the module to be removed. This eliminates
* multiple times in a stream. In the first release, only
* allow privileged user to use this ioctl.
* Furthermore, the remove is only allowed
* below an anchor if the zoneid is the same as the zoneid
* which created the anchor.
*
* Note that we do not plan to support this ioctl
* on pipes in the first release. We want to learn more
* about the implications of these ioctls before extending
* their support. And we do not think these features are
* valuable for pipes.
*
* Neither do we support O/C hot stream. Note that only
* The lower IP stream is not.
* When there is a O/C cold barrier we do not allow removal
* below the barrier.
*
* Also note that _I_REMOVE cannot be used to remove a
* driver or the stream head.
*/
queue_t *q;
int pos;
return (ENXIO);
return (EINVAL);
return (error);
return (EINVAL);
if (error)
return (error);
if (error)
return (error);
/*
* Match the name of given module to the name of module at
* the given position.
*/
;
return (EINVAL);
}
/*
* If the position is at or below an anchor, then the zoneid
* must match the zoneid that created the anchor.
*/
return (EPERM);
}
}
/*
* As a performance concern we are caching the values of
* q_minpsz and q_maxpsz of the module below the stream
* head in the stream head.
*/
if (!is_remove) {
/* Do this processing here as a performance concern */
if (strmsgsz != 0) {
else {
}
}
}
/*
* Need to update the anchor value if this module is removed
* at or below the anchor point. If the removed module is at
* the anchor point, remove the anchor for this stream if
* there is no module above the anchor point. Otherwise, if
* the removed module is below the anchor point, decrement the
* anchor point by 1.
*/
}
return (0);
}
case I_ANCHOR:
/*
* Set the anchor position on the stream to reside at
* the top module (in other words, the top module
* cannot be popped). Anchors with a FIFO make no
* obvious sense, so they're not allowed.
*/
return (EINVAL);
}
/* Only allow the same zoneid to update the anchor */
return (EINVAL);
}
return (0);
case I_LOOK:
/*
* Get name of first module downstream.
* If no module, return an error.
*/
{
copyflag);
return (error);
}
return (EINVAL);
}
case I_LINK:
case I_PLINK:
/*
* Link a multiplexor.
*/
return (error);
case _I_PLINK_LH:
/*
* Link a multiplexor: Call must originate from kernel.
*/
if (kioctl)
return (EINVAL);
case I_UNLINK:
case I_PUNLINK:
/*
* Unlink a multiplexor.
* If arg is -1, unlink all links for which this is the
* controlling stream. Otherwise, arg is an index number
* for a link to be removed.
*/
{
int native_arg = (int)arg;
int type;
netstack_t *ns;
return (EINVAL);
}
type = LINKNORMAL;
else /* I_PUNLINK */
type = LINKPERSIST;
if (native_arg == 0) {
return (EINVAL);
}
if (native_arg == MUXID_ALL)
else {
/* invalid user supplied index number */
return (EINVAL);
}
/* munlink drops the muxifier lock */
}
return (error);
}
case I_FLUSH:
/*
* send a flush message downstream
* flush message can indicate
* FLUSHR - flush read queue
* FLUSHW - flush write queue
*/
return (ENXIO);
return (EINVAL);
for (;;) {
break;
}
return (error);
}
}
/*
* Send down an unsupported ioctl and wait for the nack
* in order to allow the M_FLUSH to propagate back
* up to the stream head.
* Replaces if (qready()) runqueues();
*/
*rvalp = 0;
return (0);
case I_FLUSHBAND:
{
copyflag);
if (error)
return (error);
return (ENXIO);
return (EINVAL);
return (error);
}
/*
* Send down an unsupported ioctl and wait for the nack
* in order to allow the M_FLUSH to propagate back
* up to the stream head.
* Replaces if (qready()) runqueues();
*/
*rvalp = 0;
return (0);
}
case I_SRDOPT:
/*
* Set read options
*
* RNORM - default stream mode
* RMSGN - message no discard
* RMSGD - message discard
* RPROTNORM - fail read with EBADMSG for M_[PC]PROTOs
* RPROTDAT - convert M_[PC]PROTOs to M_DATAs
* RPROTDIS - discard M_[PC]PROTOs and retain M_DATAs
*/
return (EINVAL);
return (EINVAL);
case RNORM:
break;
case RMSGD:
break;
case RMSGN:
break;
}
case RPROTNORM:
break;
case RPROTDAT:
break;
case RPROTDIS:
break;
}
return (0);
case I_GRDOPT:
/*
* Get read option and return the value
* to spot pointed to by arg
*/
{
int rdopt;
copyflag));
}
case I_SERROPT:
/*
* Set error options
*
* RERRNORM - persistent read errors
* RERRNONPERSIST - non-persistent read errors
* WERRNORM - persistent write errors
* WERRNONPERSIST - non-persistent write errors
*/
return (EINVAL);
case RERRNORM:
break;
case RERRNONPERSIST:
break;
}
case WERRNORM:
break;
case WERRNONPERSIST:
break;
}
return (0);
case I_GERROPT:
/*
* Get error option and return the value
* to spot pointed to by arg
*/
{
int erropt = 0;
copyflag));
}
case I_SETSIG:
/*
* Register the calling proc to receive the SIGPOLL
* signal based on the events given in arg. If
* arg is zero, remove the proc from register list.
*/
{
/*
* Hold sd_lock to prevent traversal of sd_siglist while
* it is modified.
*/
;
if (arg) {
return (EINVAL);
}
return (EINVAL);
}
/*
* If proc not already registered, add it
* to list.
*/
if (!ssp) {
if (pssp)
else
}
/*
* Set events.
*/
} else {
/*
* Remove proc from register list.
*/
if (ssp) {
if (pssp)
else
} else {
return (EINVAL);
}
}
/*
* Recalculate OR of sig events.
*/
stp->sd_sigflags = 0;
return (0);
}
case I_GETSIG:
/*
* Return (in arg) the current registration of events
* for which the calling proc is to be signaled.
*/
{
sizeof (int), copyflag);
return (error);
}
return (EINVAL);
}
case I_ESETSIG:
/*
* Register the ss_pid to receive the SIGPOLL
* signal based on the events is ss_events arg. If
* ss_events is zero, remove the proc from register list.
*/
{
if (error)
return (error);
/*
* Permissions check by sending signal 0.
* Note that when kill fails it does a set_errno
* causing the system call to fail.
*/
if (error) {
return (error);
}
}
if (pid == 0)
else if (pid < 0)
else
return (ESRCH);
}
if (pid < 0)
else
/*
* Get a hold on the pid structure while referencing it.
* There is a separate PID_HOLD should it be inserted
* in the list below.
*/
/*
* Hold sd_lock to prevent traversal of sd_siglist while
* it is modified.
*/
;
return (EINVAL);
}
return (EINVAL);
}
/*
* If proc not already registered, add it
* to list.
*/
if (!ssp) {
if (pssp)
else
}
/*
* Set events.
*/
} else {
/*
* Remove proc from register list.
*/
if (ssp) {
if (pssp)
else
} else {
return (EINVAL);
}
}
/*
* Recalculate OR of sig events.
*/
stp->sd_sigflags = 0;
return (0);
}
case I_EGETSIG:
/*
* Return (in arg) the current registration of events
* for which the calling proc is to be signaled.
*/
{
if (error)
return (error);
if (pid == 0)
else if (pid < 0)
else
return (ESRCH);
}
if (pid < 0)
else
/* Prevent the pidp from being reassigned */
return (error);
}
return (EINVAL);
}
case I_PEEK:
{
size_t n;
if (error)
return (error);
/*
* Skip the invalid messages
*/
break;
/*
* If user has requested to peek at a high priority message
* and first message is not, return 0
*/
*rvalp = 0;
return (0);
}
/*
* No mblks to look at at the streamhead and
* 1). This isn't a synch stream or
* 2). This is a synch stream but caller wants high
* priority messages which is not supported by
* the synch stream. (it only supports QNORM)
*/
*rvalp = 0;
return (0);
}
return (EBADMSG);
}
} else {
}
return (ENOSR);
}
/*
* set mp = tmp_mp, so that I_PEEK processing can continue.
* tmp_mp is used to free the dup'd message.
*/
/*
* First process PROTO blocks, if any.
* If user doesn't want to get ctl info by setting maxlen <= 0,
* then set len to -1/0 and skip control blocks part.
*/
else {
int ctl_part = 0;
uio.uio_loffset = 0;
return (error);
}
ctl_part = 1;
}
/* No ctl message */
if (ctl_part == 0)
else
}
/*
* Now process DATA blocks, if any.
* If user doesn't want to get data info by setting maxlen <= 0,
* then set len to -1/0 and skip data blocks part.
*/
else {
int data_part = 0;
uio.uio_loffset = 0;
return (error);
}
data_part = 1;
}
}
/* No data message */
if (data_part == 0)
else
}
/*
* It is a synch stream and user wants to get
* data (maxlen > 0).
* uio setup is done by the codes that process DATA
* blocks above.
*/
error = 0;
if (error)
return (error);
/*
* No data found by the infonext().
*/
}
}
if (error) {
return (error);
}
/*
* If there is no message retrieved, set return code to 0
* otherwise, set it to 1.
*/
*rvalp = 0;
else
*rvalp = 1;
return (0);
}
case I_FDINSERT:
{
return (ENXIO);
/*
* STRDERR, STWRERR and STPLEX tested above.
*/
if (error)
return (error);
sizeof (t_uscalar_t)) != 0)
return (EINVAL);
return (EINVAL);
}
} else
return (EINVAL);
if (error != 0) {
return (error);
}
}
#ifdef _ILP32
{
queue_t *q;
/* get read queue of stream terminus */
q = q->q_next)
claimstr(q);
mate = q;
}
q = _RD(q);
if (mate)
ival = (t_uscalar_t)q;
}
#else
#endif /* _ILP32 */
return (EINVAL);
}
/*
* Check for legal flag value.
*/
return (EINVAL);
}
/* get these values from those cached in the stream head */
/*
* Make sure ctl and data sizes together fall within
* the limits of the max and min receive packet sizes
* and do not exceed system limit. A negative data
* length means that no data part is to be sent.
*/
if (rmax == 0) {
return (ERANGE);
}
msgsize = 0;
return (ERANGE);
}
return (error);
}
return (error);
}
}
/*
* Copy strfdinsert.ctlbuf into native form of
* ctlbuf to pass down into strmakemsg().
*/
uio.uio_loffset = 0;
return (error);
}
/*
* Place the possibly reencoded queue pointer 'offset' bytes
* from the start of the control portion of the message.
*/
/*
* Put message downstream.
*/
return (error);
}
case I_SENDFD:
{
return (EBADF);
if (audit_active) {
}
return (error);
}
case I_RECVFD:
case I_E_RECVFD:
{
struct k_strrecvfd *srf;
int i, fd;
return (ENXIO);
}
return (error);
}
return (error);
}
}
return (EBADMSG);
}
return (EMFILE);
}
struct o_strrecvfd ostrfd;
return (EOVERFLOW);
}
/* Null the filler bits */
for (i = 0; i < 8; i++)
sizeof (struct o_strrecvfd), copyflag);
} else { /* I_E_RECVFD */
/* null the filler bits */
for (i = 0; i < 8; i++)
}
if (error) {
return (error);
}
if (audit_active) {
}
/*
* Always increment f_count since the freemsg() below will
* always call free_passfp() which performs a closef().
*/
return (0);
}
case I_SWROPT:
/*
* mask with any of the following bits set...
* SNDZERO - send zero length message
* SNDPIPE - send sigpipe to process if
* sd_werror is set and process is
* doing a write or putmsg.
* The new stream head write options should reflect
* what is in arg.
*/
return (EINVAL);
return (0);
case I_GWROPT:
{
int wropt = 0;
copyflag));
}
case I_LIST:
/*
* Returns all the modules found on this stream,
* upto the driver. If argument is NULL, return the
* number of modules (including driver). If argument
* is not NULL, copy the names into the structure
* provided.
*/
{
queue_t *q;
int num_modules, space_allocated;
} else {
}
} else {
if (error)
return (error);
if ((space_allocated) <= 0)
return (EINVAL);
num_modules = 0;
while (_SAMESTR(q) && (space_allocated != 0)) {
char *name =
if (error) {
return (error);
}
q = q->q_next;
num_modules++;
sizeof (struct str_mlist));
}
sizeof (int), copyflag);
}
return (error);
}
case I_CKBAND:
{
queue_t *q;
return (EINVAL);
mutex_enter(QLOCK(q));
*rvalp = 0;
} else {
if (arg == 0) {
if (q->q_first)
*rvalp = 1;
else
*rvalp = 0;
} else {
while (--arg > 0)
*rvalp = 1;
else
*rvalp = 0;
}
}
mutex_exit(QLOCK(q));
return (0);
}
case I_GETBAND:
{
int intpri;
queue_t *q;
mutex_enter(QLOCK(q));
if (!mp) {
mutex_exit(QLOCK(q));
return (ENODATA);
}
copyflag);
mutex_exit(QLOCK(q));
return (error);
}
case I_ATMARK:
{
queue_t *q;
return (EINVAL);
*rvalp = 1;
} else {
mutex_enter(QLOCK(q));
*rvalp = 0;
*rvalp = 1;
*rvalp = 1;
else
*rvalp = 0;
mutex_exit(QLOCK(q));
}
return (0);
}
case I_CANPUT:
{
char band;
return (EINVAL);
return (0);
}
case I_SETCLTIME:
{
int closetime;
copyflag);
if (error)
return (error);
if (closetime < 0)
return (EINVAL);
return (0);
}
case I_GETCLTIME:
{
int closetime;
copyflag));
}
case TIOCGSID:
{
return (ENOTTY);
}
copyflag));
}
case TIOCSPGRP:
{
proc_t *q;
copyflag))
return (error);
return (ENOTTY);
}
return (0);
}
return (EINVAL);
}
return (EPERM);
}
return (0);
}
case TIOCGPGRP:
{
return (ENOTTY);
}
copyflag));
}
case TIOCSCTTY:
{
}
case TIOCNOTTY:
{
/* freectty() always assumes curproc. */
return (0);
return (ENOTTY);
}
case FIONBIO:
case FIOASYNC:
return (0); /* handled by the upper layer */
}
}
/*
* Custom free routine used for M_PASSFP messages.
*/
static void
{
}
/* ARGSUSED */
int
{
struct k_strrecvfd *srf;
int retval = 0;
return (ENXIO);
/* Fastpath, we have a pipe, and we are already mated, use it. */
} else { /* Not already mated. */
/*
* Walk the stream to the end of this one.
* assumes that the claimstr() will prevent
* plumbing between the stream head and the
* driver from changing
*/
/*
* Loop until we reach the end of this stream.
* On completion, qp points to the write queue
* at the end of the stream, or the read queue
* at the stream head if this is a fifo.
*/
;
/*
* Just in case we get a q_next which is NULL, but
* not at the end of the stream. This is actually
* broken, so we set an assert to catch it in
* debug, and set an error and return if not debug.
*/
return (EINVAL);
}
/*
* Enter the syncq for the driver, so (hopefully)
* the queue values will not change on us.
* XXXX - This will only prevent the race IFF only
* the write side modifies the q_next member, and
* the put procedure is protected by at least
* MT_PERQ.
*/
/* Now get the q_next value from this qp. */
/*
* If nextqp exists and the other stream is different
* from this one claim the stream, set the mate, and
* get the read queue at the stream head of the other
* stream. Assumes that nextqp was at least valid when
* we got it. Hopefully the entersq of the driver
* will prevent it from changing on us.
*/
/* Make sure we still have a q_next */
return (EINVAL);
}
}
/* If we entered the synq above, leave it. */
} /* STRMATED(STP) */
/* XXX prevents substitution of the ops vector */
goto out;
}
goto out;
}
/*
* Since M_PASSFP messages include a file descriptor, we use
* esballoc() and specify a custom free routine (free_passfp()) that
* will close the descriptor as part of freeing the message. For
* convenience, we stash the frtn_t right after the data block.
*/
goto out;
}
goto out;
}
out:
if (mate)
return (retval);
}
/*
* Send an ioctl message downstream and wait for acknowledgement.
* flags may be set to either U_TO_K or K_TO_K and a combination
* of STR_NOERROR or STR_NOSIG
* STR_NOSIG: Signals are essentially ignored or held and have
* no effect for the duration of the call.
* STR_NOERROR: Ignores stream head read, write and hup errors.
* Additionally, if an existing ioctl times out, it is assumed
* lost and and this ioctl will continue as if the previous ioctl had
* finished. ETIME may be returned if this ioctl times out (i.e.
* ic_timout is not INFTIM). Non-stream head errors may be returned if
* an EFAULT was found when accessing user data, a lack of
* resources, etc.
*/
int
int fflags, /* file flags with model info */
int flag,
int *rvalp)
{
int id;
int transparent = 0;
int error = 0;
int len = 0;
int errs;
transparent = 1;
}
return (EINVAL);
return (error);
if (flag & STR_NOERROR)
else
/*
* If there is data to copy into ioctl block, do so.
*/
if (transparent)
/*
* Note: STR_NOERROR does not have an effect
* in putiocd()
*/
else
return (error);
}
/*
* We could have slept copying in user pages.
* Recheck the stream head state (the other end
* of a pipe could have gone away).
*/
if (error != 0) {
return (error);
}
}
}
if (transparent)
/*
* Block for up to STRTIMOUT milliseconds if there is an outstanding
* ioctl for this stream already running. All processes
* sleeping here will be awakened as a result of an ACK
* or NAK being received for the outstanding ioctl, or
* as a result of the timer expiring on the outstanding
* ioctl (a failure), or as a result of any waiting
* process's timer expiring (also a failure).
*/
error = 0;
"strdoioctl sleeps - IOCWAIT");
if (cv_rval <= 0) {
if (cv_rval == 0) {
} else {
if (flag & STR_NOERROR) {
/*
* Terminating current ioctl in
* progress -- assume it got lost and
* wake up the other thread so that the
* operation completes.
*/
}
/*
* Otherwise, there's a running
* STR_NOERROR -- we have no choice
* here but to wait forever (or until
* interrupted).
*/
} else {
/*
* pending ioctl has caused
* us to time out
*/
}
}
}
if (error) {
return (error);
}
}
/*
* Have control of ioctl mechanism.
* Send down ioctl packet and wait for response.
*/
}
/*
* If this is marked with 'noerror' (internal; mostly
* I_{P,}{UN,}LINK), then make sure nobody else is able to get
* in here by setting IOCWAITNE.
*/
if (flag & STR_NOERROR)
/*
* Assign sequence number.
*/
/*
* Timed wait for acknowledgment. The wait time is limited by the
* timeout value, which must be a positive integer (number of
* milliseconds) to wait, or 0 (use default value of STRTIMOUT
* milliseconds), or -1 (wait forever). This will be awakened
* the timer expiring on another ioctl waiting for control of the
* mechanism.
*/
/*
* If the reply has already arrived, don't sleep. If awakened from
* the sleep, fail only if the reply has not arrived by then.
* Otherwise, process the reply.
*/
if (error != 0) {
return (error);
}
}
"strdoioctl sleeps awaiting reply");
/*
* There are four possible cases here: interrupt, timeout,
* wakeup by IOCWAITNE (above), or wakeup by strrput_nondata (a
* valid M_IOCTL reply).
*
* If we've been awakened by a STR_NOERROR ioctl on some other
* thread, then sd_iocblk will still be NULL, and IOCWAITNE
* will be set. Pretend as if we just timed out. Note that
* this other thread waited at least STRTIMOUT before trying to
* awaken our thread, so this is indistinguishable (even for
* INFTIM) from the case where we failed with ETIME waiting on
* IOCWAIT in the prior loop.
*/
cv_rval = -1;
}
/*
* note: STR_NOERROR does not protect
* us here.. use ic_timout < 0
*/
if (cv_rval <= 0) {
if (cv_rval == 0) {
} else {
}
/*
* A message could have come in after we were scheduled
* but before we were actually run.
*/
}
sizeof (struct copyresp);
} else {
}
}
return (error);
}
}
/*
* Note: it is strictly impossible to get here with sd_iocblk set to
* -1. This is because the initial loop above doesn't allow any new
* ioctls into the fray until all others have passed this point.
*/
/* for detection of duplicate ioctl replies */
} else {
/*
* flags not cleared here because we're still doing
*/
}
/*
* Have received acknowledgment.
*/
case M_IOCACK:
/*
* Positive ack.
*/
/*
* Set error if indicated.
*/
break;
}
/*
* Set return value.
*/
/*
* Data may have been returned in ACK message (ioc_count > 0).
* If so, copy it out to the user's buffer.
*/
break;
}
if (!transparent) {
if (len) /* an M_COPYOUT was used with I_STR */
else
}
break;
case M_IOCNAK:
/*
* Negative ack.
*
* The only thing to do is set error as specified
* in neg ack packet.
*/
break;
case M_COPYIN:
/*
* Driver or module has requested user ioctl data.
*/
/*
* M_COPYIN should *never* have a message attached, though
* it's harmless if it does -- thus, panic on a DEBUG
* kernel and just free it on a non-DEBUG build.
*/
}
}
if (error) {
return (error);
}
goto waitioc;
case M_COPYOUT:
/*
* Driver or module has ioctl data for a user.
*/
/*
* Always (transparent or non-transparent )
* use the address specified in the request
*/
if (!transparent)
/* copyout data to the provided address */
if (error) {
return (error);
}
goto waitioc;
default:
ASSERT(0);
break;
}
return (error);
}
/*
* Send an M_CMD message downstream and wait for a reply. This is a ptools
* being subjected to flow control or interfering with pending messages on the
* stream (e.g. an ioctl in flight).
*/
int
{
int error = 0;
return (EINVAL);
if (scp->sc_timeout > 0)
return (ENOMEM);
/*
* Copy in the payload.
*/
goto out;
}
/* cb_len comes from sc_len, which has already been checked */
}
/*
* Since this mechanism is strictly for ptools, and since only one
* process can be grabbed at a time, we simply fail if there's
* currently an operation pending.
*/
goto out;
}
/*
* Timed wait for acknowledgment. If the reply has already arrived,
* don't sleep. If awakened from the sleep, fail only if the reply
* has not arrived by then. Otherwise, process the reply.
*/
goto waitout;
}
break;
if (rval <= 0) {
goto waitout;
}
}
/*
* We received a reply.
*/
goto out;
/*
* Data may have been returned in the reply (cb_len > 0).
* If so, copy it out to the user's buffer.
*/
goto out;
}
}
out:
return (error);
return (error);
}
/*
* For the SunOS keyboard driver.
* Return the next available "ioctl" sequence number.
* Exported, so that streams modules can send "ioctl" messages
* downstream from their open routine.
*/
int
getiocseqno(void)
{
int i;
i = ++ioc_id;
return (i);
}
/*
* Get the next message from the read queue. If the message is
* priority, STRPRI will have been set by strrput(). This flag
* should be reset only when the entire message at the front of the
* queue as been consumed.
*
* NOTE: strgetmsg and kstrgetmsg have much of the logic in common.
*/
int
unsigned char *prip,
int *flagsp,
int fmode,
{
int flg;
int more = 0;
int error = 0;
char first = 1;
unsigned char pri = 0;
queue_t *q;
int pr = 0; /* Partial read successful */
unsigned char type;
"strgetmsg:%p", vp);
return (error);
}
if (error != 0) {
return (error);
}
}
switch (*flagsp) {
case MSG_HIPRI:
if (*prip != 0)
return (EINVAL);
break;
case MSG_ANY:
case MSG_BAND:
break;
default:
return (EINVAL);
}
/*
* Setup uio and iov for data part
*/
uios.uio_loffset = 0;
uios.uio_offset = 0;
mark = 0;
for (;;) {
int done = 0;
/*
* Get the next message of appropriate priority
* from the stream head. If the caller is interested
* in band or hipri messages, then they should already
* be enqueued at the stream head. On the other hand
* if the caller wants normal (band 0) messages, they
* might be deferred in a synchronous stream and they
* will need to be pulled up.
*
* After we have dequeued a message, we might find that
* it was a deferred M_SIG that was enqueued at the
* stream head. It must now be posted as part of the
* read by calling strsignal_nolock().
*
* Also note that strrput does not enqueue an M_PCSIG,
* and there cannot be more than one hipri message,
* so there was no need to have the M_PCSIG case.
*
* At some time it might be nice to try and wrap the
* functionality of kstrgetmsg() and strgetmsg() into
* a common routine so to reduce the amount of replicated
* code (since they are extremely similar).
*/
/* Asking for normal, band0 data */
continue;
} else {
break;
}
}
if (error != 0) {
goto getmout;
}
/*
* We can't depend on the value of STRPRI here because
* the stream head may be in transit. Therefore, we
* must look at the type of the first message to
* determine if a high priority messages is waiting
*/
/* Asked for HIPRI and got one */
break;
/*
* Asked for at least band "prip" and got either at
* least that band or a hipri message.
*/
continue;
} else {
break;
}
}
/* No data. Time to sleep? */
qbackenable(q, 0);
/*
* If STRHUP or STREOF, return 0 length control and data.
* If resid is 0, then a read(fd,buf,0) was done. Do not
* sleep to satisfy this request because by default we have
* zero bytes to return.
*/
*flagsp = 0;
return (0);
}
"strgetmsg calls strwaitq:%p, %p",
"strgetmsg error or done:%p, %p",
return (error);
}
return (error);
}
first = 0;
}
/*
* Extract any mark information. If the message is not completely
* consumed this information will be put in the mblk
* that is putback.
* If MSGMARKNEXT is set and the message is completely consumed
* the STRATMARK flag will be set below. Likewise, if
* MSGNOTMARKNEXT is set and the message is
* completely consumed STRNOTATMARK will be set.
*/
}
/*
* keep track of the original message type and priority
*/
qbackenable(q, pri);
return (EBADMSG);
}
/*
* Set this flag so strrput will not generate signals. Need to
* make sure this flag is cleared before leaving this routine
* else signals will stop being sent.
*/
if (STREAM_NEEDSERVICE(stp))
/*
* Set HIPRI flag if message is priority.
*/
else
/*
* First process PROTO or PCPROTO blocks, if any.
*/
char *ubuf;
/*
* clear stream head pri flag based on
* first message type
*/
}
more = 0;
goto getmout;
}
ubuf += n;
}
bcnt -= n;
if (bcnt == 0)
break;
}
} else
/*
* More PROTO blocks in msg.
*/
savemptail = bp;
}
}
/*
* Now process DATA blocks, if any.
*/
/*
* struiocopyout will consume a potential zero-length
* M_DATA even if uio_resid is zero.
*/
if (error != 0) {
/*
* clear stream head hi pri flag based on
* first message
*/
}
more = 0;
goto getmout;
}
/*
* (pr == 1) indicates a partial read.
*/
pr = 1;
} else
if (bp) { /* more data blocks in msg */
if (savemp)
else
}
if (savemp) {
/*
* Avoid queuing a zero-length tail part of
* a message. pr=1 indicates that we read some of
* the message.
*/
/*
* clear stream head hi pri flag based on
* first message
*/
}
} else {
/*
* If the first message was HIPRI and the one we're
* putting back isn't, then clear STRPRI, otherwise
* set STRPRI again. Note that we must set STRPRI
* again since the flush logic in strrput_nondata()
* may have cleared it while we had sd_lock dropped.
*/
else
/*
* The first message was not a HIPRI message,
* but the one we are about to putback is.
* For simplicitly, we do not allow for HIPRI
* messages to be embedded in the message
* body, so just force it to same type as
* first message.
*/
}
if (mark != 0) {
/*
* If another marked message arrived
* while sd_lock was not held sd_mark
* would be non-NULL.
*/
}
}
}
} else {
/*
* The complete message was consumed.
*
* If another M_PCPROTO arrived while sd_lock was not held
* it would have been discarded since STRPRI was still set.
*
* Move the MSG*MARKNEXT information
* to the stream head just in case
* the read queue becomes empty.
* clear stream head hi pri flag based on
* first message
*
* If the stream head was at the mark
* (STRATMARK) before we dropped sd_lock above
* and some data was consumed then we have
* moved past the mark thus STRATMARK is
* cleared. However, if a message arrived in
* strrput during the copyout above causing
* STRATMARK to be set we can not clear that
* flag.
*/
}
if (mark & MSGMARKNEXT) {
} else if (mark & MSGNOTMARKNEXT) {
} else {
}
}
}
/*
* Getmsg cleanup processing - if the state of the queue has changed
*/
qbackenable(q, pri);
/*
* We dropped the stream head lock above. Send all M_SIG messages
* before processing stream head for SIGPOLL messages.
*/
/*
* sd_lock is held so the content of the read queue can not
* change.
*/
if (STREAM_NEEDSERVICE(stp))
}
/*
* stream head cannot change while we make the determination
* whether or not to send a signal. Drop the flag to allow strrput
* to send firstmsgsigs again.
*/
/*
* If the type of message at the front of the queue changed
* due to the receive the appropriate signals and pollwakeup events
* are generated. The type of changes are:
* Processed a hipri message, q_first is not hipri.
* Processed a band X message, and q_first is band Y.
* The generated signals and pollwakeups are identical to what
* strrput() generates should the message that is now on q_first
* arrive to an empty read queue.
*
* Note: only strrput will send a signal for a hipri message.
*/
strsigset_t signals = 0;
strpollset_t pollwakeups = 0;
/*
* Removed a hipri message. Regular data at
* the front of the queue.
*/
} else {
}
/*
* The band is different for the new q_first.
*/
} else {
}
}
if (pollwakeups != 0) {
goto no_pollwake;
}
}
}
return (error);
}
/*
* Get the next message from the read queue. If the message is
* priority, STRPRI will have been set by strrput(). This flag
* should be reset only when the entire message at the front of the
* queue as been consumed.
*
* If uiop is NULL all data is returned in mctlp.
* Note that a NULL uiop implies that FNDELAY and FNONBLOCK are assumed
* not enabled.
* The timeout parameter is in milliseconds; -1 for infinity.
* This routine handles the consolidation private flags:
* MSG_IGNERROR Ignore any stream head error except STPLEX.
* MSG_DELAYERROR Defer the error check until the queue is empty.
* MSG_HOLDSIG Hold signals while waiting for data.
* MSG_IPEEK Only peek at messages.
* MSG_DISCARDTAIL Discard the tail M_DATA part of the message
* that doesn't fit.
* MSG_NOMARK If the message is marked leave it on the queue.
*
* NOTE: strgetmsg and kstrgetmsg have much of the logic in common.
*/
int
unsigned char *prip,
int *flagsp,
{
int flags;
int flg;
int more = 0;
int error = 0;
char first = 1;
unsigned char pri = 0;
queue_t *q;
int pr = 0; /* Partial read successful */
unsigned char type;
"kstrgetmsg:%p", vp);
return (error);
}
if (error != 0) {
return (error);
}
}
}
case MSG_HIPRI:
if (*prip != 0)
return (EINVAL);
break;
case MSG_ANY:
case MSG_BAND:
break;
default:
return (EINVAL);
}
mark = 0;
for (;;) {
int done = 0;
int waitflag;
int fmode;
/*
* This section of the code operates just like the code
* in strgetmsg(). There is a comment there about what
* is going on here.
*/
/* Asking for normal, band0 data */
continue;
} else {
break;
}
}
if (error != 0) {
goto getmout;
}
/*
* We can't depend on the value of STRPRI here because
* the stream head may be in transit. Therefore, we
* must look at the type of the first message to
* determine if a high priority messages is waiting
*/
break;
/*
* Asked for at least band "prip" and got either at
* least that band or a hipri message.
*/
continue;
} else {
break;
}
}
/* No data. Time to sleep? */
qbackenable(q, 0);
/*
* Delayed error notification?
*/
if (error != 0) {
return (error);
}
}
/*
* If STRHUP or STREOF, return 0 length control and data.
* If a read(fd,buf,0) has been done, do not sleep, just
* return.
*
* If mctlp == NULL and uiop == NULL, then the code will
* do the strwaitq. This is an understood way of saying
* sleep "polling" until a message is received.
*/
*flagsp = 0;
return (0);
}
if (flags &
if (flags & MSG_HOLDSIG)
if (flags & MSG_IGNERROR)
waitflag |= STR_NOERROR;
if (flags & MSG_DELAYERROR)
waitflag |= STR_DELAYERR;
}
else
fmode = 0;
"kstrgetmsg calls strwaitq:%p, %p",
"kstrgetmsg error or done:%p, %p",
return (error);
}
return (error);
}
first = 0;
}
/*
* Extract any mark information. If the message is not completely
* consumed this information will be put in the mblk
* that is putback.
* If MSGMARKNEXT is set and the message is completely consumed
* the STRATMARK flag will be set below. Likewise, if
* MSGNOTMARKNEXT is set and the message is
* completely consumed STRNOTATMARK will be set.
*/
if (mark != 0) {
/*
* If the caller doesn't want the mark return.
* Used to implement MSG_WAITALL in sockets.
*/
if (flags & MSG_NOMARK) {
qbackenable(q, pri);
return (EWOULDBLOCK);
}
}
}
/*
* keep track of the first message type
*/
qbackenable(q, pri);
return (EBADMSG);
}
/*
* Clear any struioflag - we do the uiomove over again
* when peeking since it simplifies the code.
*
* Dup the message and put the original back on the queue.
* If dupmsg() fails, try again with copymsg() to see if
* there is indeed a shortage of memory. dupmsg() may fail
* if db_ref in any of the messages reaches its limit.
*/
/*
* Restore the state of the stream head since we
* need to drop sd_lock (strwaitbuf is sleeping).
*/
if (error) {
/*
* There is no net change to the queue thus
* no need to qbackenable.
*/
return (error);
}
goto retry;
}
}
/*
* Set this flag so strrput will not generate signals. Need to
* make sure this flag is cleared before leaving this routine
* else signals will stop being sent.
*/
/*
* Put first non-data mblk back to stream head and
* cut the mblk chain so sd_rputdatafunc only sees
* M_DATA mblks. We can skip the first mblk since it
* is M_DATA according to the condition above.
*/
break;
}
}
goto retry;
}
if (STREAM_NEEDSERVICE(stp))
/*
* Set HIPRI flag if message is priority.
*/
else
/*
* First process PROTO or PCPROTO blocks, if any.
*/
}
/*
* More PROTO blocks in msg. Will only happen if mctlp is NULL.
*/
savemptail = bp;
}
}
/*
* Now process DATA blocks, if any.
*/
/* Append data to tail of mctlp */
}
/*
* If a streams message is likely to consist
* of many small mblks, it is pulled up into
* one continuous chunk of memory.
* see longer comment at top of page
* by mblk_pull_len declaration.
*/
}
if (error != 0) {
} else
/*
* clear stream head hi pri flag based on
* first message
*/
}
more = 0;
goto getmout;
}
/*
* (pr == 1) indicates a partial read.
*/
pr = 1;
}
if (bp) { /* more data blocks in msg */
if (savemp)
else
}
if (savemp) {
/*
* When MSG_DISCARDTAIL is set or
* when peeking discard any tail. When peeking this
* is the tail of the dup that was copied out - the
* message has already been putback on the queue.
* Return MOREDATA to the caller even though the data
* is discarded. This is used by sockets (to
* set MSG_TRUNC).
*/
}
/*
* Avoid queuing a zero-length tail part of
* a message. pr=1 indicates that we read some of
* the message.
*/
}
} else {
/*
* If the first message was HIPRI and the one we're
* putting back isn't, then clear STRPRI, otherwise
* set STRPRI again. Note that we must set STRPRI
* again since the flush logic in strrput_nondata()
* may have cleared it while we had sd_lock dropped.
*/
else
/*
* The first message was not a HIPRI message,
* but the one we are about to putback is.
* For simplicitly, we do not allow for HIPRI
* messages to be embedded in the message
* body, so just force it to same type as
* first message.
*/
}
if (mark != 0) {
/*
* If another marked message arrived
* while sd_lock was not held sd_mark
* would be non-NULL.
*/
}
}
}
/*
* The complete message was consumed.
*
* If another M_PCPROTO arrived while sd_lock was not held
* it would have been discarded since STRPRI was still set.
*
* Move the MSG*MARKNEXT information
* to the stream head just in case
* the read queue becomes empty.
* clear stream head hi pri flag based on
* first message
*
* If the stream head was at the mark
* (STRATMARK) before we dropped sd_lock above
* and some data was consumed then we have
* moved past the mark thus STRATMARK is
* cleared. However, if a message arrived in
* strrput during the copyout above causing
* STRATMARK to be set we can not clear that
* flag.
* XXX A "perimeter" would help by single-threading strrput,
* strread, strgetmsg and kstrgetmsg.
*/
}
if (mark & MSGMARKNEXT) {
} else if (mark & MSGNOTMARKNEXT) {
} else {
}
}
}
/*
* Getmsg cleanup processing - if the state of the queue has changed
*/
qbackenable(q, pri);
/*
* We dropped the stream head lock above. Send all M_SIG messages
* before processing stream head for SIGPOLL messages.
*/
/*
* sd_lock is held so the content of the read queue can not
* change.
*/
if (STREAM_NEEDSERVICE(stp))
}
/*
* stream head cannot change while we make the determination
* whether or not to send a signal. Drop the flag to allow strrput
* to send firstmsgsigs again.
*/
/*
* If the type of message at the front of the queue changed
* due to the receive the appropriate signals and pollwakeup events
* are generated. The type of changes are:
* Processed a hipri message, q_first is not hipri.
* Processed a band X message, and q_first is band Y.
* The generated signals and pollwakeups are identical to what
* strrput() generates should the message that is now on q_first
* arrive to an empty read queue.
*
* Note: only strrput will send a signal for a hipri message.
*/
strsigset_t signals = 0;
strpollset_t pollwakeups = 0;
/*
* Removed a hipri message. Regular data at
* the front of the queue.
*/
} else {
}
/*
* The band is different for the new q_first.
*/
} else {
}
}
if (pollwakeups != 0) {
goto no_pollwake;
}
}
}
return (error);
}
/*
* Put a message downstream.
*
* NOTE: strputmsg and kstrputmsg have much of the logic in common.
*/
int
unsigned char pri,
int flag,
int fmode)
{
int error;
int xpg4 = 0;
/*
* If it is an XPG4 application, we need to send
* SIGPIPE below
*/
if (audit_active)
return (error);
}
if (error != 0) {
return (error);
}
}
/*
* Check for legal flag value.
*/
switch (flag) {
case MSG_HIPRI:
return (EINVAL);
break;
case MSG_BAND:
break;
default:
return (EINVAL);
}
"strputmsg in:stp %p", stp);
/* get these values from those cached in the stream head */
/*
* Make sure ctl and data sizes together fall within the
* limits of the max and min receive packet sizes and do
* not exceed system limit.
*/
if (rmax == 0) {
return (ERANGE);
}
/*
* Use the MAXIMUM of sd_maxblk and q_maxpsz.
* Needed to prevent partial failures in the strmakedata loop.
*/
msgsize = 0;
rmin = 0; /* no range check for NULL data part */
}
return (ERANGE);
}
/*
* Setup uio and iov for data part
*/
uios.uio_loffset = 0;
uios.uio_offset = 0;
/* Ignore flow control in strput for HIPRI */
flag |= MSG_IGNFLOW;
for (;;) {
int done = 0;
/*
* strput will always free the ctl mblk - even when strput
* fails.
*/
"strputmsg out:stp %p out %d error %d",
return (error);
}
/*
* Verify that the whole message can be transferred by
* strput.
*/
if (error == 0)
break;
if (error != EWOULDBLOCK)
goto out;
/*
* Check for a missed wakeup.
* Needed since strput did not hold sd_lock across
* the canputnext.
*/
/* Try again */
continue;
}
"strputmsg out:q %p out %d error %d",
return (error);
}
"strputmsg wake:stp %p wakes", stp);
return (error);
}
}
out:
/*
* For historic reasons, applications expect EAGAIN
* when data mblk could not be allocated. so change
* ENOMEM back to EAGAIN
*/
return (error);
}
/*
* Put a message downstream.
* The fmode flag (NDELAY, NONBLOCK) is the or of the flags in the uio
* and the fmode parameter.
*
* This routine handles the consolidation private flags:
* MSG_IGNERROR Ignore any stream head error except STPLEX.
* MSG_HOLDSIG Hold signals while waiting for data.
* MSG_IGNFLOW Don't check streams flow control.
*
* NOTE: strputmsg and kstrputmsg have much of the logic in common.
*/
int
unsigned char pri,
int flag,
int fmode)
{
int error;
if (audit_active)
return (EINVAL);
return (error);
}
if (error != 0) {
return (error);
}
}
}
/*
* Check for legal flag value.
*/
case MSG_HIPRI:
if (pri != 0) {
return (EINVAL);
}
break;
case MSG_BAND:
break;
default:
return (EINVAL);
}
"kstrputmsg in:stp %p", stp);
/* get these values from those cached in the stream head */
/*
* Make sure ctl and data sizes together fall within the
* limits of the max and min receive packet sizes and do
* not exceed system limit.
*/
if (rmax == 0) {
return (ERANGE);
}
/*
* Use the MAXIMUM of sd_maxblk and q_maxpsz.
* Needed to prevent partial failures in the strmakedata loop.
*/
msgsize = -1;
} else {
/* Use uio flags as well as the fmode parameter flags */
return (ERANGE);
}
}
/* Ignore flow control in strput for HIPRI */
flag |= MSG_IGNFLOW;
for (;;) {
int done = 0;
int waitflag;
/*
* strput will always free the ctl mblk - even when strput
* fails. If MSG_IGNFLOW is set then any error returned
* will cause us to break the loop, so we don't need a copy
* of the message. If MSG_IGNFLOW is not set, then we can
* get hit by flow control and be forced to try again. In
* this case we need to have a copy of the message. We
* do this using copymsg since the message may get modified
* by something below us.
*
* We've observed that many TPI providers do not check db_ref
* on the control messages but blindly reuse them for the
* T_OK_ACK/T_ERROR_ACK. Thus using copymsg is more
* friendly to such providers than using dupmsg. Also, note
* that sockfs uses MSG_IGNFLOW for all TPI control messages.
* Only data messages are subject to flow control, hence
* subject to this copymsg.
*/
if (flag & MSG_IGNFLOW) {
} else {
do {
/*
* If a message has a free pointer, the message
* must be dupmsg to maintain this pointer.
* Code using this facility must be sure
* that modules below will not change the
* contents of the dblk without checking db_ref
* first. If db_ref is > 1, then the module
* needs to do a copymsg first. Otherwise,
* the contents of the dblk may become
* may end up calling atomic_add_32_nv.
* The atomic_add_32_nv in freeb (accessing
* all of db_ref, db_type, db_flags, and
* db_struioflag) does not prevent other threads
* from concurrently trying to modify e.g.
* db_type.
*/
else
break;
if (error) {
return (error);
}
}
/*
* Verify that all of msgsize can be transferred by
* strput.
*/
if (error == 0)
break;
if (error != EWOULDBLOCK)
goto out;
/*
* IF MSG_IGNFLOW is set we should have broken out of loop
* above.
*/
/*
* Check for a missed wakeup.
* Needed since strput did not hold sd_lock across
* the canputnext.
*/
/* Try again */
continue;
}
if (flag & MSG_HOLDSIG)
if (flag & MSG_IGNERROR)
waitflag |= STR_NOERROR;
}
"kstrputmsg out:stp %p out %d error %d",
return (error);
}
"kstrputmsg wake:stp %p wakes", stp);
return (error);
}
}
out:
/*
* For historic reasons, applications expect EAGAIN
* when data mblk could not be allocated. so change
* ENOMEM back to EAGAIN
*/
return (error);
}
/*
* Determines whether the necessary conditions are set on a stream
* for it to be readable, writeable, or have exceptions.
*
* strpoll handles the consolidation private events:
* POLLNOERR Do not return POLLERR even if there are stream
* head errors.
* Used by sockfs.
* POLLRDDATA Do not return POLLIN unless at least one message on
* the queue contains one or more M_DATA mblks. Thus
* when this flag is set a queue with only
* Used by sockfs to ignore T_EXDATA_IND messages.
*
* Note: POLLRDDATA assumes that synch streams only return messages with
* an M_DATA attached (i.e. not messages consisting of only
*/
int
short events_arg,
int anyyet,
short *reventsp,
{
int retevents = 0;
int headlocked = 0;
/*
* For performance, a single 'if' tests for most possible edge
* conditions in one shot
*/
return (EINVAL);
}
return (0);
}
}
}
/* Find next module forward that has a service procedure */
if (events & POLLWRNORM) {
/* ensure backq svc procedure runs */
/* Check sync stream barrier write q */
/* ensure pollwakeup() is done */
else
/* More write events to process ??? */
if (! (events & POLLWRBAND)) {
releasestr(qp);
goto chkrd;
}
} else
}
if (events & POLLWRBAND) {
if (qbp) {
while (qbp) {
else
retevents |= POLLWRBAND;
}
} else {
retevents |= POLLWRBAND;
}
}
releasestr(qp);
}
/*
* Note: Need to do polllock() here since ps_lock may be
* held. See bug 4191544.
*/
headlocked = 1;
while (mp) {
/*
* For POLLRDDATA we scan b_cont and b_next until we
* find an M_DATA.
*/
if ((events & POLLRDDATA) &&
continue;
}
}
retevents |= normevents;
else
break;
}
if (! (retevents & normevents) &&
/*
* Sync stream barrier read queue has data.
*/
retevents |= normevents;
}
/* Treat eof as normal data */
retevents |= normevents;
}
if (retevents) {
if (headlocked)
return (0);
}
/*
* If poll() has not found any events yet, set up event cell
* to wake up the poll if a requested event occurs on this
* stream. Check for collisions with outstanding poll requests.
*/
if (!anyyet) {
if (headlocked == 0) {
headlocked = 1;
}
}
if (headlocked)
return (0);
}
/*
* are awakened when there are no new messages arriving at the,
* stream head, and a message is placed back on the read queue.
*
* sd_lock must be held when messages are placed back on stream
* head. (getq() holds sd_lock when it removes messages from
* the queue)
*/
static void
{
/*
* We use the same logic as defined in strrput()
* but in reverse as we are putting back onto the
* queue and want to retain byte ordering.
* Consolidate an M_DATA message onto an M_DATA,
* M_PROTO, or M_PCPROTO by merging it with q_first.
* The consolidation does not take place if the message
* we are returning to the queue is marked with either
* of the marks or the delim flag or if q_first
* is marked with MSGMARK. The MSGMARK check is needed to
* handle the odd semantics of MSGMARK where essentially
* the whole message is to be treated as marked.
* Carry any MSGMARKNEXT and MSGNOTMARKNEXT from q_first
* to the front of the b_cont chain.
*/
rmvq_noenab(q, qfirst);
/*
* The first message in the b_cont list
* tracks MSGMARKNEXT and MSGNOTMARKNEXT.
* We need to handle the case where we
* are appending:
*
* 1) a MSGMARKNEXT to a MSGNOTMARKNEXT.
* 2) a MSGMARKNEXT to a plain message.
* 3) a MSGNOTMARKNEXT to a plain message
* 4) a MSGNOTMARKNEXT to a MSGNOTMARKNEXT
* message.
*
* Thus we never append a MSGMARKNEXT or
* MSGNOTMARKNEXT to a MSGMARKNEXT message.
*/
}
}
}
/*
* A message may have come in when the sd_lock was dropped in the
* calling routine. If this is the case and STR*ATMARK info was
* received, need to move that from the stream head to the q_last
* so that SIOCATMARK can return the proper value.
*/
b_flag &= ~MSGNOTMARKNEXT;
b_flag |= MSGMARKNEXT;
} else {
b_flag &= ~MSGMARKNEXT;
b_flag |= MSGNOTMARKNEXT;
}
}
#ifdef DEBUG
/*
* Make sure that the flags are not messed up.
*/
{
}
}
#endif
short pollevents;
cv_broadcast(&q->q_wait);
}
} else {
if (band == 0) {
return;
} else {
}
}
}
}
/*
* Return the held vnode attached to the stream head of a
* given queue
* It is the responsibility of the calling routine to ensure
* that the queue does not go away (e.g. pop).
*/
vnode_t *
{
return (vp);
}
/*
* return the stream head write queue for the given vp
* It is the responsibility of the calling routine to ensure
* that the stream or vnode do not close.
*/
queue_t *
{
}
/*
* pollwakeup stream head
* It is the responsibility of the calling routine to ensure
* that the stream or vnode do not close.
*/
void
{
}
/*
* Mate the stream heads of two vnodes together. If the two vnodes are the
* same, we just make the write-side point at the read-side -- otherwise,
* we do a full mate. Only works on vnodes associated with streams that are
* still being built and thus have only a stream head.
*/
void
{
/*
* Verify that there are no modules on the stream yet. We also
* rely on the stream head always having a service procedure to
* avoid tweaking q_nfsrv.
*/
/*
* If the queues are the same, just twist; otherwise do a full mate.
*/
} else {
}
}
/*
* XXX will go away when console is correctly fixed.
* Clean up the console PIDS, from previous I_SETSIG,
* called only for cnopen which never calls strclean().
*/
void
{
int update = 0;
while (ssp) {
/*
* Get rid of PID if the proc is gone.
*/
if (pidp->pid_prinactive) {
if (pssp)
else
update = 1;
continue;
} else
}
if (update) {
stp->sd_sigflags = 0;
}
}
/*
* Return B_TRUE if there is data in the message, B_FALSE otherwise.
*/
static boolean_t
{
return (B_TRUE);
}
return (B_FALSE);
}