/* * timecmp * * This callback function is used during backup. It checks * if the object specified by the 'attr' should be backed * up or not. * * Directories are backed up anyways for dump format. * If this function is called, then the directory is * marked in the bitmap vector, it shows that either the * directory itself is modified or there is something below * it that will be backed up. * * Directories for tar format are backed up if and only if * they are modified. * * By setting ndmp_force_bk_dirs global variable to a non-zero * value, directories are backed up anyways. * * Backing up the directories unconditionally, helps * restoring the metadata of directories as well, when one * of the objects below them are being restored. * * For non-directory objects, if the modification or change * time of the object is after the date specified by the * bk_selector_t, the the object must be backed up. * */ static boolean_t timecmp(bk_selector_t *bksp, struct stat64 *attr) { ndmp_lbr_params_t *nlp; nlp = (ndmp_lbr_params_t *)bksp->bs_cookie; if (S_ISDIR(attr->st_mode) && ndmp_force_bk_dirs) { NDMP_LOG(LOG_DEBUG, "d(%lu)", (uint_t)attr->st_ino); return (TRUE); } if (S_ISDIR(attr->st_mode) && dbm_getone(nlp->nlp_bkmap, (u_longlong_t)attr->st_ino) && ((NLP_ISDUMP(nlp) && ndmp_dump_path_node) || (NLP_ISTAR(nlp) && ndmp_tar_path_node))) { /* * If the object is a directory and it leads to a modified * object (that should be backed up) and for that type of * backup the path nodes should be backed up, then return * TRUE. * * This is required by some DMAs like Backup Express, which * needs to receive ADD_NODE (for dump) or ADD_PATH (for tar) * for the intermediate directories of a modified object. * Other DMAs, like net_backup and net_worker, do not have such * requirement. This requirement makes sense for dump format * but for 'tar' format, it does not. In provision to the * NDMP-v4 spec, for 'tar' format the intermediate directories * need not to be reported. */ NDMP_LOG(LOG_DEBUG, "p(%lu)", (u_longlong_t)attr->st_ino); return (TRUE); } if (attr->st_mtime > bksp->bs_ldate) { NDMP_LOG(LOG_DEBUG, "m(%lu): %lu > %lu", (uint_t)attr->st_ino, (uint_t)attr->st_mtime, (uint_t)bksp->bs_ldate); return (TRUE); } if (attr->st_ctime > bksp->bs_ldate) { if (NLP_IGNCTIME(nlp)) { NDMP_LOG(LOG_DEBUG, "ign c(%lu): %lu > %lu", (uint_t)attr->st_ino, (uint_t)attr->st_ctime, (uint_t)bksp->bs_ldate); return (FALSE); } NDMP_LOG(LOG_DEBUG, "c(%lu): %lu > %lu", (uint_t)attr->st_ino, (uint_t)attr->st_ctime, (uint_t)bksp->bs_ldate); return (TRUE); } NDMP_LOG(LOG_DEBUG, "mc(%lu): (%lu,%lu) < %lu", (uint_t)attr->st_ino, (uint_t)attr->st_mtime, (uint_t)attr->st_ctime, (uint_t)bksp->bs_ldate); return (FALSE); }
/* * ndmpd_mark_inodes_v2 * * Mark the inodes of the backup hierarchy if necessary. * * Parameters: * session (input) - pointer to the session * nlp (input) - pointer to the nlp structure * * Returns: * 0: on success. * != 0: on error. */ int ndmpd_mark_inodes_v2(ndmpd_session_t *session, ndmp_lbr_params_t *nlp) { int rv; if (ndmp_skip_traverse) { syslog(LOG_INFO, "Skip processing directories \"%s\"", nlp->nlp_backup_path); rv = create_allset_bitmap(nlp); } else { if (NLP_ISTAR(nlp)) rv = mark_tar_inodes_v2(session, nlp); else if (NLP_ISDUMP(nlp)) rv = mark_dump_inodes_v2(session, nlp); else { syslog(LOG_ERR, "Unknown backup type for \"%s\"", nlp->nlp_backup_path); rv = -1; } } return (rv); }