X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fstored%2Fdev.c;h=0e72db6a84530de7182b80d605238ad46ff934b3;hb=ce462cd94d90f4785b622cedc2ca48d616fe3f07;hp=b09c33dbcd45712c1d10a0d562e03e6c15409570;hpb=cfc2aa18dbf9afb34902a14473152f388836538d;p=bacula%2Fbacula diff --git a/bacula/src/stored/dev.c b/bacula/src/stored/dev.c index b09c33dbcd..0e72db6a84 100644 --- a/bacula/src/stored/dev.c +++ b/bacula/src/stored/dev.c @@ -127,12 +127,12 @@ init_dev(JCR *jcr, DEVRES *device) device->dev_type = B_TAPE_DEV; } else if (S_ISFIFO(statp.st_mode)) { device->dev_type = B_FIFO_DEV; -#ifdef USE_FAKETAPE - /* must set DeviceType = Faketape +#ifdef USE_VTAPE + /* must set DeviceType = Vtape * in normal mode, autodetection is disabled */ } else if (S_ISREG(statp.st_mode)) { - device->dev_type = B_FAKETAPE_DEV; + device->dev_type = B_VTAPE_DEV; #endif } else if (!(device->cap_bits & CAP_REQMOUNT)) { Jmsg2(jcr, M_ERROR, 0, _("%s is an unknown device type. Must be tape or directory\n" @@ -275,29 +275,39 @@ init_dev(JCR *jcr, DEVRES *device) /* Choose the right backend */ void DEVICE::init_backend() { - if (is_faketape()) { - d_open = faketape_open; - d_write = faketape_write; - d_close = faketape_close; - d_ioctl = faketape_ioctl; - d_read = faketape_read; #ifdef HAVE_WIN32 - } else if (is_tape()) { + if (is_tape()) { d_open = win32_tape_open; d_write = win32_tape_write; d_close = win32_tape_close; d_ioctl = win32_tape_ioctl; d_read = win32_tape_read; -#endif } else { + d_open = ::open; + d_close = ::close; + d_ioctl = win32_ioctl; /* dummy function */ + d_write = win32_write; /* win32 read/write are not POSIX */ + d_read = win32_read; + } + +#else /* POSIX / UNIX Interface */ + if (is_vtape()) { /* test backend */ + d_open = vtape_open; /* vtape isn't available for WIN32 or FreeBSD */ + d_write = vtape_write; + d_close = vtape_close; + d_ioctl = vtape_ioctl; + d_read = vtape_read; + + } else { /* tape and file are using normal io */ d_open = ::open; d_write = ::write; d_close = ::close; d_ioctl = ::ioctl; d_read = ::read; } +#endif } /* @@ -1677,7 +1687,7 @@ bool DEVICE::weof(int num) { struct mtop mt_com; int stat; - Dmsg0(129, "weof_dev\n"); + Dmsg1(129, "=== weof_dev=%s\n", print_name()); if (!is_open()) { dev_errno = EBADF; @@ -1862,6 +1872,18 @@ void DEVICE::clrerror(int func) } +/* + * Set to unload the current volume in the drive + */ +void DEVICE::set_unload() +{ + if (!m_unload && VolHdr.VolumeName[0] != 0) { + m_unload = true; + memcpy(UnloadVolName, VolHdr.VolumeName, sizeof(UnloadVolName)); + } +} + + /* * Clear volume header */ @@ -1890,7 +1912,7 @@ void DEVICE::close() switch (dev_type) { case B_VTL_DEV: - case B_FAKETAPE_DEV: + case B_VTAPE_DEV: case B_TAPE_DEV: unlock_door(); default: @@ -1964,7 +1986,7 @@ bool DEVICE::truncate(DCR *dcr) /* We need the DCR for DVD-writing */ Dmsg1(100, "truncate %s\n", print_name()); switch (dev_type) { case B_VTL_DEV: - case B_FAKETAPE_DEV: + case B_VTAPE_DEV: case B_TAPE_DEV: /* maybe we should rewind and write and eof ???? */ return true; /* we don't really truncate tapes */ @@ -2404,7 +2426,6 @@ void init_device_wait_timers(DCR *dcr) dev->rem_wait_sec = dev->wait_sec; dev->num_wait = 0; dev->poll = false; - dev->BadVolName[0] = 0; jcr->min_wait = 60 * 60; jcr->max_wait = 24 * 60 * 60;