Miguel de Icaza writes:
>
> Hello guys,
>
> Ok, 120 system calls after the last one, I need some more help.
> If somebody can quickly look up the IRIX X sources, I would appreciate
> if you could tell me how a little routine works.
>
> The source code should be in a directory called:
> xc/programs/Xserver/hw/sgi
>
> The code does an open on /dev/shmiq and then opens: sprintf (buf,
> "/dev/qcntl%d", mistery_variable) I want to know how it computes
> mistery_variable. I am obviously screwing something in the shmiq
> emulation code.
fd = open( SHMIQDEVNAME, O_EXCL | O_RDWR | O_NOCTTY ) ;
if ( fd < 0 ) {
perror( "Failed to open shmiq device." ) ;
return 0 ;
}
/* Now open the control character device */
if ( fstat ( fd, &sb ) < 0 ) {
perror( "fstat failed -- shmiq not opened." ) ;
(void) close( fd ) ;
return 0 ;
}
(void) sprintf( cntldev, QCNTLDEVFORMAT, minor( sb.st_rdev ) ) ;
The /dev/qcntl2 device is the control device for minor device 2 as returned
by the clone open of /dev/shmiq. A clone device returns a different
minor device for each open call; minor device numbers are reused only
after they have been closed. Similary, /dev/ptc is a clone device for getting
PTYs.
|