SUMMARY: Checking for installed display card

From: David Steiner (dsteiner@ispa.uni-osnabrueck.de)
Date: Wed Jan 24 1996 - 02:25:14 CST


Greetings and Thanks!

My original question (paraphrased) was:

We have a mixed bag of workstations running SunOS 4.1.x, with a number of
different graphics cards. In order to display correctly, our software
requires OpenWindows to be started with different parameters depending on the
installed card. How can I check for this from a startup script?

The ideas that I thought of were:

- Hardwire the GS-equipped hostnames in the script, i.e.

    if [ `hostname` = "gshost" ]; then ...

- Put a file somewhere like /etc and test for it, i.e.

    if [ -f /etc/has_gs ] ; then ...

I dismissed these, they require rewriting the script if the hardware
configuration changes (e.i., a graphics card is moved from one machin to
another).

The most common suggestion from the group was to grep the output of dmesg
or /var/adm/messages (actually the same). This is ok but prone to failure
in two cases. The first (and perhaps least likely) is right after a hardware
configuration change when the boot messages from before and after the
the change are still in the messages file. This means that there will be
2 graphics cards reported by the grep.

The second case (and the reason it will not work for me) is if the site
regularly rotates log files to manage space. After the first log rotation,
there are no more boot messages in the file, hence no reported graphics
device.

One person did supply me with an excellent solution (thanks to William T.
Reckas <zeke@fnoc.navy.mil>). He provided me with a short little C program
that checks to see what card is installed and output an appropriate string
which can then be used in a case statement in the script to set the
appropriate parameters. I have included a copy of his message below my
sig (with his permission).

One caveat: The program needs to be modified when a _new_type_ of graphics
card is installed on a machine. For us, this is not as likely to happen
as moving a card from one machine to another and is, therefore, more acceptable
than the hardwire scripts method.

Finally, this whole thing is much easier for Solaris 2.x since it has a
prtconf command which can be grepped.

Once again, thanks to all who responded.

-David-

David R. Steiner University of Vechta
Research Assoc. _____ ___ ____ __
Remote Sensing/GIS // // // `` // |
                                            // === //='' //--|
email: dsteiner@ispa.uni-osnabrueck.de _//_ __// _//_ _//_ _|_
fax:(+49)4441-15445 Vechta, Germany

* All decisions are based on insufficient evidence. -Nickel Hunsenmeir *

----- Begin Included Message -----

>From zeke@fnoc.navy.mil Fri Jan 19 17:49:58 1996
From: zeke@fnoc.navy.mil (William T. Reckas)
Subject: Re: Checking for installed display card
To: dsteiner@ispa.uni-osnabrueck.de
Date: Fri, 19 Jan 96 16:47:58 GMT
Reply-To: zeke@fnoc.navy.mil
X-Mailer: ELM [version 2.3 PL11]
Content-Length: 5227

Well, what we have done here is to write a simple program
(included below) that tries to open up various devices. If
it successfully opens it, it outputs a string which
a script can then key off of to take necessary actions.

Please note that I have not tried this on Solaris, only SunOS, but
it should be easily ported if it does not work directly.

Here is the program (check_graphics_device.c) :

*******************************************************************
*******************************************************************

#include <fcntl.h>
#include <stdio.h>

#define NUMBER_OF_DEVICES 3
/*
 * The following define is for the name of the path to the
 * device. Typically this will be /dev/xxx, but we will make
 * it slightly larger just in case someone wants to check a
 * device elsewhere.
 */

#define DEVICE_NAME_LENGTH 60

#define NAME_LENGTH 20

struct {
   char device[DEVICE_NAME_LENGTH+1] ;
   char name[NAME_LENGTH+1] ;
   } gdevices[ NUMBER_OF_DEVICES ] =
      { "/dev/cgsix0" , "cgsix",
        "/dev/cgtwelve0", "cgtwelve",
        "/dev/xfb0" , "megatek" } ;

main()
   {
   int i, fd ;

   for ( i=0 ; i<NUMBER_OF_DEVICES ; i++ )
      {
      fd = open( gdevices[i].device, O_RDONLY ) ;

      if( fd >= 0 )
         {
         (void) close( fd ) ;

         printf("%s\n", gdevices[i].name );
         exit( 0 ) ;
         }
      }
   printf( "unknown\n" ) ;
   exit( 1 ) ;
   }
*******************************************************************
*******************************************************************

Then within our script (that starts X in this instance), we have
something like the following (feel free to set parameters as necessary) :

******************************************************************
******************************************************************

#
# Try to determine which X server to start depending upon the graphics
# card that is found in this workstation.
#
card=`check_graphics_device`

case "$card" in
   megatek)
      x_server=/usr/X11R5/bin/Xmeg

      if [ ! -x $x_server ] ; then
         echo "Megatek X server is not available."
         exit 2
      fi
      ;;
   bwtwo | cgtwo | cgthree | cgfour | cgsix)
      x_server=/usr/X11R5/bin/Xsun

      if [ ! -x $x_server ] ; then
         echo "Sun X server is not available."
         exit 2
      fi
      ;;
   cgtwelve)
      x_server=/usr/openwin/bin/xnews

      if [ ! -x $x_server ] ; then
         echo "24 bit X server is not available."
         exit 2
      fi
      ;;
   *)
      echo "Unknown graphics system."
      exit 3
      ;;
esac

******************************************************************
******************************************************************

Regards.

David Steiner writes
>
> Hello, Managers.
[ original post snipped ]
>

-- 
William T. Reckas        Ogden Professional Services        zeke@fnoc.navy.mil
Fleet Numerical Meteorology and Oceanography Center     Phone:  (408) 656-4620
7 Grace Hopper Ave, Stop 1                              FAX:    (408) 656-4489
Monterey, CA 93943-5501

"Sure, women expect us to think all of the time, but who can ? It takes a lot of energy that would be better spent trying to find the Makita saw she took and somehow misplaced." - Tim Allen (on wives)

----- End Included Message -----



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:10:51 CDT