File Transfer to and From Minix-under-Bochs

modified: Sun Jan 19 08:53:35 EST 1997


---------- Forwarded message ----------
Date: Fri, 17 Jan 1997 21:14:14 -0500 (EST)
From: Bradley C. Kuszmaul 
To: awoodhull@hamp.hampshire.edu
Subject: Re: How to import files from unix to minix running under the bochs 386 simulator

     How to Import Files from Unix to Minix-Running-Under-Bochs.
			 Bradley C. Kuszmaul
			   Yale University
			 bradley@cs.yale.edu
			     Jan 17 1996

Suppose you have directory 
 ~yourname/hello/
on your unix system (say Linux) that you want to import into Minix
running under bochs.
 
Do the following:

 linux% cd ~yourname
 linux% tar cf - hello > hello.tar
 linux% compress hello.tar
 linux% pad 1474560 < hello.tar.Z > 1.44

(This creates a 1.44 megabyte file whose first bytes are hello.tar.Z)
then edit your .bochsrc so that it contains the line

floppya: file=./1.44

Then startup bochs, boot minix, and login (as bin) then do
 minix% vol -r /dev/fd0 | uncompress | tar xf -

The "pad" command mentioned above is implemented by the following C
program.  There is probably some standard unix program that does this,
but I couldn't figure out what it was.

To go the other way, from minix to unix you can reverse the process:
 minix% tar cf - hello > hello.tar
 minix% compress hello.tar
 minix% vol -w /dev/fd0<hello.tar.Z

Then in the unix world you can do
 linux% uncompress -c 1.44|tar xf -
 
The same tricks supposedly work if you actually use a real 1.44
megabyte floppy disk drive instead of a disk image (but of course you
don't need the "pad" program if you are writing to a real floppy.)

---- pad.c ----
#include<stdio.h>
#include<stdlib.h>

void print_usage (void) {
  fprintf(stderr,"Usage:\n");
  fprintf(stderr,"  pad SIZE < input.file > output.file\n");
  fprintf(stderr,"copies stdin to stdout then outputs enough 0's to make the total size\n");
  fprintf(stderr,"of stdout equal to SIZE (in bytes)\n");
  fprintf(stderr,"\nAuthor: Bradley C. Kuszmaul, bradley@cs.yale.edu");
  fprintf(stderr,"Copyright 1997 Yale University.\n");
  fprintf(stderr,"There is no warranty for this free software.\n");
  fprintf(stderr,"Distributed under the terms of the Gnu Public\n");
  fprintf(stderr,"  License, available in the usual places on the web.\n");
  fprintf(stderr,"  And there ain't no insanity clause.\n");
}
  
main (int argc, char *argv[]) {
  int size;
  char *endptr;
  int datum;
  if (argc!=2) {
    fprintf(stderr,"Expected one argument\n");
    print_usage();
    exit(1); }
  size = strtol(argv[1], &endptr, 0);
  if (*endptr!=0) {
    fprintf(stderr,"Expected a well formed integer, found %s\n",argv[1]);
    print_usage();
    exit(1);
  }
  if (size<=0) {
    fprintf(stderr,"Expected a positive integer, found %d\n",size);
    print_usage();
    exit(1);
  }
  while ((datum=getc(stdin))!=EOF) {
    putc(datum,stdout);
    size--;
  }
  if (size<0) {
    fprintf(stderr,"The standard input was bigger than the specified padding size by %d bytes\n",-size);
    exit(2);
  }
  while (size>0) {
    putc(0,stdout);
    size--;
  }
  return 0;
}
---- end of pad.c ----