Exemplo n.º 1
0
int
ndmca_monitor_load_next (struct ndm_session *sess)
{
	struct ndm_control_agent *ca = sess->control_acb;
	int			rc;

	ndmalogf (sess, 0, 1, "Operation requires next tape");

	ndmca_media_capture_mover_window (sess);
	ndmca_media_calculate_offsets (sess);

	if (ca->tape_mode == NDMP9_TAPE_RDWR_MODE) {
	    if (ca->mover_state.pause_reason != NDMP9_MOVER_PAUSE_EOM)
		ndmca_media_write_filemarks (sess);
	    else
		ndmalogf (sess, 0, 1, "At EOM, not writing filemarks");
	}

	rc = ndmca_media_unload_current(sess);
	if (rc) return rc;

	rc = ndmca_media_load_next(sess);
	if (rc) return rc;

	rc = ndmca_media_set_window_current (sess);
	if (rc) return rc;

	rc = ndmca_mover_continue(sess);
	if (rc) return rc;

	ndmalogf (sess, 0, 1, "Operation resuming");

	return 0;
}
Exemplo n.º 2
0
/* VERY VERY HARD */
int
ndmca_monitor_seek_tape (struct ndm_session *sess)
{
	struct ndm_control_agent *ca = sess->control_acb;
	int			rc;
	uint64_t		pos;

	pos = ca->last_notify_mover_paused.seek_position;

	ndmalogf (sess, 0, 1, "Operation requires a different tape");

/*	ndmca_media_capture_mover_window (sess);	// !!! */
	ndmca_media_calculate_offsets (sess);

	rc = ndmca_media_unload_current(sess);
	if (rc) return rc;

	rc = ndmca_media_load_seek (sess, pos);
	if (rc) return rc;

	rc = ndmca_media_set_window_current (sess);
	if (rc) return rc;

	rc = ndmca_mover_continue(sess);
	if (rc) return rc;

	ndmalogf (sess, 0, 1, "Operation resuming");

	return 0;
}
Exemplo n.º 3
0
int
ndmca_op_init_labels (struct ndm_session *sess)
{
    struct ndm_control_agent *ca = sess->control_acb;
    struct ndm_job_param *	job = &ca->job;
    struct ndm_media_table *mtab = &job->media_tab;
    int			n_media = mtab->n_media;
    struct ndmmedia *	me;
    int			rc, errors;

    ca->tape_mode = NDMP9_TAPE_RDWR_MODE;
    ca->is_label_op = 1;

    if (n_media <= 0) {
        ndmalogf (sess, 0, 0, "No media entries in table");
        return -1;
    }

    errors = 0;
    for (me = mtab->head; me; me = me->next) {
        if (me->valid_label)
            continue;

        ndmalogf (sess, 0, 0, "media #%d missing a label", me->index);
        errors++;
    }
    if (errors)
        return -1;

    rc = ndmca_op_robot_startup (sess, 1);
    if (rc) return rc;	/* already tattled */

    rc = ndmca_connect_tape_agent (sess);
    if (rc) {
        ndmconn_destruct (sess->plumb.tape);
        sess->plumb.tape = NULL;
        return rc;	/* already tattled */
    }

    for (me = mtab->head; me; me = me->next) {
        ca->cur_media_ix = me->index;

        rc = ndmca_media_load_current (sess);
        if (rc) {
            /* already tattled */
            continue;
        }

        rc = ndmca_media_write_label (sess, 'm', me->label);
        if (rc) {
            ndmalogf (sess, 0, 0, "failed label write");
        }

        ndmca_media_write_filemarks(sess);
        ndmca_media_unload_current (sess);
    }

    return rc;
}
Exemplo n.º 4
0
int ndmca_test_unload_tape(struct ndm_session* sess)
{
  ndmca_tape_open(sess);

  ndmca_media_unload_current(sess);

  return 0;
}
Exemplo n.º 5
0
int
ndmca_media_change (struct ndm_session *sess)
{
	int		rc;

	rc = ndmca_media_unload_current(sess);
	if (rc) return rc;

	rc = ndmca_media_load_next (sess);
	if (rc) return rc;

	return 0;
}
Exemplo n.º 6
0
int
ndmca_monitor_unload_last_tape (struct ndm_session *sess)
{
	struct ndm_control_agent *ca = sess->control_acb;
	int			rc;

	if (!ca->media_is_loaded)
		return 0;

	ndmca_media_capture_mover_window (sess);
	ndmca_media_calculate_offsets (sess);

	if (ca->tape_mode == NDMP9_TAPE_RDWR_MODE) {
		ndmca_media_write_filemarks (sess);
	}

	rc = ndmca_media_unload_current(sess);
	if (rc) return rc;

	return 0;
}
Exemplo n.º 7
0
int
ndmca_op_list_labels (struct ndm_session *sess)
{
    struct ndm_control_agent *ca = sess->control_acb;
    struct ndm_job_param *	job = &ca->job;
    struct ndm_media_table *mtab = &job->media_tab;
    int			n_media;
    char			labbuf[NDMMEDIA_LABEL_MAX];
    char			buf[200];
    struct ndmmedia *	me;
    int			rc;

    ca->tape_mode = NDMP9_TAPE_READ_MODE;
    ca->is_label_op = 1;

    rc = ndmca_op_robot_startup (sess, 0);
    if (rc) return rc;	/* already tattled */

    if (job->media_tab.n_media == 0) {
        if (job->have_robot) {
            rc = ndmca_robot_synthesize_media (sess);
            if (rc) return rc;	/* already tattled */
        } else {
            /*
             * No fixup. Should be done by now.
             * See ndma_job_auto_adjust()
             */
        }
    }

    if ((rc = ndmca_connect_tape_agent (sess)) != 0) {
        ndmconn_destruct (sess->plumb.tape);
        sess->plumb.tape = NULL;
        return rc;	/* already tattled */
    }

    n_media = mtab->n_media;

    for (me = mtab->head; me; me = me->next) {
        ca->cur_media_ix = me->index;

        rc = ndmca_media_load_current (sess);
        if (rc) {
            /* already tattled */
            continue;
        }

        rc = ndmca_media_read_label (sess, labbuf);
        if (rc == 'm' || rc == 'V') {
            strcpy (me->label, labbuf);
            me->valid_label = 1;
            ndmmedia_to_str (me, buf);
            ndmalogf (sess, "ME", 0, "%s", buf);
        } else {
            ndmalogf (sess, 0, 0, "failed label read");
        }
        ndmca_media_unload_current (sess);
    }

    return rc;
}
Exemplo n.º 8
0
int
ndmca_media_unload_last (struct ndm_session *sess)
{
	return ndmca_media_unload_current(sess);
}