From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- sys/mtio/mtrewind.x | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 sys/mtio/mtrewind.x (limited to 'sys/mtio/mtrewind.x') 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 +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 -- cgit