[Previous]
[Contents]
[Next]

dev_info()

return information about the terminal device associated with a file

Synopsis:

#include <sys/dev.h>
int dev_info( int fd,
              struct _dev_info_entry *info );

Description:

The dev_info() function returns information about the terminal device associated with the file descriptor given in fd.

If the call is successful, the structure pointed to by info contains data in the following members:

int tty
TTY number of this device.
int unit
Unit number of this device. (for example, /dev/con2 would have a unit of 2).
nid_t nid
The node-id where this device exists.
pid_t driver_pid
Process ID of the driver task that controls this device.
char driver_type[16]
A symbolic name describing the nature of this device.
char tty_name[MAX_TTY_NAME]
A complete pathname that may be used to open this device.

The (nid, tty) pair uniquely identifies the terminal device that is associated with fd. As shown in the example, these values can be used to build a pathname for this device.

The symbolic name given in driver_type() is intended to allow applications to identify the type of device that is being referred to by fd. Examples of currently defined strings for driver_type() are:

console
Console device
serial
Asynchronous Serial device
parallel
Parallel (printer) device
netlink
Network link
pseudo
Pseudo terminal device (for example, pty)

The (nid, driver_pid) pair can be used to identify the process that controls a particular device. Device-dependent control messages can often be sent to these driver processes to alter the behavior of that particular device.

Returns:

Zero on success. The structure pointed to by info contains information about the file descriptor fd. A return of -1 indicates failure, in which case the global variable errno is set, and the info structure is not filled.

Errors:

ENOSYS
The dev_info() function is not supported for this fd.
EBADF
The fd argument is invalid.

Examples:

#include <sys/dev.h>
#include <stdio.h>

int main( void )
  {
    struct _dev_info_entry info;

    if( dev_info( 0, &info ) == 0 ) {
      printf( "NODE %d,TTY %d\n", info.nid, info.tty );
      printf( "also known as: %s\n", &info.tty_name[0] );
      printf( "is a %s device\n", &info.driver_type[0] );
    }
    return( EXIT_SUCCESS );
  }

Classification:

QNX

Safety:
Interrupt handler No
Signal handler Yes, but modifies errno
Thread Yes

See also:

errno, open()


[Previous]
[Contents]
[Next]