2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2017 Kern Sibbald
6 The original author of Bacula is Kern Sibbald, with contributions
7 from many others, a complete list can be found in the file AUTHORS.
9 You may use this file and others of this release according to the
10 license defined in the LICENSE file, which includes the Affero General
11 Public License, v3.0 ("AGPLv3") and some additional permissions and
12 terms pursuant to its AGPLv3 Section 7.
14 This notice must be preserved when any source code is
15 conveyed and/or propagated.
17 Bacula(R) is a registered trademark of Kern Sibbald.
21 * tape_dev.c -- low level operations on tape devices
23 * written by, Kern Sibbald, MM
24 * separated from dev.c in February 2014
26 * The separation between tape and file is not yet clean.
31 * Handling I/O errors and end of tape conditions are a bit tricky.
32 * This is how it is currently done when writing.
33 * On either an I/O error or end of tape,
34 * we will stop writing on the physical device (no I/O recovery is
35 * attempted at least in this daemon). The state flag will be sent
36 * to include ST_EOT, which is ephemeral, and ST_WEOT, which is
37 * persistent. Lots of routines clear ST_EOT, but ST_WEOT is
38 * cleared only when the problem goes away. Now when ST_WEOT
39 * is set all calls to write_block_to_device() call the fix_up
40 * routine. In addition, all threads are blocked
41 * from writing on the tape by calling lock_dev(), and thread other
42 * than the first thread to hit the EOT will block on a condition
43 * variable. The first thread to hit the EOT will continue to
44 * be able to read and write the tape (he sort of tunnels through
45 * the locking mechanism -- see lock_dev() for details).
47 * Now presumably somewhere higher in the chain of command
48 * (device.c), someone will notice the EOT condition and
49 * get a new tape up, get the tape label read, and mark
50 * the label for rewriting. Then this higher level routine
51 * will write the unwritten buffer to the new volume.
52 * Finally, he will release
53 * any blocked threads by doing a broadcast on the condition
54 * variable. At that point, we should be totally back in
55 * business with no lost data.
65 /* Imported functions */
66 extern void set_os_device_parameters(DCR *dcr);
67 extern bool dev_get_os_pos(DEVICE *dev, struct mtget *mt_stat);
68 extern uint32_t status_dev(DEVICE *dev);
69 const char *mode_to_str(int mode);
73 bool tape_dev::open_device(DCR *dcr, int omode)
76 int timeout = max_open_wait;
77 #if !defined(HAVE_WIN32)
79 utime_t start_time = time(NULL);
82 if (DEVICE::open_device(dcr, omode)) {
83 return true; /* already open */
85 omode = openmode; /* pickup possible new options */
87 mount(1); /* do mount if required */
89 Dmsg0(100, "Open dev: device is tape\n");
91 get_autochanger_loaded_slot(dcr);
100 if (is_fifo() && timeout) {
102 tid = start_thread_timer(dcr->jcr, pthread_self(), timeout);
104 Dmsg2(100, "Try open %s mode=%s\n", print_name(), mode_to_str(omode));
106 #if defined(HAVE_WIN32)
109 if ((m_fd = d_open(dev_name, mode)) < 0) {
116 /* If busy retry each second for max_open_wait seconds */
118 /* Try non-blocking open */
119 m_fd = d_open(dev_name, mode+O_NONBLOCK);
123 Dmsg5(100, "Open error on %s omode=%d mode=%x errno=%d: ERR=%s\n",
124 print_name(), omode, mode, errno, be.bstrerror());
126 /* Tape open, now rewind it */
127 Dmsg0(100, "Rewind after open\n");
128 mt_com.mt_op = MTREW;
130 /* rewind only if dev is a tape */
131 if (is_tape() && (d_ioctl(m_fd, MTIOCTOP, (char *)&mt_com) < 0)) {
133 dev_errno = errno; /* set error status from rewind */
136 Dmsg2(100, "Rewind error on %s close: ERR=%s\n", print_name(),
137 be.bstrerror(dev_errno));
138 /* If we get busy, device is probably rewinding, try again */
139 if (dev_errno != EBUSY) {
140 break; /* error -- no medium */
143 /* Got fd and rewind worked, so we must have medium in drive */
145 m_fd = d_open(dev_name, mode); /* open normally */
149 Dmsg5(100, "Open error on %s omode=%d mode=%x errno=%d: ERR=%s\n",
150 print_name(), omode, mode, errno, be.bstrerror());
155 set_os_device_parameters(dcr); /* do system dependent stuff */
156 break; /* Successfully opened and rewound */
160 /* Exceed wait time ? */
161 if (time(NULL) - start_time >= max_open_wait) {
162 break; /* yes, get out */
169 Mmsg2(errmsg, _("Unable to open device %s: ERR=%s\n"),
170 print_name(), be.bstrerror(dev_errno));
172 pm_strcpy(dcr->jcr->errmsg, errmsg);
174 Dmsg1(100, "%s", errmsg);
177 /* Stop any open() timer we started */
179 stop_thread_timer(tid);
182 Dmsg1(100, "open dev: tape %d opened\n", m_fd);
183 state |= preserve; /* reset any important state info */
190 * Returns: true on success
193 bool tape_dev::rewind(DCR *dcr)
199 Dmsg3(400, "rewind res=%d fd=%d %s\n", num_reserved(), m_fd, print_name());
200 state &= ~(ST_EOT|ST_EOF|ST_WEOT); /* remove EOF/EOT flags */
201 block_num = file = 0;
208 mt_com.mt_op = MTREW;
210 /* If we get an I/O error on rewind, it is probably because
211 * the drive is actually busy. We loop for (about 5 minutes)
212 * retrying every 5 seconds.
214 for (i=max_rewind_wait; ; i -= 5) {
215 if (d_ioctl(m_fd, MTIOCTOP, (char *)&mt_com) < 0) {
218 if (i == max_rewind_wait) {
219 Dmsg1(200, "Rewind error, %s. retrying ...\n", be.bstrerror());
222 * This is a gross hack, because if the user has the
223 * device mounted (i.e. open), then uses mtx to load
224 * a tape, the current open file descriptor is invalid.
225 * So, we close the drive and re-open it.
228 int open_mode = openmode;
231 open_device(dcr, open_mode);
239 if (dev_errno == EIO) {
240 Mmsg1(errmsg, _("No tape loaded or drive offline on %s.\n"), print_name());
244 if (dev_errno == EIO && i > 0) {
245 Dmsg0(200, "Sleeping 5 seconds.\n");
250 Mmsg2(errmsg, _("Rewind error on %s. ERR=%s.\n"),
251 print_name(), be.bstrerror());
261 * Check if the current position on the volume corresponds to
262 * what is in the catalog.
265 bool tape_dev::is_eod_valid(DCR *dcr)
269 * Check if we are positioned on the tape at the same place
270 * that the database says we should be.
272 if (VolCatInfo.VolCatFiles == get_file()) {
273 Jmsg(jcr, M_INFO, 0, _("Ready to append to end of Volume \"%s\" at file=%d.\n"),
274 dcr->VolumeName, get_file());
275 } else if (get_file() > VolCatInfo.VolCatFiles) {
276 Jmsg(jcr, M_WARNING, 0, _("For Volume \"%s\":\n"
277 "The number of files mismatch! Volume=%u Catalog=%u\n"
278 "Correcting Catalog\n"),
279 dcr->VolumeName, get_file(), VolCatInfo.VolCatFiles);
280 VolCatInfo.VolCatFiles = get_file();
281 VolCatInfo.VolCatBlocks = get_block_num();
282 if (!dir_update_volume_info(dcr, false, true)) {
283 Jmsg(jcr, M_WARNING, 0, _("Error updating Catalog\n"));
284 dcr->mark_volume_in_error();
288 Jmsg(jcr, M_ERROR, 0, _("Bacula cannot write on tape Volume \"%s\" because:\n"
289 "The number of files mismatch! Volume=%u Catalog=%u\n"),
290 dcr->VolumeName, get_file(), VolCatInfo.VolCatFiles);
291 dcr->mark_volume_in_error();
298 * Position device to end of medium (end of data)
299 * Returns: true on succes
302 bool tape_dev::eod(DCR *dcr)
309 ok = DEVICE::eod(dcr);
314 #if defined (__digital__) && defined (__unix__)
315 return fsf(VolCatInfo.VolCatFiles);
319 if (has_cap(CAP_FASTFSF) && !has_cap(CAP_EOM)) {
320 Dmsg0(100,"Using FAST FSF for EOM\n");
321 /* If unknown position, rewind */
322 if (get_os_tape_file() < 0) {
324 Dmsg0(100, "Rewind error\n");
329 mt_com.mt_op = MTFSF;
331 * ***FIXME*** fix code to handle case that INT16_MAX is
334 mt_com.mt_count = INT16_MAX; /* use big positive number */
335 if (mt_com.mt_count < 0) {
336 mt_com.mt_count = INT16_MAX; /* brain damaged system */
340 if (has_cap(CAP_MTIOCGET) && (has_cap(CAP_FASTFSF) || has_cap(CAP_EOM))) {
341 if (has_cap(CAP_EOM)) {
342 Dmsg0(100,"Using EOM for EOM\n");
343 mt_com.mt_op = MTEOM;
347 if (d_ioctl(m_fd, MTIOCTOP, (char *)&mt_com) < 0) {
349 clrerror(mt_com.mt_op);
350 Dmsg1(50, "ioctl error: %s\n", be.bstrerror());
352 Mmsg2(errmsg, _("ioctl MTEOM error on %s. ERR=%s.\n"),
353 print_name(), be.bstrerror());
354 Dmsg1(100, "%s", errmsg);
359 os_file = get_os_tape_file();
363 Mmsg2(errmsg, _("ioctl MTIOCGET error on %s. ERR=%s.\n"),
364 print_name(), be.bstrerror());
365 Dmsg1(100, "%s", errmsg);
369 Dmsg1(100, "EOD file=%d\n", os_file);
377 * Rewind then use FSF until EOT reached
380 Dmsg0(100, "Rewind error.\n");
385 * Move file by file to the end of the tape
388 for (file_num=file; !at_eot(); file_num++) {
389 Dmsg0(200, "eod: doing fsf 1\n");
391 Dmsg0(100, "fsf error.\n");
396 * Avoid infinite loop by ensuring we advance.
398 if (!at_eot() && file_num == (int)file) {
399 Dmsg1(100, "fsf did not advance from file %d\n", file_num);
401 os_file = get_os_tape_file();
403 Dmsg2(100, "Adjust file from %d to %d\n", file_num, os_file);
411 * Some drivers leave us after second EOF when doing
412 * MTEOM, so we must backup so that appending overwrites
415 if (has_cap(CAP_BSFATEOM)) {
416 /* Backup over EOF */
418 /* If BSF worked and fileno is known (not -1), set file */
419 os_file = get_os_tape_file();
421 Dmsg2(100, "BSFATEOF adjust file from %d to %d\n", file , os_file);
424 file++; /* wing it -- not correct on all OSes */
427 update_pos(dcr); /* update position */
429 Dmsg1(200, "EOD dev->file=%d\n", file);
435 * Load medium in device
436 * Returns: true on success
439 bool load_dev(DEVICE *dev)
446 dev->dev_errno = EBADF;
447 Mmsg0(dev->errmsg, _("Bad call to load_dev. Device not open\n"));
448 Emsg0(M_FATAL, 0, dev->errmsg);
451 if (!(dev->is_tape())) {
455 Dmsg0(200, "stored: MTLOAD command not available\n");
457 dev->dev_errno = ENOTTY; /* function not available */
458 Mmsg2(dev->errmsg, _("ioctl MTLOAD error on %s. ERR=%s.\n"),
459 dev->print_name(), be.bstrerror());
463 dev->block_num = dev->file = 0;
466 mt_com.mt_op = MTLOAD;
468 if (dev->d_ioctl(dev->fd(), MTIOCTOP, (char *)&mt_com) < 0) {
470 dev->dev_errno = errno;
471 Mmsg2(dev->errmsg, _("ioctl MTLOAD error on %s. ERR=%s.\n"),
472 dev->print_name(), be.bstrerror());
480 * Rewind device and put it offline
481 * Returns: true on success
484 bool tape_dev::offline(DCR *dcr)
489 return true; /* device not open */
492 state &= ~(ST_APPEND|ST_READ|ST_EOT|ST_EOF|ST_WEOT); /* remove EOF/EOT flags */
493 block_num = file = 0;
497 mt_com.mt_op = MTOFFL;
499 if (d_ioctl(m_fd, MTIOCTOP, (char *)&mt_com) < 0) {
502 Mmsg2(errmsg, _("ioctl MTOFFL error on %s. ERR=%s.\n"),
503 print_name(), be.bstrerror());
506 Dmsg1(100, "Offlined device %s\n", print_name());
510 bool DEVICE::offline_or_rewind(DCR *dcr)
515 if (has_cap(CAP_OFFLINEUNMOUNT)) {
519 * Note, this rewind probably should not be here (it wasn't
520 * in prior versions of Bacula), but on FreeBSD, this is
521 * needed in the case the tape was "frozen" due to an error
522 * such as backspacing after writing and EOF. If it is not
523 * done, all future references to the drive get and I/O error.
531 * Foward space a file
532 * Returns: true on success
535 bool tape_dev::fsf(int num)
543 Mmsg0(errmsg, _("Bad call to fsf. Device not open\n"));
544 Emsg0(M_FATAL, 0, errmsg);
554 Mmsg1(errmsg, _("Device %s at End of Tape.\n"), print_name());
558 Dmsg0(200, "ST_EOF set on entry to FSF\n");
564 * If Fast forward space file is set, then we
565 * use MTFSF to forward space and MTIOCGET
566 * to get the file position. We assume that
567 * the SCSI driver will ensure that we do not
568 * forward space past the end of the medium.
570 if (has_cap(CAP_FSF) && has_cap(CAP_MTIOCGET) && has_cap(CAP_FASTFSF)) {
572 mt_com.mt_op = MTFSF;
573 mt_com.mt_count = num;
574 stat = d_ioctl(m_fd, MTIOCTOP, (char *)&mt_com);
576 my_errno = errno; /* save errno */
577 } else if ((os_file=get_os_tape_file()) < 0) {
578 my_errno = errno; /* save errno */
583 Dmsg0(200, "Set ST_EOT\n");
585 Mmsg2(errmsg, _("ioctl MTFSF error on %s. ERR=%s.\n"),
586 print_name(), be.bstrerror(my_errno));
587 Dmsg1(200, "%s", errmsg);
591 Dmsg1(200, "fsf file=%d\n", os_file);
597 * Here if CAP_FSF is set, and virtually all drives
598 * these days support it, we read a record, then forward
599 * space one file. Using this procedure, which is slow,
600 * is the only way we can be sure that we don't read
601 * two consecutive EOF marks, which means End of Data.
603 } else if (has_cap(CAP_FSF)) {
606 Dmsg0(200, "FSF has cap_fsf\n");
607 if (max_block_size == 0) {
608 rbuf_len = DEFAULT_BLOCK_SIZE;
610 rbuf_len = max_block_size;
612 rbuf = get_memory(rbuf_len);
613 mt_com.mt_op = MTFSF;
615 while (num-- && !at_eot()) {
616 Dmsg0(100, "Doing read before fsf\n");
617 if ((stat = this->read((char *)rbuf, rbuf_len)) < 0) {
618 if (errno == ENOMEM) { /* tape record exceeds buf len */
619 stat = rbuf_len; /* This is OK */
621 * On IBM drives, they return ENOSPC at EOM
622 * instead of EOF status
624 } else if (at_eof() && errno == ENOSPC) {
630 Dmsg2(100, "Set ST_EOT read errno=%d. ERR=%s\n", dev_errno,
632 Mmsg2(errmsg, _("read error on %s. ERR=%s.\n"),
633 print_name(), be.bstrerror());
634 Dmsg1(100, "%s", errmsg);
638 if (stat == 0) { /* EOF */
639 Dmsg1(100, "End of File mark from read. File=%d\n", file+1);
640 /* Two reads of zero means end of tape */
643 Dmsg0(100, "Set ST_EOT\n");
649 } else { /* Got data */
654 Dmsg0(100, "Doing MTFSF\n");
655 stat = d_ioctl(m_fd, MTIOCTOP, (char *)&mt_com);
656 if (stat < 0) { /* error => EOT */
659 Dmsg0(100, "Set ST_EOT\n");
661 Mmsg2(errmsg, _("ioctl MTFSF error on %s. ERR=%s.\n"),
662 print_name(), be.bstrerror());
663 Dmsg0(100, "Got < 0 for MTFSF\n");
664 Dmsg1(100, "%s", errmsg);
672 * No FSF, so use FSR to simulate it
675 Dmsg0(200, "Doing FSR for FSF\n");
676 while (num-- && !at_eot()) {
677 fsr(INT32_MAX); /* returns -1 on EOF or EOT */
681 Mmsg1(errmsg, _("Device %s at End of Tape.\n"), print_name());
687 Dmsg1(200, "Return %d from FSF\n", stat);
689 Dmsg0(200, "ST_EOF set on exit FSF\n");
692 Dmsg0(200, "ST_EOT set on exit FSF\n");
694 Dmsg1(200, "Return from FSF file=%d\n", file);
699 * Backward space a file
700 * Returns: false on failure
703 bool tape_dev::bsf(int num)
710 Mmsg0(errmsg, _("Bad call to bsf. Device not open\n"));
711 Emsg0(M_FATAL, 0, errmsg);
716 Mmsg1(errmsg, _("Device %s cannot BSF because it is not a tape.\n"),
727 mt_com.mt_op = MTBSF;
728 mt_com.mt_count = num;
729 stat = d_ioctl(m_fd, MTIOCTOP, (char *)&mt_com);
733 Mmsg2(errmsg, _("ioctl MTBSF error on %s. ERR=%s.\n"),
734 print_name(), be.bstrerror());
741 * Foward space num records
742 * Returns: false on failure
745 bool DEVICE::fsr(int num)
752 Mmsg0(errmsg, _("Bad call to fsr. Device not open\n"));
753 Emsg0(M_FATAL, 0, errmsg);
761 if (!has_cap(CAP_FSR)) {
762 Mmsg1(errmsg, _("ioctl MTFSR not permitted on %s.\n"), print_name());
766 Dmsg1(100, "fsr %d\n", num);
767 mt_com.mt_op = MTFSR;
768 mt_com.mt_count = num;
769 stat = d_ioctl(m_fd, MTIOCTOP, (char *)&mt_com);
775 struct mtget mt_stat;
777 Dmsg1(100, "FSF fail: ERR=%s\n", be.bstrerror());
778 if (dev_get_os_pos(this, &mt_stat)) {
779 Dmsg4(100, "Adjust from %d:%d to %d:%d\n", file,
780 block_num, mt_stat.mt_fileno, mt_stat.mt_blkno);
781 file = mt_stat.mt_fileno;
782 block_num = mt_stat.mt_blkno;
790 Mmsg3(errmsg, _("ioctl MTFSR %d error on %s. ERR=%s.\n"),
791 num, print_name(), be.bstrerror());
797 * Backward space a record
798 * Returns: false on failure
801 bool DEVICE::bsr(int num)
808 Mmsg0(errmsg, _("Bad call to bsr_dev. Device not open\n"));
809 Emsg0(M_FATAL, 0, errmsg);
817 if (!has_cap(CAP_BSR)) {
818 Mmsg1(errmsg, _("ioctl MTBSR not permitted on %s.\n"), print_name());
822 Dmsg0(100, "bsr_dev\n");
826 mt_com.mt_op = MTBSR;
827 mt_com.mt_count = num;
828 stat = d_ioctl(m_fd, MTIOCTOP, (char *)&mt_com);
832 Mmsg2(errmsg, _("ioctl MTBSR error on %s. ERR=%s.\n"),
833 print_name(), be.bstrerror());
838 void tape_dev::lock_door()
842 if (!is_tape()) return;
843 mt_com.mt_op = MTLOCK;
845 d_ioctl(m_fd, MTIOCTOP, (char *)&mt_com);
849 void tape_dev::unlock_door()
853 if (!is_tape()) return;
854 mt_com.mt_op = MTUNLOCK;
856 d_ioctl(m_fd, MTIOCTOP, (char *)&mt_com);
861 * Reposition the device to file, block
862 * Returns: false on failure
865 bool tape_dev::reposition(DCR *dcr, uint64_t raddr)
867 uint32_t rfile, rblock;
869 rfile = (uint32_t)(raddr>>32);
870 rblock = (uint32_t)raddr;
873 Mmsg0(errmsg, _("Bad call to reposition. Device not open\n"));
874 Emsg0(M_FATAL, 0, errmsg);
878 /* After this point, we are tape only */
879 Dmsg4(100, "reposition from %u:%u to %u:%u\n", file, block_num, rfile, rblock);
881 Dmsg0(100, "Rewind\n");
887 Dmsg1(100, "fsf %d\n", rfile-file);
888 if (!fsf(rfile-file)) {
889 Dmsg1(100, "fsf failed! ERR=%s\n", bstrerror());
892 Dmsg2(100, "wanted_file=%d at_file=%d\n", rfile, file);
894 if (rblock < block_num) {
895 Dmsg2(100, "wanted_blk=%d at_blk=%d\n", rblock, block_num);
896 Dmsg0(100, "bsf 1\n");
898 Dmsg0(100, "fsf 1\n");
900 Dmsg2(100, "wanted_blk=%d at_blk=%d\n", rblock, block_num);
902 if (has_cap(CAP_POSITIONBLOCKS) && rblock > block_num) {
903 /* Ignore errors as Bacula can read to the correct block */
904 Dmsg1(100, "fsr %d\n", rblock-block_num);
905 return fsr(rblock-block_num);
907 while (rblock > block_num) {
908 if (!dcr->read_block_from_dev(NO_BLOCK_NUMBER_CHECK)) {
911 Dmsg2(30, "Failed to find requested block on %s: ERR=%s",
912 print_name(), be.bstrerror());
915 Dmsg2(300, "moving forward wanted_blk=%d at_blk=%d\n", rblock, block_num);
922 * Write an end of file on the device
923 * Returns: true on success
926 bool tape_dev::weof(DCR *dcr, int num)
930 Dmsg1(129, "=== weof_dev=%s\n", print_name());
934 Mmsg0(errmsg, _("Bad call to weof_dev. Device not open\n"));
935 Emsg0(M_FATAL, 0, errmsg);
944 Mmsg0(errmsg, _("Attempt to WEOF on non-appendable Volume\n"));
945 Emsg0(M_FATAL, 0, errmsg);
951 mt_com.mt_op = MTWEOF;
952 mt_com.mt_count = num;
953 stat = d_ioctl(m_fd, MTIOCTOP, (char *)&mt_com);
962 Mmsg2(errmsg, _("ioctl MTWEOF error on %s. ERR=%s.\n"),
963 print_name(), be.bstrerror());
966 /* DCR is null if called from within write_ansi_ibm_labels() */
967 if (dcr && stat == 0) {
968 if (!write_ansi_ibm_labels(dcr, ANSI_EOF_LABEL, VolHdr.VolumeName)) {
976 * If timeout, wait until the mount command returns 0.
977 * If !timeout, try to mount the device only once.
979 bool tape_dev::mount(int timeout)
981 Dmsg0(190, "Enter tape mount\n");
983 if (!is_mounted() && device->mount_command) {
984 return mount_tape(1, timeout);
991 * If timeout, wait until the unmount command returns 0.
992 * If !timeout, try to unmount the device only once.
994 bool tape_dev::unmount(int timeout)
996 Dmsg0(100, "Enter tape unmount\n");
998 if (!is_mounted() && requires_mount() && device->unmount_command) {
999 return mount_tape(0, timeout);
1006 * (Un)mount the device (for tape devices)
1008 bool tape_dev::mount_tape(int mount, int dotimeout)
1010 POOL_MEM ocmd(PM_FNAME);
1018 icmd = device->mount_command;
1020 icmd = device->unmount_command;
1023 edit_mount_codes(ocmd, icmd);
1025 Dmsg2(100, "mount_tape: cmd=%s mounted=%d\n", ocmd.c_str(), !!is_mounted());
1028 /* Try at most 10 times to (un)mount the device. This should perhaps be configurable. */
1033 results = get_memory(4000);
1035 /* If busy retry each second */
1036 Dmsg1(100, "mount_tape run_prog=%s\n", ocmd.c_str());
1037 while ((status = run_program_full_output(ocmd.c_str(), max_open_wait/2, results)) != 0) {
1042 Dmsg5(100, "Device %s cannot be %smounted. stat=%d result=%s ERR=%s\n", print_name(),
1043 (mount ? "" : "un"), status, results, be.bstrerror(status));
1044 Mmsg(errmsg, _("Device %s cannot be %smounted. ERR=%s\n"),
1045 print_name(), (mount ? "" : "un"), be.bstrerror(status));
1048 free_pool_memory(results);
1049 Dmsg0(200, "============ mount=0\n");
1054 set_mounted(mount); /* set/clear mounted flag */
1055 free_pool_memory(results);
1056 Dmsg1(200, "============ mount=%d\n", mount);
1060 void tape_dev::set_ateof()
1065 DEVICE::set_ateof();
1069 const char *tape_dev::print_type()
1074 DEVICE *tape_dev::get_dev(DCR */*dcr*/)
1079 uint32_t tape_dev::get_hi_addr()
1084 uint32_t tape_dev::get_low_addr()
1089 uint64_t tape_dev::get_full_addr()
1091 return (((uint64_t)file) << 32) | (uint64_t)block_num;
1094 bool tape_dev::end_of_volume(DCR *dcr)
1096 return write_ansi_ibm_labels(dcr, ANSI_EOV_LABEL, VolHdr.VolumeName);
1099 /* Print the address */
1100 char *tape_dev::print_addr(char *buf, int32_t buf_len)
1103 bsnprintf(buf, buf_len, "%lu:%lu", get_hi_addr(), get_low_addr());
1107 char *tape_dev::print_addr(char *buf, int32_t buf_len, boffset_t addr)
1110 bsnprintf(buf, buf_len, "%lu:%lu", (uint32_t)(addr>>32), (uint32_t)addr);
1115 * Clean up when terminating the device
1117 void tape_dev::term(DCR *dcr)