#include "scsi-defs.h"
-#include "tapeio.h"
+#include "device.h"
extern FILE *debug_file;
extern changer_t *changer; /* Needed for the infos about emubarcode and labelfile */
char *chgscsi_label = NULL; /* Result pointer for tape_rdlabel */
char *chgscsi_result = NULL; /* Needed for the result string of MapBarCode */
+/*
+ * This used to be in tape-src/tapeio.c; this is the Device API version.
+ */
+
+static char *
+tape_rdlabel(
+ char *devname,
+ char **datestamp,
+ char **label)
+{
+ Device *dev;
+ char *r = NULL;
+
+ dev = device_open(devname);
+ if (dev->status != DEVICE_STATUS_SUCCESS) {
+ r = g_strdup(device_error_or_status(dev));
+ g_object_unref(dev);
+ return r;
+ }
+
+ if (!device_configure(dev, TRUE) || !device_read_label(dev)) {
+ r = g_strdup(device_error_or_status(dev));
+ g_object_unref(dev);
+ return r;
+ }
+
+ *datestamp = g_strdup(dev->volume_time);
+ *label = g_strdup(dev->volume_label);
+
+ return NULL;
+}
+
/*
* First all functions which are called from extern
*/
CDB_T CDB;
extern OpenFiles_T *pDev;
RequestSense_T *pRequestSense;
- char *errstr; /* Used by tape_rewind */
int ret;
int cnt = 0;
int done;
DebugPrint(DEBUG_INFO, SECTION_TAPE,_("Close Device\n"));
SCSI_CloseDevice(DeviceFD);
}
- /* We don't retry if it fails; that is left to the vtape driver. */
- if ((errstr = tape_rewind(pDev[DeviceFD].dev)) == NULL) {
- DebugPrint(DEBUG_INFO, SECTION_TAPE,_("Rewind OK,\n"), cnt);
- } else {
- DebugPrint(DEBUG_ERROR, SECTION_TAPE,_("Rewind failed %s\n"),errstr);
- DebugPrint(DEBUG_INFO, SECTION_TAPE,_("##### STOP GenericRewind (-1)\n"));
- return(-1);
- /*NOTREACHED*/
- }
+ /* no actual rewind operation here -- the device itself will handle that */
DebugPrint(DEBUG_INFO, SECTION_TAPE,_("##### STOP GenericRewind (0)\n"));
}
{
if (section == dsection || dsection == 0)
{
- if (index(buf, '\n') != NULL && strlen(buf) > 1)
+ if (strchr(buf, '\n') != NULL && strlen(buf) > 1)
{
dbprintf(_("%ld:%s"), (long)ti, buf);
} else {