Пример #1
0
int
ndmca_tt_wrapper (struct ndm_session *sess,
  int (*func)(struct ndm_session *sess))
{
	int		rc;

	rc = (*func)(sess);

	if (rc != 0) {
		ndmalogf (sess, "Test", 1, "Failure");
	}

	ndmca_test_done_phase (sess);

	/* clean up mess */
	ndmca_test_log_note (sess, 2, "Cleaning up...");

	ndmca_tape_open (sess);	/* Open the tape, OK if already opened */
	ndmca_tape_mtio (sess, NDMP9_MTIO_REW, 1, 0);
	rc = ndmca_tape_close (sess);	/* close, collective error */
	if (rc != 0) {
		ndmca_test_log_note (sess, 0, "Cleaning up failed, quiting");
	} else {
		ndmca_test_log_note (sess, 2, "Cleaning up done");
	}

	return rc;
}
Пример #2
0
int
ndmca_media_open_tape (struct ndm_session *sess)
{
	struct ndm_control_agent *ca = sess->control_acb;
	int			rc;
	unsigned int		t;

	ndmalogf (sess, 0, 1, "Opening tape drive %s %s",
			ca->job.tape_device,
			(ca->tape_mode == NDMP9_TAPE_RDWR_MODE)
				? "read/write" : "read-only");

	rc = -1;
	for (t = 0; t <= ca->job.tape_timeout; t += 10) {
		if (t > 0) {
			ndmalogf (sess, 0, 1,
				"Pausing ten seconds before retry (%d/%d)",
				t, ca->job.tape_timeout);
			sleep (10);
		}
		rc = ndmca_tape_open(sess);
		if (rc == 0) break;
	}

	if (rc) {
		/* should interpret the error */
		ndmalogf (sess, 0, 0, "failed open tape drive %s %s",
			ca->job.tape_device,
			(ca->tape_mode == NDMP9_TAPE_RDWR_MODE)
				? "read/write" : "read-only");
	}

	return rc;
}
Пример #3
0
int ndmca_test_unload_tape(struct ndm_session* sess)
{
  ndmca_tape_open(sess);

  ndmca_media_unload_current(sess);

  return 0;
}