[comp.unix.ultrix] How to duplicate the Ultrix distribution TK50's?

weis@netmbx.UUCP (Dietmar Weis) (06/05/91)

It can't be done with dd, there must be something special.
(I tried it with bs=10k (good for layered products tapes, but not for
at least the supported subset vol. 1.))

Thanks,
Dietmar

-- 
weis@netmbx.UUCP         | Dietmar Weis         DONOP CONSULT GmbH
Voice: 030/884 28 54-0   |                      Uhlandstrasse 179/180
Fax:   030/882 55 29     |                      D - 1000 Berlin 12

aej@manyjars.WPI.EDU (Allan E Johannesen) (06/05/91)

>>>>> On 5 Jun 91 11:54:11 GMT, weis@netmbx.UUCP (Dietmar Weis) said:

weis> It can't be done with dd, there must be something special.  (I
weis> tried it with bs=10k (good for layered products tapes, but not
weis> for at least the supported subset vol. 1.))

I'll mail you my cheap programs to copy tape to disk and disk to tape
(I only have one drive).  Essentially, the problem is the varying
block sizes of the different tape files, and also of copying all the
files on the tape (the first is only a boot file, if it's nonempty).

karrer@bernina.ethz.ch (Andreas Karrer) (06/05/91)

weis@netmbx.UUCP (Dietmar Weis) writes:

>It can't be done with dd, there must be something special.
>(I tried it with bs=10k (good for layered products tapes, but not for
>at least the supported subset vol. 1.))

it can be done with dd. On a bootable tape (like supported subset vol.1)
the first two files are written with bs=512, all other files with bs=10k.

on a "continuation tape" (like supported Vol. 2) all files are bs=10k.

+-----------
  Andi Karrer, Communication Systems, ETH Zuerich, Switzerland
  karrer@bernina.ethz.ch                 - terible simplifieur

aej@manyjars.WPI.EDU (Allan E Johannesen) (06/06/91)

Since mail bounces, here are the tape-to-disk and disk-to-tape
programs:

#include <sys/file.h>
#include <stdio.h>

int tape, disk, l_read, anything = 1, file_number = 0, files = 0, sfile;
#define l_block 10240
char block[l_block], fname[100], sname[100], *tapename, *getenv();

void
get_tape_name()
{ if ((tapename = getenv("TAPE")) == (char *) NULL)
    tapename = "/dev/nrmt0h";
}
    
main(argc,argv)
int argc;
char **argv;
{ if (argc != 2)
    { printf("usage:\nto-disk set-name\nenv TAPE is tape name, else /dev/nrmt0h\n");
      exit(1); };
  get_tape_name();
  while (anything)
    { if ((tape = open(tapename,O_RDONLY)) < 0)
	{ perror("Couldn't open tape");
	  exit(1); };

      sprintf(fname,"%s.%d",argv[1],file_number);
      sprintf(sname,"s%s.%d",argv[1],file_number++);

      if ((disk = open(fname,O_WRONLY|O_CREAT,0640)) < 0)
	{ perror("Couldn't open disk");
	  exit(1); };

      if ((sfile = open(sname,O_WRONLY|O_CREAT,0640)) < 0)
	{ perror("Couldn't open size file");
	  exit(1); };

      anything = 0;

      while ((l_read = read(tape,block,l_block)) > 0)
	{ if (anything++ == 0) files++;
	  if (sfile)
	    { char length[20];
	      sprintf(length,"%d\n",l_read);
	      write(sfile,length,strlen(length));
	      close(sfile);
	      sfile = 0; };
	  write(disk,block,l_read); };

      close(disk);
      if (anything)
	if (anything == 1)
	  printf("file %d, 1 block.\n",file_number);
	else
	  printf("file %d, %d blocks.\n",file_number,anything);
      else
	{ printf("file %d, empty.\n",file_number);
	  unlink(fname); };

      close(tape);

      if (file_number < 3)
	anything = 1; };

  printf("done, %d files\n",files); }

disk-to-tape:

#include <stdio.h>
#include <sys/file.h>
#include <stdio.h>

FILE *size;
int tape, disk, l_read, anything = 1, file_number = 0, files = 0, block_size;
#define l_block 10240
char block[l_block], fname[100];

main(argc,argv)
int argc;
char **argv;
{ if (argc != 2)
    { printf("usage:\nto-tape disk-set-name\n");
      exit(1); };
  while (anything)
    { if ((tape = open("/dev/nrmt0h",O_WRONLY)) < 0)
	{ perror("Couldn't open tape");
	  exit(1); };

      sprintf(fname,"%s.%d",argv[1],file_number);

      if ((disk = open(fname,O_RDONLY)) < 0)
	break;

      sprintf(fname,"s%s.%d",argv[1],file_number++);
      if ((size = fopen(fname,"r")) == (FILE *) NULL)
	{ perror("size not found");
	  exit(1); };

      fgets(block,100,size);
      fclose(size);
      sscanf(block,"%d",&block_size);

      printf("file %d blocksize %d ",file_number,block_size);
      fflush(stdout);

      anything = 0;

      while ((l_read = read(disk,block,block_size)) > 0)
	{ anything++;
	  write(tape,block,l_read); };

      close(disk);
      if (anything == 1)
	printf("1 block.\n");
      else
	printf("%d blocks.\n",anything);
      files++;

      close(tape); };

  printf("done, %d files\n",files); }

grr@cbmvax.commodore.com (George Robbins) (06/06/91)

In article <2378@netmbx.UUCP> weis@netmbx.UUCP (Dietmar Weis) writes:
> It can't be done with dd, there must be something special.
> (I tried it with bs=10k (good for layered products tapes, but not for
> at least the supported subset vol. 1.))

The files on the tape have differing blocksizes.  You could do it with
dd as a "tape-to-tape" copy, since this preserves blocksizes (assuming
that you specify something large enough).  However if you use disk as
an intermediate storage, you need to specify the correct blocksize for
each file output to the tape.  I believe there are some "tapecopy"
programs floating around that can do this.
-- 
George Robbins - now working for,     uucp:   {uunet|pyramid|rutgers}!cbmvax!grr
but no way officially representing:   domain: grr@cbmvax.commodore.com
Commodore, Engineering Department     phone:  215-431-9349 (only by moonlite)