/* * ndmp_backup_reader * * Backup reader thread which uses backup_work to read and TAR * the files/dirs to be backed up (V2 only) */ static int ndmp_backup_reader(tlm_commands_t *commands, ndmp_lbr_params_t *nlp, char *job_name) { int retval; ndmp_run_args_t np; tlm_job_stats_t *job_stats; tlm_cmd_t *local_commands; NDMP_LOG(LOG_DEBUG, "bk_path: \"%s\"", nlp->nlp_backup_path); local_commands = commands->tcs_command; (void) memset(&np, 0, sizeof (np)); if (!malloc_paths(&np)) return (-1); local_commands->tc_ref++; commands->tcs_reader_count++; job_stats = tlm_ref_job_stats(job_name); retval = backup_work(nlp->nlp_backup_path, job_stats, &np, commands, nlp); write_tar_eof(local_commands); commands->tcs_reader_count--; local_commands->tc_writer = TLM_STOP; tlm_release_reader_writer_ipc(local_commands); tlm_un_ref_job_stats(job_name); free_paths(&np); return (retval); }
/* * malloc_paths * * Allocate the path names (direct and checkpointed paths) */ static boolean_t malloc_paths(ndmp_run_args_t *np) { boolean_t rv; rv = TRUE; np->nr_chkp_nm = ndmp_malloc(TLM_MAX_PATH_NAME); np->nr_unchkp_nm = ndmp_malloc(TLM_MAX_PATH_NAME); if (!np->nr_chkp_nm || !np->nr_unchkp_nm) { free_paths(np); rv = FALSE; } else if ((np->nr_excls = ndmpd_make_exc_list()) == NULL) { free_paths(np); rv = FALSE; } return (rv); }
void free_paths(t_paths *paths) { if (paths) { free_path(paths->path); if (paths->next) free_paths(paths->next); free(paths); } }