/* Initialize -- Set data structure to know value, ignore current value */ int ndmta_initialize (struct ndm_session *sess) { struct ndm_tape_agent * ta = &sess->tape_acb; int rc; NDMOS_MACRO_ZEROFILL(ta); ndmta_commission (sess); rc = ndmos_tape_initialize (sess); if (rc) return rc; return 0; }
/* Initialize -- Set data structure to know value, ignore current value */ int ndmta_initialize (struct ndm_session *sess) { int rc; sess->tape_acb = NDMOS_API_MALLOC (sizeof(struct ndm_tape_agent)); if (!sess->tape_acb) return -1; NDMOS_MACRO_ZEROFILL (sess->tape_acb); ndmta_commission (sess); rc = ndmos_tape_initialize (sess); if (rc) return rc; return 0; }
ndmp9_error ndmos_tape_close (struct ndm_session *sess) { struct ndm_tape_agent * ta = &sess->tape_acb; off_t cur_pos; /* TODO this is not called on an EOF from the DMA, so the lockfile * will remain, although the spec says the tape service should be * automatically closed */ if (ta->tape_fd < 0) { return NDMP9_DEV_NOT_OPEN_ERR; } simu_flush_weof(sess); #if 0 u_long resid; ndmos_tape_mtio (sess, NDMP9_MTIO_REW, 1, &resid); #endif cur_pos = lseek (ta->tape_fd, (off_t)0, 1); if (cur_pos != -1) { char *pos_symlink_name; char pos_buf[32]; pos_symlink_name = g_strdup_printf("%s.pos", ta->drive_name); sprintf (pos_buf, "%ld", (long) cur_pos); if (symlink (pos_buf, pos_symlink_name) < 0) { ; /* ignore error during close */ } g_free(pos_symlink_name); } close (ta->tape_fd); ta->tape_fd = -1; unlink_tape_lockfile(ta->drive_name); ndmos_tape_initialize (sess); return NDMP9_NO_ERR; }
ndmp9_error ndmos_tape_close (struct ndm_session *sess) { ndmp9_error err; struct ndm_tape_agent * ta = sess->tape_acb; if (ta->tape_fd < 0) { return NDMP9_DEV_NOT_OPEN_ERR; } if (sess->ntsc && sess->ntsc->tape_close) { err = sess->ntsc->tape_close(sess); if (err != NDMP9_NO_ERR) return err; } ndmos_tape_initialize (sess); return NDMP9_NO_ERR; }