#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
use Cwd;
use strict;
package MDesc;
use constant {
MDEND => 0x45,
MDNODE => 0x4e,
MDARC => 0x61,
MDDATA => 0x64,
MDSTR => 0x73,
MDVAL => 0x76,
};
sub new {
my $class = shift;
my $self = {};
$self->{NODE_SEC_SZ} = undef;
$self->{NAME_SEC_SZ} = undef;
$self->{DATA_SEC_SZ} = undef;
return $self;
}
sub open {
my $self = shift;
if (@_) {
} else {
}
return unless open(MD, "$self->{NAME}");
# Read and parse MD header
close (MD);
return;
}
$self->{NODE_SEC_SZ},
$self->{NAME_SEC_SZ},
1;
}
#
# return hash of given node's information
#
sub getnode {
}
return %node;
}
#
# return hash of given property's information
#
sub getprop {
$prop{'string'} =
} else {
return undef;
}
return %prop;
}
#
# find name table index of given name
#
sub findname {
}
return -1;
}
#
# find given property in node
#
sub findprop {
do {
$nodeid++;
return $nodeid;
}
return -1;
}
#
# lookup property in node and return its hash
#
sub lookup {
my ($propid);
return undef if ($propid == -1);
}
sub scan_node {
my (%node);
do {
$nodeid++;
}
}
#
# scan dag from 'start' via 'arcname'
# return list of nodes named 'nodename'
#
sub scan {
return @ret;
}
package main;
#
# 'find' needs to use globals anyway,
# so we might as well use the same ones
# everywhere
#
our %opts;
#
# fix path_to_inst
#
sub fixinst {
$in = "etc/path_to_inst";
#
# first pass
# see if there are any old paths that need to be re-written
#
$found = 0;
while (<IN>) {
($path, undef, undef) = split;
$found = 1;
last;
}
}
# return if no old paths found
if ($found == 0) {
close(IN);
close(OUT);
unlink $out;
return 0;
}
print "replacing $old with $new in /etc/path_to_inst\n";
#
# 2nd pass
# substitute new for old
#
while (<IN>) {
($path, undef, undef) = split;
}
print OUT;
}
close(IN);
close(OUT);
if ($opts{v}) {
print "path_to_inst changes:\n";
print "\n";
}
return 1;
}
our $oldpat;
sub wanted {
my $targ;
-l or return;
$targ = readlink;
unlink;
symlink $targ, $_;
print "symlink $_ changed to $targ\n" if ($opts{v});
}
}
#
# fix symlinks
#
sub fixdev {
print "updating /dev symlinks\n";
}
#
# fixup path_to_inst and /dev symlinks
#
sub fixup {
# setup globals
# if fixinst finds no matches, no need to run fixdev
return if (fixinst == 0);
print "\n" if ($opts{v});
}
#
# remove caches
#
sub rmcache {
unlink "etc/devices/devid_cache";
unlink "etc/devices/devname_cache";
unlink "etc/devices/retire_store";
unlink "etc/devices/snapshot_cache";
unlink "dev/.devlink_db";
}
# $< == 0 or die "$0: must be run as root\n";
if ($opts{R}) {
chdir $opts{R} or die "can't chdir to $opts{R}\n";
}
if ($#ARGV == 1) {
#
# manual run (no MD needed)
#
exit;
}
#
# scan MD for ioaliases
#
$md->open;
$#nodes == 0 or die "missing ioaliases node\n";
#
# foreach ioalias node, replace any 'alias' paths
# with the 'current' one
#
# complicating this is that the alias paths can be
# substrings of each other, which can cause false
# hits in /etc/path_to_inst, so first gather all
# aliases with the same root into a list, then sort
# it by length so we always fix the longer alias
# paths before the shorter ones
#
if ($slash == -1) {
} else {
}
}
}
my $aref;
}
}