Exemplo n.º 1
0
/*
 * Add a filename to the files we want to restore.
 *
 * The RFC says this:
 *
 * original_path - The original path name of the data to be recovered,
 *                 relative to the backup root. If original_path is the null
 *                 string, the server shall recover all data contained in the
 *                 backup image.
 *
 * destination_path, name, other_name
 *               - Together, these identify the absolute path name to which
 *                 data are to be recovered.
 *
 *               If name is the null string:
 *                 - destination_path identifies the name to which the data
 *                   identified by original_path are to be recovered.
 *                 - other_name must be the null string.
 *
 *               If name is not the null string:
 *                 - destination_path, when concatenated with the server-
 *                   specific path name delimiter and name, identifies the
 *                   name to which the data identified by original_path are
 *                   to be recovered.
 *
 *               If other_name is not the null string:
 *                 - destination_path, when concatenated with the server-
 *                   specific path name delimiter and other_name,
 *                   identifies the alternate name-space name of the data
 *                   to be recovered. The definition of such alternate
 *                   name-space is server-specific.
 *
 * Neither name nor other_name may contain a path name delimiter.
 *
 * Under no circumstance may destination_path be the null string.
 *
 * If intermediate directories that lead to the path name to
 * recover do not exist, the server should create them.
 */
static inline void add_to_namelist(struct ndm_job_param *job,
                                   char *filename,
                                   const char *restore_prefix,
                                   char *name,
                                   char *other_name,
                                   int64_t node)
{
   ndmp9_name nl;
   POOL_MEM destination_path;

   memset(&nl, 0, sizeof(ndmp9_name));

   /*
    * See if the filename is an absolute pathname.
    */
   if (*filename == '\0') {
      pm_strcpy(destination_path, restore_prefix);
   } else if (*filename == '/') {
      Mmsg(destination_path, "%s%s", restore_prefix, filename);
   } else {
      Mmsg(destination_path, "%s/%s", restore_prefix, filename);
   }

   nl.original_path = filename;
   nl.destination_path = destination_path.c_str();
   nl.name = name;
   nl.other_name = other_name;
   nl.node = node;

   ndma_store_nlist(&job->nlist_tab, &nl);
}
Exemplo n.º 2
0
int
ndmda_copy_nlist (struct ndm_session *sess,
  ndmp9_name *nlist, unsigned n_nlist)
{
	struct ndm_data_agent *	da = sess->data_acb;
	unsigned int		i;

	for (i = 0; i < n_nlist; i++) {
		if (!ndma_store_nlist(&da->nlist_tab, &nlist[i])) {
			return -1;	/* no mem */
		}
	}

	/* TODO: sort */

	return 0;
}
Exemplo n.º 3
0
int
args_to_job (void)
{
	struct ndm_job_param *	job = &the_job;
	int			i;

	switch (the_mode) {
	case NDM_JOB_OP_QUERY_AGENTS:
	case NDM_JOB_OP_INIT_LABELS:
	case NDM_JOB_OP_LIST_LABELS:
	case NDM_JOB_OP_REMEDY_ROBOT:
	case NDM_JOB_OP_TEST_TAPE:
	case NDM_JOB_OP_TEST_MOVER:
	case NDM_JOB_OP_TEST_DATA:
	case NDM_JOB_OP_REWIND_TAPE:
	case NDM_JOB_OP_EJECT_TAPE:
	case NDM_JOB_OP_MOVE_TAPE:
	case NDM_JOB_OP_IMPORT_TAPE:
	case NDM_JOB_OP_EXPORT_TAPE:
	case NDM_JOB_OP_LOAD_TAPE:
	case NDM_JOB_OP_UNLOAD_TAPE:
	case NDM_JOB_OP_INIT_ELEM_STATUS:
		break;

	case NDM_JOB_OP_BACKUP:
		args_to_job_backup_env();
		break;

	case NDM_JOB_OP_TOC:
		args_to_job_recover_env();
		args_to_job_recover_nlist();
		if (J_index_file)
			jndex_doit();
		break;

	case NDM_JOB_OP_EXTRACT:
		args_to_job_recover_env();
		args_to_job_recover_nlist();
		jndex_doit();
		break;

	case 'D':		/* -o daemon */
		return 0;

	default:
		printf ("mode -%c not implemented yet\n", the_mode);
		break;
	}
	job->operation = the_mode;

	/* DATA agent */
	job->data_agent  = D_data_agent;
	job->bu_type = B_bu_type;
	job->env_tab = E_environment;
	if (the_mode == NDM_JOB_OP_EXTRACT || the_mode == NDM_JOB_OP_TOC) {
		for (i = 0; i < n_file_arg; i++) {
			ndma_store_nlist (&job->nlist_tab, &nlist[i]);
		}
		job->nlist_tab.n_nlist = n_file_arg;
	}
	job->index_log.deliver = ndmjob_ixlog_deliver;

	/* TAPE agent */
	job->tape_agent  = T_tape_agent;
	job->tape_device = f_tape_device;
	job->record_size = b_bsize * 512;
	job->tape_timeout = o_tape_timeout;
	job->use_eject = o_use_eject;
	job->tape_target = o_tape_scsi;
	job->tape_tcp = o_tape_tcp;

	/* ROBOT agent */
	job->robot_agent = R_robot_agent;
	job->robot_target = r_robot_target;
	job->robot_timeout = o_robot_timeout;
	if (o_tape_addr >= 0) {
		job->drive_addr = o_tape_addr;
		job->drive_addr_given = 1;
	}
	if (o_from_addr >= 0) {
		job->from_addr = o_from_addr;
		job->from_addr_given = 1;
	}
	if (o_to_addr >= 0) {
		job->to_addr = o_to_addr;
		job->to_addr_given = 1;
	}
	if (ROBOT_GIVEN())
		job->have_robot = 1;

	/* media */
	job->media_tab = m_media;

	return 0;
}