NAME

Solaris::DeviceTree::Util - Mixin class devicetrees

DESCRIPTION

This class acts as a mixin class for several methods which are available to all subclasses of Solaris::DeviceTree.

METHODS

The following methods are available:

if( $node->is_network_node ) { ... }

This method returns true if the node represents a network card.

if( $node->is_block_node ) { ... }

This method returns true if the node represents a block device (which is essentially a disk).

if( $node->is_controller_node ) { ... }

This method returns true if the node represents a controller device.

@network_nodes = $node->network_nodes

This method returns all nodes for network cards in the tree.

@block_nodes = $node->block_nodes

This method returns all nodes for disks in the tree.

@controller_nodes = $node->controller_nodes

This method returns all nodes for controller devices.

$node = $node->find_nodes( devfs_path => '/pci@1f,0/pci@1f,2000' );

This method returns nodes matching certain criteria. Currently it is possible to match against a physical path or to specify a subroutine where the node is returned if the subroutine returns true. As in Perl grep $_ is locally bound to the node being checked.

In a scalar context the method returns only the first node found. In an array context the method returns all matching nodes.

$node = $node->find_nodes( devfs_path => '/pci@1f,0/pci@1f,2000' );
@nodes = $node->find_nodes( func => sub { $_->is_network_node } );

my $prop = $node->find_prop( devfs_path => '/aliases', prop_name => 'disk' );

This method picks a node by criteria from the devicetree and then selects either a property or a prom property depending on the options given. At least one of

prop_name
prom_prop_name

must be specified. All options valid for find_nodes are also applicable to this method.

find_minor_node( name => ':a' );

my $solaris_path = $node->solaris_path

This method converts between an OBP device path and a Solaris device path.

The conversion is quite complex. As a first step the IOCTLS OPROMDEV2PROMNAME (OIOC | 15) /* Convert devfs path to prom path */ OPROMPROM2DEVNAME (OIOC | 16) /* Convert devfs path to prom path */ might be taken. However, some older machines are not aware of that. It would be optimal to use devfs_dev_to_prom_name from libdevinfo, but that one is static and reprogramming that one is *not* fun.

%aliases = %{$node->aliases};

This method returns a hash reference which maps all aliases to their corresponding pathes.

$chosen_boot_device = $root->obp_chosen_boot_device;

This method returns the device from which the system has most recently booted.

@boot_devices = $root->obp_boot_devices;

This method returns a list with all boot devices entered in the obp.

@diag_devices = $root->obp_diag_devices;

This method returns a list with all diag devices entered in the obp.

my $name = $node->solaris_device

This method returns the name of the associated Solaris device. This is for example

c0t0d0s0   for a disk device
hme0       for a network device
rmt0       for a tape device

or undef if no Solaris device could be found.

EXAMPLES

AUTHOR

Copyright 1999-2003 Dagobert Michelsen.

SEE ALSO