[comp.unix.internals] How to distinguish between STREAMS and non-STREAMS

dcm@baldur.dell.com (Dave McCracken) (01/15/91)

josef@nixpbe.nixdorf.de (josef Moellers) writes:

>Does anybody now of a bulletproof and FAST method to distinguish between
>a STREAMS fd and a non-STREAMS fd?
>I cannot use calls to getmsg/putmsg, as I am not allowed to change the
>state of the STREAM.

I would say right offhand you should do a streams-specific query ioctl.
A few that might be useful are I_LOOK, I_GRDOPT, I_GRWOPT, and I_LIST.
I_LIST might be particularly fast since if you pass it a NULL pointer
for the list, it just returns the number of modules on the stream,
and this information comes directly out of the stream head.

--
Dave McCracken      dcm@dell.dell.com      (512) 343-3720
Dell Computer       9505 Arboretum Blvd    Austin, TX 78759-7299

josef@nixpbe.nixdorf.de (josef Moellers) (01/17/91)

In <dcm.663952404@baldur> dcm@baldur.dell.com (Dave McCracken) writes:

>josef@nixpbe.nixdorf.de (josef Moellers) writes:

>>Does anybody now of a bulletproof and FAST method to distinguish between
>>a STREAMS fd and a non-STREAMS fd?
>>I cannot use calls to getmsg/putmsg, as I am not allowed to change the
>>state of the STREAM.

>I would say right offhand you should do a streams-specific query ioctl.
>A few that might be useful are I_LOOK, I_GRDOPT, I_GRWOPT, and I_LIST.
>I_LIST might be particularly fast since if you pass it a NULL pointer
>for the list, it just returns the number of modules on the stream,
>and this information comes directly out of the stream head.

This was my first approach. We have access to the source code, so I used
I_GRDOPT, as this referenced a single field in the stream head, and so
was fastest.
But ... the f!@#$%^&*( SCO UNIX uses the numerical code for I_GRDOPT on
ttys to switch modes on the console windows, so when the application
calls the select()-function -whoops- goes Your screen!

--
| Josef Moellers		| c/o Siemens Nixdorf Informationssysteme AG |
|  USA: mollers.pad@nixdorf.com	| Abt. STO-XS 113			     |
| !USA: mollers.pad@nixdorf.de	| Heinz-Nixdorf-Ring			     |
| Phone: (+49) 5251 104662	| D-4790 Paderborn			     |

guy@auspex.auspex.com (Guy Harris) (01/18/91)

>I_LIST might be particularly fast since if you pass it a NULL pointer
>for the list, it just returns the number of modules on the stream,

Unless, of course, you're not running System V Release 4, in which case
it just returns an error....

I_LOOK also looks only at the stream head, although it does loop through
the table of modules to find the name.

boyd@necisa.ho.necisa.oz.au (Boyd Roberts) (01/31/91)

josef@nixpbe.nixdorf.de (josef Moellers) writes:
>
>Does anybody now of a bulletproof and FAST method to distinguish between
>a STREAMS fd and a non-STREAMS fd?
>I cannot use calls to getmsg/putmsg, as I am not allowed to change the
>state of the STREAM.
>

Why not do a putmsg() with an invalid pointer to the message? -- gag.

EFAULT tells you that it's a stream.


Boyd Roberts			boyd@necisa.ho.necisa.oz.au

``When the going gets wierd, the weird turn pro...''