Date: Sat, 1 Feb 1997 20:31:30 +0100 From: j@uriah.heep.sax.de (J Wunsch) To: freebsd-scsi@FreeBSD.org (FreeBSD SCSI list) Cc: Don.Lewis@tsc.tdk.com (Don Lewis) Subject: Re: SCSI disk MEDIUM ERROR with a few twists Message-ID: <Mutt.19970201203130.j@uriah.heep.sax.de> In-Reply-To: <199702011808.NAA16376@hda.hda.com>; from Peter Dufault on Feb 1, 1997 13:08:55 -0500 References: <199702011537.HAA28985@salsa.gv.tsc.tdk.com> <199702011808.NAA16376@hda.hda.com>
next in thread | previous in thread | raw e-mail | index | archive | help
As Peter Dufault wrote: > I also put together a defect list dumper for Satoshi when he was > having some problems, so I'm putting that here too. Neat! I've combined both, since this is really easier to handle in Perl. Maybe we should put this up under tools/? #!/usr/bin/perl sub usage { die "usage: defect raw-device-name [Glist|Plist]\n"; } # # Main # &usage if $#ARGV < 0 || $#ARGV > 1; $ENV{'PATH'} = "/bin:/usr/bin:/sbin:/usr/sbin"; $dev = $ARGV[0]; # generic device name given? if ($dev =~ /^[so]d\d+$/) { $dev = "/dev/r${dev}.ctl"; } # # Select what you want to read. PList include the primary defect list # from the factory. GList is grown defects only. # if ($#ARGV > 0) { if ($ARGV[1] =~ /^[Gg]/) { $glist = 1; $plist = 0; } elsif ($ARGV[1] =~ /^[Pp]/) { $glist = 0; $plist = 1; } else { &usage; } } else { $glist = 1; $plist = 0; } open(PIPE, "scsi -f $dev " . "-c '{ Op code} 37 0 0:3 v:1 v:1 5:3 0 0 0 0 4:i2 0' $plist $glist " . "-i 4 '{ stuff } *i2 { Defect list length } i2' |") || die "Cannot pipe from scsi(8)\n"; chop($amnt = <PIPE>); close(PIPE); if ($amnt == 0) { print "There are no defects (in this list).\n"; exit 0; } print "There are " . $amnt / 8 . " defects in this list.\n"; $amnt += 4; open(PIPE, "scsi -f $dev " . "-c '{ Op code} 37 0 0:3 v:1 v:1 5:3 0 0 0 0 v:i2 0' $plist $glist " . "$amnt -i $amnt - |") || die "Cannot pipe from scsi(8)\n"; read(PIPE, $buf, 4); # defect list header print "cylinder head sector\n"; while(read(PIPE, $buf, 8)) { ($cylhi, $cyllo, $head, $sec) = unpack("CnCN", $buf); printf "%8u %4u %6u\n", $cylhi*65536+$cyllo, $head, $sec; } close(PIPE); -- cheers, J"org joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE Never trust an operating system you don't have sources for. ;-)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Mutt.19970201203130.j>