Mkdisttap.pl

From Computer History Wiki
Revision as of 16:50, 6 February 2009 by 71.87.172.177 (talk) (Initial Version)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This is a simple perl script to create a tape suitable for SIMH to use. Importantly, it places end of file markers so you can have multiple files on a 'tape' image, much like how a real tape operates.

The following is the script formatted for 4.3 BSD Quasijarus 0c, however it can easily be adapted for the other BSD's.


#!/usr/local/bin/perl -w
use strict;

# Based on mkdisttap.pl
# ftp://ftp.mrynet.com/pub/os/PUPS/PDP-11/Boot_Images/2.11_on_Simh/211bsd/mkdist
tap.pl

#
# $Id: mkdisttap.pl,v 1.1 2006/09/16 23:33:46 kirk Exp kirk $
#

# Based on the example in the HOWTO using dd.  Does not work!
# add_file("cat mtboot mtboot boot |", 512);

# Based on the maketape.c program and the maketape.data data file.
add_file("stand", 512);
end_file();
add_file("miniroot", 10240);
end_file();
add_file("rootdump", 10240);
end_file();
add_file("usr.tar", 10240);
end_file();
add_file("srcsys.tar", 10240);
end_file();
add_file("src.tar", 10240);
end_file();
#add_file("install.tar", 10240);
#end_file();
#add_file("install.tar", 10240);
#end_file();
#add_file("install.tar", 10240);
#end_file();
#add_file("install.tar", 10240);
end_file();
end_file();

sub end_file {
  print "\x00\x00\x00\x00";
}

sub add_file {
  my($filename, $blocksize) = @_;
  my($block, $bytes_read, $length);

  open(FILE, $filename) || die("Can't open $filename: $!");
  while($bytes_read = read(FILE, $block, $blocksize)) {
    if($bytes_read < $blocksize) {
      $block .= "\x00" x ($blocksize - $bytes_read);
      $bytes_read = $blocksize;
    }
    $length = pack("V", $bytes_read);
    print $length, $block, $length;
  }
  close(FILE);
}