9 track tapes and block sizes
Holm Tiffe
holm at freibergnet.de
Thu Sep 17 03:41:10 CDT 2020
shadoooo via cctalk wrote:
> Hello,
> I have a question about 9 track tapes and block sizes.
> What I know is that tape is subdivided in files by means of marks, and each
> file is subdivided in blocks of equal size.
> Programs like tar use a specific block size to create files on tape.
> However files can have different block sizes like bootloader file,
> installation dumps and root file system copy on 2.11BSD.
> Now suppose you find and unknown tape you want to preserve: using dd you
> could easily 1:1 copy tape files to hard disk files using a SCSI drive and
> Linux.
> But: how you know which block size is on the tape?
>
> Thanks
> Andrea
I've sometimes created my own simh .tap to Boottape converter (an later
found out that such a thing exists on the net) to create some boottapes
for my pdp11's using a tandberg 8GB quarter inch drive. It worked
(on Freebsd). I've installed 2.11BSD and on a KA630 Quasijarus Unix,
If you set the blocksize to variable you get back the read byte count
from the read() system call und you have to preserve that information to
the new copied tape (that's what the .tap formats are made for).
I know it is the other way around (.tap->tape) but this is my old q&d
tape write program, you hae made the other half yourselves...
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<sys/types.h>
#include<sys/ioctl.h>
#include<sys/mtio.h>
#include<fcntl.h>
#define MAXBLOCK 50
extern int errno;
main()
{
FILE * ifp;
FILE * ofp;
unsigned char buf[MAXBLOCK*512];
unsigned char * bufp;
unsigned long foffs=0;
struct mtop mtio;
int blnum,mark,mt;
unsigned int blen, tlen;
mark=0;
if((ifp=fopen("tapefile","r"))==NULL)
{
fprintf(stderr,"Cant open input file\n");
exit(-1);
}
if(system("mt -f /dev/sa0 blocksize 0")<0)
{
fprintf(stderr,"Can't set variable blocksize on /dev/sa0\n");
exit(-1);
}
if((mt=open("/dev/sa0", O_CREAT|O_TRUNC|O_WRONLY,0666))<0)
{
fprintf(stderr,"Can't open tape device\n");
exit(-1);
}
blnum=0;
l0:
while(1)
{
if(fread(&blen, sizeof(uint32_t),1,ifp)!=1)
{
fprintf(stderr,"Can't read blocklen\n");
fclose(ifp);
close(mt);
exit(-1);
}
foffs+=sizeof(uint32_t);
if(blen==0)
{
if(mark)
{
fprintf(stderr,"EOT detected\n");
fclose(ifp);
mtio.mt_op = MTWEOF;
mtio.mt_count = 2;
if (ioctl(mt, MTIOCTOP, &mtio) < 0)
fprintf(stderr, "MTIOCTOP err: %d\n", errno);
close(mt);
exit(0);
foffs+=sizeof(uint32_t);
if(blen==0)
{
if(mark)
{
fprintf(stderr,"EOT detected\n");
fclose(ifp);
mtio.mt_op = MTWEOF;
mtio.mt_count = 2;
if (ioctl(mt, MTIOCTOP, &mtio) < 0)
fprintf(stderr, "MTIOCTOP err: %d\n", errno);
close(mt);
exit(0);
}
else
{
fprintf(stderr,"tapemark detected foffs= %08x\n",
blen,foffs);
mark=1;
mtio.mt_op = MTWEOF;
mtio.mt_count = 1;
if (ioctl(mt, MTIOCTOP, &mtio) <
0)
fprintf(stderr, "MTIOCTOP err: %d\n", errno);
goto l0;
}
}
else
mark=0;
fprintf(stderr,"foffs %08x, blen bl %d = %d:%04x\n",foffs,blnum,blen,blen);
blnum++;
blen=blen&0x0fffffff; // erase error flags
if(fread(buf,sizeof(unsigned char),blen,ifp)!=blen)
{
fprintf(stderr,"Cant read blen %dbytes into buffer\n",blen);
fclose(ifp);
exit(-1);
}
if (write(mt, buf, blen) < 0)
{
fprintf(stderr,"Cant write blen %d bytes into buffer\n",blen );
fclose(ifp);
close(mt);
exit(1);
}
foffs+=blen;
if(fread(&tlen, sizeof(uint32_t),1,ifp)!=1)
{
fprintf(stderr,"Cant read trailing blocklen\n");
fclose(ifp);
exit(-1);
}
foffs+=sizeof(uint32_t);
if(blen!=tlen)
{
fprintf(stderr,"heading blocklen %08x != trailing blocklen %08x\n",
blen,tlen);
fclose(ifp);
exit(-1);
}
bzero(buf,MAXBLOCK*512);
}
}
Regards to Italy,
Holm
--
Technik Service u. Handel Tiffe, www.tsht.de, Holm Tiffe,
Goethestrasse 15, 09569 Oederran, USt-Id: DE253710583
info at tsht.de Fax +49 37292 709779 Tel +49 37292 709778 Mobil: 0172 8790 741
More information about the cctech
mailing list