1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <error.h>
include "mtio.h"
# MTREWIND -- Rewind the named magtape device. This is a synchronous
# rewind. Rewind not only rewinds the device, it also initializes the
# MTIO view of what is on the tape (number of files, total bytes used).
# Hence, if the drive is left allocated but the tape is changed, or if
# the position cache becomes inaccurate for any reason, a rewind will
# initialize things without having to deallocate and reallocate the drive.
procedure mtrewind (mtname, initcache)
char mtname[ARB] #I device to be rewound
int initcache #I discard positional information?
pointer sp, fname
int fd, mtopen()
errchk mtfname
begin
call smark (sp)
call salloc (fname, SZ_FNAME, TY_CHAR)
# Init position cache.
if (initcache == YES) {
call mt_glock (mtname, Memc[fname], SZ_FNAME)
iferr (call delete (Memc[fname]))
;
}
# Rewind device.
call mtfname (mtname, 1, Memc[fname], SZ_FNAME)
iferr (fd = mtopen (Memc[fname], READ_ONLY, 0))
call erract (EA_WARN)
else
call close (fd)
call sfree (sp)
end
|