Difference between revisions of "Mkdisttap.pl"

From Computer History Wiki
Jump to: navigation, search
(added sections for Quas & 4.2)
Line 64: Line 64:
 
</pre>
 
</pre>
  
== 4.2 BSD ==
+
== 4.2 & 4.3 BSD ==
  
This is the format of the script to generate 42.tap for 4.2 BSD
+
This is the format of the script to generate 42.tap for [[4.2 BSD]], and the 43.tap for [[4.3 BSD]].
  
 
<pre>
 
<pre>

Revision as of 21:19, 6 February 2009

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.

Quasijarus 0c

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/mkdisttap.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);
}

4.2 & 4.3 BSD

This is the format of the script to generate 42.tap for 4.2 BSD, and the 43.tap for 4.3 BSD.

#!/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("srcsys.tar", 10240);
end_file();
add_file("usr.tar", 10240);
end_file();
add_file("vfont.tar", 10240);
end_file();
add_file("src.tar", 10240);
end_file();
add_file("new.tar", 10240);
end_file();
add_file("ingres.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);
}