Author: sparky
Date: Sat Mar  4 15:54:29 2006
New Revision: 7084

Added:
   ppcrcd/trunk/conf.dir/usr/lib/ppcrcd/find_md   (contents, props changed)
Modified:
   ppcrcd/trunk/conf.dir/usr/lib/ppcrcd/hw-detect
Log:
- added md-detection script, not tested


Added: ppcrcd/trunk/conf.dir/usr/lib/ppcrcd/find_md
==============================================================================
--- (empty file)
+++ ppcrcd/trunk/conf.dir/usr/lib/ppcrcd/find_md        Sat Mar  4 15:54:29 2006
@@ -0,0 +1,72 @@
+#!/usr/bin/perl
+#
+# script to find and prepare md devices
+#      (c) 2006 [EMAIL PROTECTED]
+use strict;
+use warnings;
+
+my $verbose = shift @ARGV || 0;
+( my $prog = $0 ) =~ s#.*/##;
+
+sub verbose {
+       my $verb = shift;
+       return if $verb > $verbose;
+       my $msg = shift;
+
+       warn "$prog: $msg\n";
+}
+
+verbose(1, "Detecting md devices");
+my %by_uuid;
+my $found = 0;
+
+opendir D_IN, "/dev";
+while (my $f = readdir D_IN ) {
+       next unless $f =~ /^[sh]d[a-z][0-9]*$/;
+       my @out = `mdadm -E /dev/$f 2>&1`;
+       if ( $? != 0 ) {
+               print "$f\n" if $f =~ /^[sh]d[a-z][0-9]+$/;
+               next;
+       }
+       
+       my ($uuid) = grep /UUID/, @out;
+       chomp $uuid;
+       $uuid =~ s/\s*UUID\s*:\s*//;
+       unless ( length $uuid ) {
+               print "$f\n" if $f =~ /^[sh]d[a-z][0-9]+$/;
+               next;
+       }
+       verbose(4, "   +-Found /dev/$f ($uuid)");
+       push @{$by_uuid{$uuid}}, $f;
+       $found++;
+}
+closedir D_IN;
+
+unless ( $found ) {
+       verbose(4, "   No devices found");
+       exit;
+}
+my $cnt = 0;
+
+open MD_OUT, ">> /etc/mdadm.conf";
+open FS_OUT, ">> /etc/fstab";
+open MO_OUT, "> /etc/modprobe.d/md.conf";
+printf MD_OUT "\n# automatically generated\n";
+foreach my $uuid ( sort keys %by_uuid ) {
+       # dirname: ex: md0_hda2hdc2
+       my $dirname = "md${cnt}_" . join '', sort @{$by_uuid{$uuid}};
+       verbose(2, "  Preparing /dev/$dirname");
+       
+       printf MD_OUT "DEVICE ", join " /dev/", ('', @{$by_uuid{$uuid}});
+       printf MD_OUT "\nARRAY /dev/md$cnt uuid=$uuid\n";
+       
+       printf FS_OUT "/dev/md$cnt /mnt/$dirname auto defaults 0 0\n";
+       mkdir "/mnt/$dirname";
+       
+       printf MO_OUT "install block-major-9-$cnt /sbin/mdadm --assemble --scan 
/dev/md$cnt\n";
+       system("mknod /dev/md$cnt b 9 $cnt");
+       $cnt++;
+}
+close MD_OUT;
+close FS_OUT;
+close MO_OUT;

Modified: ppcrcd/trunk/conf.dir/usr/lib/ppcrcd/hw-detect
==============================================================================
--- ppcrcd/trunk/conf.dir/usr/lib/ppcrcd/hw-detect      (original)
+++ ppcrcd/trunk/conf.dir/usr/lib/ppcrcd/hw-detect      Sat Mar  4 15:54:29 2006
@@ -67,7 +67,11 @@
 mac-fdisk -l 2>/dev/null | egrep "^/dev/[a-z]+[0-9]+" > /tmp/parts.mac
 fdisk -l 2>/dev/null | egrep "^/dev/[a-z]+[0-9]+" > /tmp/parts.pc
 
-for dev in /dev/hd??* /dev/sd??*; do
+PARTS=$(echo /dev/hd??* /dev/sd??*)
+cmdopt nomd || \
+       PARTS=$(/usr/lib/ppcrcd/find_md $(< /verbose) | sort)
+
+for dev in $PARTS; do
        [ -r $dev ] || continue
        verbose 4 "    +-Checking $dev"
        mnt="/mnt/$(basename $dev)"
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to