/* "Automagically" repair RMS file attributes of a BACKUP SAVESET * (typically used after transfer via FTP in BINARY mode) * * Usage: $ mcr [dir]FIX_SAVESET file.bck */ /* * Changes from original version: * wjm 25-mar-1991: fixed dimension of "buffer" * wjm 10-may-1991: add "ctx=stm" * wjm 31-jan-1993: add some header files & declarations, * replace 'exit()' by 'exit(4)' */ /* * (Originally) From: Bill Bame * * Author : William P. Bame (September 1990) * Purpose: Change the file attributes of a saveset so that VMS BACKUP can * read it again. Especially useful when transferring save sets via * some non-DEC protocol (ftp, uucp, etc.). * Notes : Tested with VMS 5.1-1 through 5.4-1A * * Disclaimer: As usual, use at your own risk. */ #include #include #include unsigned int SYS$OPEN(),SYS$CLOSE(),SYS$MODIFY(); #include #include #include #define RME$C_SETRFM 0x00000001 main(argc,argv) int argc; char **argv; { int fd,buffer[11],status; struct FAB myfab = cc$rms_fab; if (argc >= 2) { if ((fd = open(*++argv,O_RDONLY,0,"ctx=stm")) <= 0) { perror("open"); exit(4); } else { if ((read(fd,buffer,44)) < 0) { perror("read"); exit(4); } } close(fd); printf("Blocksize = %d",buffer[10]); myfab.fab$b_fac = FAB$M_PUT; myfab.fab$l_fop |= FAB$M_ESC; myfab.fab$l_ctx |= RME$C_SETRFM; myfab.fab$l_fna = *argv; myfab.fab$b_fns = strlen(*argv); if (((status = SYS$OPEN(&myfab, 0, 0)) & 7) != 1) exit((printf("Couldn't open %s\n", *argv), status)); myfab.fab$b_org = FAB$C_SEQ; myfab.fab$b_rfm = FAB$C_FIX; myfab.fab$w_mrs = buffer[10]; if (((status = SYS$MODIFY(&myfab, 0, 0)) & 7) != 1) exit((printf("Couldn't modify %s\n", *argv), status)); if (((status = SYS$CLOSE(&myfab, 0, 0)) & 7) != 1) exit((printf("Couldn't close %s\n", *argv), status)); } else { printf("usage: fix_saveset \n"); exit(1); } }