From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fdd80,2448e3378a7803d6 X-Google-Attributes: gidfdd80,public X-Google-Thread: 1164f8,2448e3378a7803d6 X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 2001-10-31 10:42:20 PST From: aek@spies.com (Al Kossow) Newsgroups: comp.sys.dec,alt.sys.pdp11 Subject: Re: simh and writing a rsts tape Date: 31 Oct 2001 10:41:57 -0800 Organization: Spies In The Wire Message-ID: <9rpgll$d5u$1@spies.com> References: <3BE04079.2B57A93B@yahoo.com> NNTP-Posting-Host: spies.com X-Trace: 31 Oct 2001 10:48:41 -0800, spies.com Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news-peer-west.sprintlink.net!news.sprintlink.net!enews.sgi.com!news.spies.com!localhost!not-for-mail Xref: archiver1.google.com comp.sys.dec:8062 alt.sys.pdp11:2898 >From article <3BE04079.2B57A93B@yahoo.com>, by Bill McDermith : > Is there any way to create a simh-compatible "tape" of a set of > unix files, that can be read into rsts using pip.sav or some other > copy program? > You'll need to write a DOS formatted tape image. Here's a unix program to extract DOS files, you should be able to deduce the file format from that. From memory, it's pretty simple (14 byte header record, file name in RAD50, 512 byte data records, file mark after each file). One of the things on my 'to do' list is to convert this to work with .tap / .tpc containers.. /* * dostp - extract from or write to DOS tape * * Written by Hughes O'Neill, 10/July/77. * * Modified for V7 and stdio by Alexis Kwan (HCR for DCIEM), 11/Feb/81. * Modified for 4.1bsd (VAX) & variable tape density 26-Mar-84 * Dave Rasmussen, University of Wisconsin - Milwaukee, Dept EE&CS * uucp: uwvax!uwm-evax!dave */ #include #include #include #define MAXLINE 80 #define NAMSIZE 12 #define DEFAULT_GROUP 1 #define DEFAULT_USER 1 #define PROT_CODE 155 #define BAD 0 #define TOC 1 #define EXTRACT 2 #define REPLACE 3 #define VERBOSE 1 #define WAIT 2 #define NOREWIND 4 #define CRFLAG 8 /* This must be aligned on word boundary */ struct { short unsigned FNAME[2]; short unsigned EXT; char USER; char GROUP; char PROTECT; char UNUSEDBYTE; short unsigned DATE; short unsigned UNUSEDWORD[2]; } hd; #define HDSIZE 16 #define YES 1 #define NO 0 #define ERROR -1 struct { int fildes; int nleft; char *nextp; char buff[BUFSIZ]; /* This must be aligned on word boundary */ } tbuf; #define READ 0 #define WRITE 1 FILE *in; FILE *out; int group = DEFAULT_GROUP; int user = DEFAULT_USER; char NRAW_TAPE[11]; char RAW_TAPE[11]; main (argc, argv) int argc; char *argv[]; { char c; int opt, cmd, i; if (argc<2) cmd = BAD; if (argv[1][0]=='-') argv[1]++; else if (argv[1][0]=='x') cmd = EXTRACT; else if (argv[1][0]=='t') cmd = TOC; else if (argv[1][0]=='r') cmd = REPLACE; else cmd = BAD; if (argv[1][1]=='l'){ i=2; strcpy(NRAW_TAPE,"/dev/nrmt0"); strcpy(RAW_TAPE,"/dev/rmt4");} else{ i=1; strcpy(NRAW_TAPE,"/dev/nrmt8"); strcpy(RAW_TAPE,"/dev/rmt8");} opt = CRFLAG; for (; (c = argv[1][i]); i++) { switch (c) { case 'v': opt |= VERBOSE; break; case 'w': opt |= WAIT; break; case 'n': opt |= NOREWIND; break; case 'b': opt &= ~CRFLAG; break; } } switch (cmd) { case BAD: printf("usage: dostp key[opts] [file ...]\n"); break; case TOC: toc(opt,argc,argv); break; case EXTRACT: extract(opt,argc,argv); break; case REPLACE: replace(opt,argc,argv); break; } } /* * Print table of contents of a DOS tape. */ toc (opt, argc, argv) int opt; int argc; char *argv[]; { char name[NAMSIZE]; if ((tbuf.fildes = open(RAW_TAPE,READ))==ERROR) { perror("toc"); exit(1); } for (;;) { if (gethdr(name)==EOF) break; if (match(name,argc,argv)) { if (opt&VERBOSE) printf("[%o,%o] %s \n",group,user,name); else printf("%s \n",name); } while (read(tbuf.fildes,tbuf.buff,BUFSIZ) > 0) ; } } /* * Extract files from DOS tape. */ extract (opt, argc, argv) int opt; int argc; char *argv[]; { int do_cmd; char name[NAMSIZE], str[MAXLINE]; register char c, savc; if ((tbuf.fildes = open(RAW_TAPE,READ))==ERROR) { perror("extract"); exit(1); } for (;;) { if (gethdr(name)==EOF) break; do_cmd = match(name,argc,argv); if ((opt & WAIT) && do_cmd) { if (opt & VERBOSE) printf("x [%o,%o] %s ? ",group,user,name); else printf("x %s ? ",name); gets(str); c = str[0]; if (c=='x') break; do_cmd = (c=='y'); } if ((opt & VERBOSE) && do_cmd) printf("x %s ",name); if (do_cmd) { if ((out = fopen(name,"w"))==NULL) { perror("extract"); break; } /* Starting with fresh buffer */ tbuf.nleft = 0; while ((c = tgetch())!=EOF) { if ((c == '\r' ) && (opt & CRFLAG)) { savc = c; if ((c = tgetch())!='\n') putc(savc,out); if (c==EOF) break; } putc(c,out); } fclose(out); if (opt & VERBOSE) printf("ok\n"); } else { while (read(tbuf.fildes,tbuf.buff,BUFSIZ) > 0) ; } } } /* * Rewind tape and die. */ quit () { restore(); exit(0); } /* * Write files onto tape in DOS format. */ replace (opt, argc, argv) int opt; int argc; char *argv[]; { int n, do_cmd; char str[MAXLINE], c; signal(SIGINT,quit); for (n = 2; n 0) { --tbuf.nleft; return(*tbuf.nextp++ & 0377); } if ((tbuf.nleft = read(tbuf.fildes,tbuf.buff,BUFSIZ)) <= 0) { tbuf.nleft = 0; return(EOF); } tbuf.nextp = tbuf.buff; --tbuf.nleft; return(*tbuf.nextp++ & 0377); } /* * Buffered tape write. */ tputch (c) char c; { if (tbuf.nleft == 1) { *tbuf.nextp = c; if (write(tbuf.fildes,tbuf.buff,BUFSIZ)==ERROR) { perror("tputch"); exit(1); } tbuf.nleft = BUFSIZ; tbuf.nextp = tbuf.buff; return; } if (tbuf.nleft == 0) { tbuf.nleft = BUFSIZ; tbuf.nextp = tbuf.buff; } --tbuf.nleft; *tbuf.nextp++ = c; } /* * Flush tape write buffer and close. */ tclose () { if (tbuf.nleft != BUFSIZ && tbuf.nleft != 0) if (write(tbuf.fildes,tbuf.buff,BUFSIZ-tbuf.nleft)==ERROR) { perror("tclose"); exit(1); } if (close(tbuf.fildes)==ERROR) { perror("tclose"); exit(1); } }