@@ -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
7778#include "hexdump.h"
@@ -232,7 +233,7 @@ unsigned long nblocks;
232233FILE * lf ;
233234#endif
234235
235- int fd ; /* tape file descriptor */
236+ tape_handle_t fd ; /* tape file descriptor */
236237
237238/* Command line stuff. */
238239
@@ -1182,7 +1183,7 @@ int rdhead(void)
11821183 char name [80 ];
11831184 nfound = 1 ;
11841185 /* read the tape label - 4 records of 80 bytes */
1185- while ((i = read (fd , label , LABEL_SIZE )) != 0 ) {
1186+ while ((i = getrec (fd , label , LABEL_SIZE )) != 0 ) {
11861187 if (i != LABEL_SIZE ) {
11871188 fprintf (stderr , "Snark: bad label record\n" );
11881189 exit (1 );
@@ -1221,7 +1222,7 @@ void rdtail(void)
12211222 int i ;
12221223 char name [80 ];
12231224 /* read the tape label - 4 records of 80 bytes */
1224- while ((i = read (fd , label , LABEL_SIZE )) != 0 ) {
1225+ while ((i = getrec (fd , label , LABEL_SIZE )) != 0 ) {
12251226 if (i != LABEL_SIZE ) {
12261227 fprintf (stderr , "Snark: bad label record\n" );
12271228 exit (1 );
@@ -1259,8 +1260,8 @@ void vmsbackup(void)
12591260#endif
12601261
12611262 /* open the tape file */
1262- fd = open (tapefile , O_RDONLY );
1263- if (fd < 0 ) {
1263+ fd = opentape (tapefile , 0 , 0 );
1264+ if (fd == NULL ) {
12641265 perror (tapefile );
12651266 exit (1 );
12661267 }
@@ -1269,22 +1270,9 @@ void vmsbackup(void)
12691270 printf ("Opened '%s' as %d\n" , tapefile , fd );
12701271 }
12711272#endif
1272- #if HAVE_MT_IOCTLS
1273- /* rewind the tape */
1274- op .mt_op = MTREW ;
1275- op .mt_count = 1 ;
1276- i = ioctl (fd , MTIOCTOP , & op );
1277- if (i < 0 ) {
1278- if (errno == EINVAL || errno == ENOTTY ) {
1279- ondisk = 1 ;
1280- } else {
1281- perror (tapefile );
1282- exit (1 );
1283- }
1284- }
1285- #else
1286- ondisk = 1 ;
1287- #endif
1273+ ondisk = 0 ;
1274+
1275+ posnbot (fd );
12881276
12891277 if (ondisk ) {
12901278 /* process_block wants this to match the size which
@@ -1317,21 +1305,11 @@ void vmsbackup(void)
13171305 fprintf (stderr , "-s not supported for disk savesets\n" );
13181306 exit (1 );
13191307 }
1320- #if HAVE_MT_IOCTLS
1321- op .mt_op = MTFSF ;
1322- op .mt_count = 1 ;
1323- i = ioctl (fd , MTIOCTOP , & op );
1324- if (i < 0 ) {
1325- perror (tapefile );
1326- exit (1 );
1327- }
1328- #else
1329- abort ();
1330- #endif
1308+ skipfile (fd , 1 );
13311309 i = 0 ;
13321310 }
13331311 else
1334- i = read (fd , block , blocksize );
1312+ i = getrec (fd , block , blocksize );
13351313#ifdef DEBUG
13361314 if (debugflag ) {
13371315 printf ("Read %d of %d bytes\n" , i , blocksize );
@@ -1373,7 +1351,7 @@ void vmsbackup(void)
13731351 }
13741352
13751353 /* close the tape */
1376- close (fd );
1354+ closetape (fd );
13771355
13781356#ifdef NEWD
13791357 /* close debug file */
0 commit comments