Subject: Linux/SGI: Xsgi Shmiq/Qcntl

From: Miguel de Icaza <[email-masked]>
Date: Wed, 10 Sep 1997 22:03:09 -0500

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. 

Cheers,
Miguel.

---

From: Mike Shaver <[email-masked]>
Date: Thu, 11 Sep 1997 00:52:56 -0400 (EDT)

> mistery_variable.  I am obviously screwing something in the shmiq

If it's like the rest of the shmiq stuff, it's probably the minor
number.   Remind me to test that stuff better now that I have an
Indy. =)

Mike

-- 
#> Mike Shaver ([email-masked])      Information Warfare Division  
#> Chief Tactical and Strategic Officer         "Saepe fidelis"        
#>                                                                     
#> "I like your game, but we have to change the rules." -- Anon        
#>

---

From: "William J. Earl" <[email-masked]>
Date: Thu, 11 Sep 1997 17:55:16 -0700

> mistery_variable.  I am obviously screwing something in the shmiq

	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.