Advertisement
robn

Untitled

Oct 17th, 2012
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.66 KB | None | 0 0
  1. sub do_x4500 {
  2.   # X4500s have six Marvell SATA controllers
  3.   my @pci = grep { chomp } `/usr/bin/lspci | grep Marvell | cut -f1 -d' '`;
  4.   return if @pci != 6;
  5.  
  6.   # can only boot from controller 4, disk 0 and 4. (Solaris calls them c8t0 and c8t4)
  7.   my $c = $pci[3];
  8.  
  9.   # find the disks
  10.   opendir (my $dh, "/dev/disk/by-path") || exit 1;
  11.   my @disks = sort grep { m/^pci-0000:$c-scsi-[04]:0:0:0$/ } readdir $dh;
  12.   closedir $dh;
  13.  
  14.   # and find out where they go
  15.   my (@targets) = map { (m{/([^/]+)$})[0] } map { readlink $_ } @disks;
  16.  
  17.   # XXX for the moment, just take the first one. later we should mirror them
  18.   my ($target) = @targets;
  19.  
  20.   return $target;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement