From owner-freebsd-scsi Sat Feb 1 11:51:42 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id LAA06379 for freebsd-scsi-outgoing; Sat, 1 Feb 1997 11:51:42 -0800 (PST) Received: from sax.sax.de (sax.sax.de [193.175.26.33]) by freefall.freebsd.org (8.8.5/8.8.5) with SMTP id LAA06374 for ; Sat, 1 Feb 1997 11:51:39 -0800 (PST) Received: (from uucp@localhost) by sax.sax.de (8.6.12/8.6.12-s1) with UUCP id UAA14866; Sat, 1 Feb 1997 20:51:37 +0100 Received: (from j@localhost) by uriah.heep.sax.de (8.8.5/8.6.9) id UAA29862; Sat, 1 Feb 1997 20:31:30 +0100 (MET) Message-ID: 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 References: <199702011537.HAA28985@salsa.gv.tsc.tdk.com> <199702011808.NAA16376@hda.hda.com> X-Mailer: Mutt 0.55-PL10 Mime-Version: 1.0 X-Phone: +49-351-2012 669 X-PGP-Fingerprint: DC 47 E6 E4 FF A6 E9 8F 93 21 E0 7D F9 12 D6 4E Reply-To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch) In-Reply-To: <199702011808.NAA16376@hda.hda.com>; from Peter Dufault on Feb 1, 1997 13:08:55 -0500 Sender: owner-freebsd-scsi@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk 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 = ); 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. ;-)