aboutsummaryrefslogtreecommitdiff
path: root/sys/mtio/mtrewind.x
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /sys/mtio/mtrewind.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'sys/mtio/mtrewind.x')
-rw-r--r--sys/mtio/mtrewind.x41
1 files changed, 41 insertions, 0 deletions
diff --git a/sys/mtio/mtrewind.x b/sys/mtio/mtrewind.x
new file mode 100644
index 00000000..b7efcddb
--- /dev/null
+++ b/sys/mtio/mtrewind.x
@@ -0,0 +1,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