#!/usr/bin/perl # # Copyright © 2015-2020 by Vincent Slyngstad # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including # without limitation the rights to use, copy, modify, merge, publish, # distribute, sublicense, and/or sell copies of the Software, and to # permit persons to whom the Software is furnished to do so, subject to # the following conditions: # # The above copyright notice and this permission notice shall be # included in all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS LISTED ABOVE BE LIABLE # FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF # CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the names of the authors above # shall not be used in advertising or otherwise to promote the sale, use # or other dealings in this Software without prior written authorization # from those authors. # # OK, time for a bigger hammer. # DUMPRX01 has generated a bytewise dump of the media, # in hardware sector/track order. Problem is, there # are several schemes, involving 8 or 12 bit mode, # for encoding the interesting 12 bit words on the # media. Here, we look at every single sector, with # known encodings, trying to find things that look # like they might be the OS/8 directory segment # headers. # This does assume that every OS/8 block starts on # a sector boundary, which ought to be the case. # Check if this might be a directory segment, report if so. sub isdirseg { local($fmt, $nseg, $sblk, $link, $flag, $aiw) = @_; # Number of entrees this segment should be negative. $nseg -= 010000 unless $nseg == 0; # Form two's complement # return unless $nseg >= -40; # ...but not more than 40 files/segment. $aiw -= 010000 unless $aiw == 0; # Form two's complement return unless $aiw <= 0; # Expect a negative or zero aiw. return unless $aiw > -2; # Expect 0 or -1. #return unless $link == 2; return unless ($sblk == 0070) || ($sblk == 0007); printf "$f: sector 0%06o is plausible ($nseg, %04o, $aiw, $fmt)\n", $sec, $sblk; } # The main loop just feeds sectors to the subroutines. foreach $f (@ARGV) { open(INPUT, $f) || die "$f: $!"; binmode(INPUT); $size = 0200 * 2; # 128 words for ($sec = 0; ; $sec++) { $spos = $sec * $size; seek(INPUT, $spos, 0) || die "seek($f): $!"; $count = read(INPUT, $buf, $size); last unless $count; die "read($f): $!" if $count < 0; @buf = unpack("S*", $buf); $fmt = "os8"; $nseg = $buf[0]; $sblk = $buf[1]; $link = $buf[2]; $flag = $buf[3]; $aiw = $buf[4]; &isdirseg($fmt, $nseg, $sblk, $link, $flag, $aiw); } } exit 0;