@@ -72,6 +72,7 @@ int mkdir (char *path, int mode);
7272#include "vmsbackup.h"
7373#include "match.h"
7474#include "sysdep.h"
75+ #include "tapeio.h"
7576
7677#ifdef DEBUG
7778static void debug_dump (const unsigned char * buffer , int dsize , int dtype );
@@ -182,7 +183,7 @@ unsigned long nblocks;
182183FILE * lf ;
183184#endif
184185
185- int fd ; /* tape file descriptor */
186+ tape_handle_t fd ; /* tape file descriptor */
186187
187188/* Command line stuff. */
188189
@@ -1105,7 +1106,7 @@ int rdhead(void)
11051106 char name [80 ];
11061107 nfound = 1 ;
11071108 /* read the tape label - 4 records of 80 bytes */
1108- while ((i = read (fd , label , LABEL_SIZE )) != 0 ) {
1109+ while ((i = getrec (fd , label , LABEL_SIZE )) != 0 ) {
11091110 if (i != LABEL_SIZE ) {
11101111 fprintf (stderr , "Snark: bad label record\n" );
11111112 exit (1 );
@@ -1144,7 +1145,7 @@ void rdtail(void)
11441145 int i ;
11451146 char name [80 ];
11461147 /* read the tape label - 4 records of 80 bytes */
1147- while ((i = read (fd , label , LABEL_SIZE )) != 0 ) {
1148+ while ((i = getrec (fd , label , LABEL_SIZE )) != 0 ) {
11481149 if (i != LABEL_SIZE ) {
11491150 fprintf (stderr , "Snark: bad label record\n" );
11501151 exit (1 );
@@ -1182,28 +1183,14 @@ void vmsbackup(void)
11821183#endif
11831184
11841185 /* open the tape file */
1185- fd = open (tapefile , O_RDONLY );
1186- if (fd < 0 ) {
1186+ fd = opentape (tapefile , 0 , 0 );
1187+ if (fd == NULL ) {
11871188 perror (tapefile );
11881189 exit (1 );
11891190 }
1191+ ondisk = 0 ;
11901192
1191- #if HAVE_MT_IOCTLS
1192- /* rewind the tape */
1193- op .mt_op = MTREW ;
1194- op .mt_count = 1 ;
1195- i = ioctl (fd , MTIOCTOP , & op );
1196- if (i < 0 ) {
1197- if (errno == EINVAL || errno == ENOTTY ) {
1198- ondisk = 1 ;
1199- } else {
1200- perror (tapefile );
1201- exit (1 );
1202- }
1203- }
1204- #else
1205- ondisk = 1 ;
1206- #endif
1193+ posnbot (fd );
12071194
12081195 if (ondisk ) {
12091196 /* process_block wants this to match the size which
@@ -1236,21 +1223,11 @@ void vmsbackup(void)
12361223 fprintf (stderr , "-s not supported for disk savesets\n" );
12371224 exit (1 );
12381225 }
1239- #if HAVE_MT_IOCTLS
1240- op .mt_op = MTFSF ;
1241- op .mt_count = 1 ;
1242- i = ioctl (fd , MTIOCTOP , & op );
1243- if (i < 0 ) {
1244- perror (tapefile );
1245- exit (1 );
1246- }
1247- #else
1248- abort ();
1249- #endif
1226+ skipfile (fd , 1 );
12501227 i = 0 ;
12511228 }
12521229 else
1253- i = read (fd , block , blocksize );
1230+ i = getrec (fd , block , blocksize );
12541231 if (i == 0 ) {
12551232 if (ondisk ) {
12561233 /* No need to support multiple save sets. */
@@ -1287,7 +1264,7 @@ void vmsbackup(void)
12871264 }
12881265
12891266 /* close the tape */
1290- close (fd );
1267+ closetape (fd );
12911268
12921269#ifdef NEWD
12931270 /* close debug file */
0 commit comments