NAME

Solaris::DeviceTree - Perl interface to the Solaris devicetree

SYNOPSIS

use Solaris::DeviceTree
my $tree = new Solaris::DeviceTree;
my @children = $tree->children;

DESCRIPTION

The Solaris::DeviceTree module implements access to the Solaris device information. The information is collected from the kernel via access to libdevinfo, the contents of the file /etc/path_to_inst and the filesystem entries below /dev and /devices. The devicetree is presented as a hierarchical collection of node. Each node contains the unified information from all available resources.

METHODS

The following methods are available:

$devtree = Solaris::DeviceTree->new

$devtree = Solaris::DeviceTree->new( use => [ qw( libdevinfo path_to_inst filesystem ) ] );

The constructor returns a reference to a Solaris::DeviceTree object which itself implements the Solaris::DeviceTree::Node interface. The instance returned represents the root-node of the devicetree.

$devtree->DESTROY;

This methos removes all internal data structures which are associated with this object.

@children = $devtree->child_nodes

This method returns a list with all children.

$node = $devtree->parent_node

Returns the parent node for the object. If the object is toplevel, then undef is returned.

$node = $devtree->root_node

Returns the root node of the tree.

@siblings = $devtree->sibling_nodes

Returns the list of siblings for the object. A sibling is a child from our parent, but not ourselves.

$path = $devtree->devfs_path

Returns the physical path assocatiated with this node.

$nodename = $devtree->node_name;

Returns the name of the node.

$bindingname = $devtree->binding_name;

Returns the binding name for this node. The binding name is the name used by the system to select a driver for the device.

$busadr = $devtree->bus_addr;

Returns the address on the bus for this node. undef is returned if a bus address has not been assigned to the device. A zero-length string may be returned and is considered a valid bus address.

$instance = $devtree->instance;

Returns the instance number of the driver bound to the node. If no driver is bound to the node undef is returned.

@compat_names = $devtree->compatible_names;

Returns the list of names from compatible device for the current node. See the discussion of generic names in "Writing Device Drivers" for a description of how compatible names are used by Solaris to achieve driver binding for the node.

$devid = $devtree->devid

Returns the device ID for the node, if it is registered. Otherwise, undef is returned.

$drivername = $devtree->driver_name;

Returns the name of the driver for the node or undef if the node is not bound to any driver.

@minor = @{$node->minor_nodes}

Returns a list of all minor nodes which are associated with this node. The minor nodes are of class Solaris::DeviceTree::MinorNode.

EXAMPLES

use Solaris::DeviceTree;

my $t = Solaris::DeviceTree->new( use => [ qw( path_to_inst ) ] );
my @nodes = ( $t );
while( @nodes > 0 ) {
  my $node = shift @nodes;
  print $node->devfs_path, "\n";
  unshift @nodes, $node->child_nodes;
}

AUTHOR

Copyright 1999-2003 Dagobert Michelsen.

SEE ALSO

Solaris::DeviceTree::PathToInst, Solaris::DeviceTree::Filesystem, Solaris::DeviceTree::Libdevinfo.

BUGS

* As an additional feature access to the libcfgadm should be included.