Print this page
NEX-9532 NDMP: readdir errors when file/directory has special characters
Reviewed by: Peer Dampmann <peer.dampmann@nexenta.com>
Reviewed by: Alexander Eremin <alexander.eremin@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-5801 Snapshots left over after failed backups
Reviewed by: Rick Mesta <rick.mesta@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Revert "NEX-5801 Snapshots left over after failed backups"
This reverts commit f182fb95f09036db71fbfc6f0a6b90469b761f21.
NEX-5801 Snapshots left over after failed backups
Reviewed by: Rick Mesta <rick.mesta@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
NEX-2911 NDMP logging should use syslog and is too chatty
        
*** 35,44 ****
--- 35,45 ----
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   * POSSIBILITY OF SUCH DAMAGE.
   */
  /* Copyright (c) 1996, 1997 PDC, Network Appliance. All Rights Reserved */
  /* Copyright (c) 2007, The Storage Networking Industry Association. */
+ /* Copyright 2017 Nexenta Systems, Inc. All rights reserved. */
  
  /*
   * File history callback functions called by backup modules. NDMP file history
   * supports 2 file history models: path based and inode/directory based.
   * Backup/recover modules similar to unix dump/restore utilize the
*** 51,60 ****
--- 52,62 ----
   * included with the SDK uses the path based model.
   */
  
  #include <sys/stat.h>
  #include <sys/types.h>
+ #include <syslog.h>
  #include <dirent.h>
  #include <errno.h>
  #include <stdlib.h>
  #include <string.h>
  #include "ndmpd.h"
*** 132,151 ****
              session->ns_fh.fh_path_index == N_PATH_ENTRIES ||
              session->ns_fh.fh_path_name_buf_index + strlen(name) + 1 >
              PATH_NAMEBUF_SIZE) {
                  ndmp_fh_add_unix_path_request request;
  
-                 NDMP_LOG(LOG_DEBUG,
-                     "sending %ld entries", session->ns_fh.fh_path_index);
  
                  request.paths.paths_val = session->ns_fh.fh_path_entries;
                  request.paths.paths_len = session->ns_fh.fh_path_index;
  
                  if (ndmp_send_request_lock(session->ns_connection,
                      NDMP_FH_ADD_UNIX_PATH, NDMP_NO_ERR, (void *) &request,
                      0) < 0) {
!                         NDMP_LOG(LOG_DEBUG, "Sending file history data");
                          return (-1);
                  }
                  session->ns_fh.fh_path_index = 0;
                  session->ns_fh.fh_path_name_buf_index = 0;
          }
--- 134,151 ----
              session->ns_fh.fh_path_index == N_PATH_ENTRIES ||
              session->ns_fh.fh_path_name_buf_index + strlen(name) + 1 >
              PATH_NAMEBUF_SIZE) {
                  ndmp_fh_add_unix_path_request request;
  
  
                  request.paths.paths_val = session->ns_fh.fh_path_entries;
                  request.paths.paths_len = session->ns_fh.fh_path_index;
  
                  if (ndmp_send_request_lock(session->ns_connection,
                      NDMP_FH_ADD_UNIX_PATH, NDMP_NO_ERR, (void *) &request,
                      0) < 0) {
!                         syslog(LOG_ERR, "Sending file history data failed");
                          return (-1);
                  }
                  session->ns_fh.fh_path_index = 0;
                  session->ns_fh.fh_path_name_buf_index = 0;
          }
*** 224,242 ****
              session->ns_fh.fh_dir_index == N_DIR_ENTRIES ||
              session->ns_fh.fh_dir_name_buf_index + strlen(name) + 1 >
              DIR_NAMEBUF_SIZE) {
                  ndmp_fh_add_unix_dir_request request;
  
-                 NDMP_LOG(LOG_DEBUG,
-                     "sending %ld entries", session->ns_fh.fh_dir_index);
- 
                  request.dirs.dirs_val = session->ns_fh.fh_dir_entries;
                  request.dirs.dirs_len = session->ns_fh.fh_dir_index;
                  if (ndmp_send_request_lock(session->ns_connection,
                      NDMP_FH_ADD_UNIX_DIR, NDMP_NO_ERR, (void *) &request,
                      0) < 0) {
!                         NDMP_LOG(LOG_DEBUG, "Sending file history data");
                          return (-1);
                  }
                  session->ns_fh.fh_dir_index = 0;
                  session->ns_fh.fh_dir_name_buf_index = 0;
          }
--- 224,239 ----
              session->ns_fh.fh_dir_index == N_DIR_ENTRIES ||
              session->ns_fh.fh_dir_name_buf_index + strlen(name) + 1 >
              DIR_NAMEBUF_SIZE) {
                  ndmp_fh_add_unix_dir_request request;
  
                  request.dirs.dirs_val = session->ns_fh.fh_dir_entries;
                  request.dirs.dirs_len = session->ns_fh.fh_dir_index;
                  if (ndmp_send_request_lock(session->ns_connection,
                      NDMP_FH_ADD_UNIX_DIR, NDMP_NO_ERR, (void *) &request,
                      0) < 0) {
!                         syslog(LOG_DEBUG, "Sending file history data");
                          return (-1);
                  }
                  session->ns_fh.fh_dir_index = 0;
                  session->ns_fh.fh_dir_name_buf_index = 0;
          }
*** 311,323 ****
          if (file_stat == NULL ||
              (ndmp_syncfh && session->ns_fh.fh_node_index != 0) ||
              session->ns_fh.fh_node_index == N_NODE_ENTRIES) {
                  ndmp_fh_add_unix_node_request request;
  
-                 NDMP_LOG(LOG_DEBUG,
-                     "sending %ld entries", session->ns_fh.fh_node_index);
- 
                  request.nodes.nodes_val = session->ns_fh.fh_node_entries;
                  request.nodes.nodes_len = session->ns_fh.fh_node_index;
                  /*
                   * Need to send Dir entry as well. Since Dir entry is more than
                   * Node entry, we may send a Node entry that hasn't have
--- 308,317 ----
*** 327,337 ****
                  (void) ndmpd_api_file_history_dir_v2(session, 0, 0, 0);
  
                  if (ndmp_send_request_lock(session->ns_connection,
                      NDMP_FH_ADD_UNIX_NODE, NDMP_NO_ERR, (void *) &request,
                      0) < 0) {
!                         NDMP_LOG(LOG_DEBUG, "Sending file history data");
                          return (-1);
                  }
                  session->ns_fh.fh_node_index = 0;
          }
          if (file_stat == NULL)
--- 321,331 ----
                  (void) ndmpd_api_file_history_dir_v2(session, 0, 0, 0);
  
                  if (ndmp_send_request_lock(session->ns_connection,
                      NDMP_FH_ADD_UNIX_NODE, NDMP_NO_ERR, (void *) &request,
                      0) < 0) {
!                         syslog(LOG_ERR, "Sending file history data failed");
                          return (-1);
                  }
                  session->ns_fh.fh_node_index = 0;
          }
          if (file_stat == NULL)
*** 407,426 ****
          if (name == NULL ||
              session->ns_fh_v3.fh_file_index == N_FILE_ENTRIES ||
              session->ns_fh_v3.fh_file_name_buf_index + strlen(name) + 1 >
              PATH_NAMEBUF_SIZE) {
  
-                 NDMP_LOG(LOG_DEBUG, "sending %ld entries",
-                     session->ns_fh_v3.fh_file_index);
- 
                  request.files.files_len = session->ns_fh_v3.fh_file_index;
                  request.files.files_val = session->ns_fh_v3.fh_files;
  
                  if (ndmp_send_request_lock(session->ns_connection,
                      NDMP_FH_ADD_FILE, NDMP_NO_ERR, (void *) &request, 0) < 0) {
!                         NDMP_LOG(LOG_DEBUG,
!                             "Sending ndmp_fh_add_file request");
                          return (-1);
                  }
  
                  session->ns_fh_v3.fh_file_index = 0;
                  session->ns_fh_v3.fh_file_name_buf_index = 0;
--- 401,417 ----
          if (name == NULL ||
              session->ns_fh_v3.fh_file_index == N_FILE_ENTRIES ||
              session->ns_fh_v3.fh_file_name_buf_index + strlen(name) + 1 >
              PATH_NAMEBUF_SIZE) {
  
                  request.files.files_len = session->ns_fh_v3.fh_file_index;
                  request.files.files_val = session->ns_fh_v3.fh_files;
  
                  if (ndmp_send_request_lock(session->ns_connection,
                      NDMP_FH_ADD_FILE, NDMP_NO_ERR, (void *) &request, 0) < 0) {
!                         syslog(LOG_ERR,
!                             "Sending ndmp_fh_add_file request failed");
                          return (-1);
                  }
  
                  session->ns_fh_v3.fh_file_index = 0;
                  session->ns_fh_v3.fh_file_name_buf_index = 0;
*** 537,556 ****
          if (name == NULL ||
              session->ns_fh_v3.fh_dir_index == N_DIR_ENTRIES ||
              session->ns_fh_v3.fh_dir_name_buf_index + strlen(name) + 1 >
              DIR_NAMEBUF_SIZE) {
  
-                 NDMP_LOG(LOG_DEBUG, "sending %ld entries",
-                     session->ns_fh_v3.fh_dir_index);
- 
                  request.dirs.dirs_val = session->ns_fh_v3.fh_dirs;
                  request.dirs.dirs_len = session->ns_fh_v3.fh_dir_index;
  
                  if (ndmp_send_request_lock(session->ns_connection,
                      NDMP_FH_ADD_DIR, NDMP_NO_ERR, (void *) &request, 0) < 0) {
!                         NDMP_LOG(LOG_DEBUG,
!                             "Sending ndmp_fh_add_dir request");
                          return (-1);
                  }
  
                  session->ns_fh_v3.fh_dir_index = 0;
                  session->ns_fh_v3.fh_dir_name_buf_index = 0;
--- 528,544 ----
          if (name == NULL ||
              session->ns_fh_v3.fh_dir_index == N_DIR_ENTRIES ||
              session->ns_fh_v3.fh_dir_name_buf_index + strlen(name) + 1 >
              DIR_NAMEBUF_SIZE) {
  
                  request.dirs.dirs_val = session->ns_fh_v3.fh_dirs;
                  request.dirs.dirs_len = session->ns_fh_v3.fh_dir_index;
  
                  if (ndmp_send_request_lock(session->ns_connection,
                      NDMP_FH_ADD_DIR, NDMP_NO_ERR, (void *) &request, 0) < 0) {
!                         syslog(LOG_ERR,
!                             "Sending ndmp_fh_add_dir request failed");
                          return (-1);
                  }
  
                  session->ns_fh_v3.fh_dir_index = 0;
                  session->ns_fh_v3.fh_dir_name_buf_index = 0;
*** 643,654 ****
           * A 0 file_stat pointer indicates that any buffered data should
           * be sent.
           */
          if (file_stat == NULL ||
              session->ns_fh_v3.fh_node_index == N_NODE_ENTRIES) {
-                 NDMP_LOG(LOG_DEBUG, "sending %ld entries",
-                     session->ns_fh_v3.fh_node_index);
  
                  /*
                   * Need to send Dir entry as well. Since Dir entry is more
                   * than a Node entry, we may send a Node entry that hasn't
                   * had its Dir entry sent. Therefore, we need to flush Dir
--- 631,640 ----
*** 660,671 ****
                  request.nodes.nodes_val = session->ns_fh_v3.fh_nodes;
  
                  if (ndmp_send_request_lock(session->ns_connection,
                      NDMP_FH_ADD_NODE,
                      NDMP_NO_ERR, (void *) &request, 0) < 0) {
!                         NDMP_LOG(LOG_DEBUG,
!                             "Sending ndmp_fh_add_node request");
                          return (-1);
                  }
  
                  session->ns_fh_v3.fh_node_index = 0;
          }
--- 646,657 ----
                  request.nodes.nodes_val = session->ns_fh_v3.fh_nodes;
  
                  if (ndmp_send_request_lock(session->ns_connection,
                      NDMP_FH_ADD_NODE,
                      NDMP_NO_ERR, (void *) &request, 0) < 0) {
!                         syslog(LOG_ERR,
!                             "Sending ndmp_fh_add_node request failed");
                          return (-1);
                  }
  
                  session->ns_fh_v3.fh_node_index = 0;
          }
*** 737,768 ****
          ndmp_lbr_params_t *nlp;
          ndmpd_module_params_t *params;
  
          if (!cbp) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "cbp is NULL");
          } else if (!cbp->fh_cookie) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "cookie is NULL");
          } else if (!path) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "path is NULL");
          } else if (!(nlp = ndmp_get_nlp(cbp->fh_cookie))) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "nlp is NULL");
          } else
                  err = 0;
  
          if (err != 0)
                  return (0);
  
-         NDMP_LOG(LOG_DEBUG, "pname(%s)", path);
- 
          err = 0;
          if (NLP_ISSET(nlp, NLPF_FH)) {
                  if (!NLP_ISSET(nlp, NLPF_DIRECT)) {
!                         NDMP_LOG(LOG_DEBUG, "DAR NOT SET!");
                          off = 0LL;
                  }
  
                  params = get_params(cbp->fh_cookie);
                  if (!params || !params->mp_file_history_path_func) {
--- 723,752 ----
          ndmp_lbr_params_t *nlp;
          ndmpd_module_params_t *params;
  
          if (!cbp) {
                  err = -1;
!                 syslog(LOG_DEBUG, "cbp is NULL");
          } else if (!cbp->fh_cookie) {
                  err = -1;
!                 syslog(LOG_DEBUG, "cookie is NULL");
          } else if (!path) {
                  err = -1;
!                 syslog(LOG_DEBUG, "path is NULL");
          } else if (!(nlp = ndmp_get_nlp(cbp->fh_cookie))) {
                  err = -1;
!                 syslog(LOG_DEBUG, "nlp is NULL");
          } else
                  err = 0;
  
          if (err != 0)
                  return (0);
  
          err = 0;
          if (NLP_ISSET(nlp, NLPF_FH)) {
                  if (!NLP_ISSET(nlp, NLPF_DIRECT)) {
!                         syslog(LOG_DEBUG, "DAR NOT SET!");
                          off = 0LL;
                  }
  
                  params = get_params(cbp->fh_cookie);
                  if (!params || !params->mp_file_history_path_func) {
*** 771,781 ****
                          char *p =
                              ndmp_get_relative_path(get_backup_path_v3(params),
                              path);
                          if ((err = ndmpd_api_file_history_file_v3(cbp->
                              fh_cookie, p, stp, off)) < 0)
!                                 NDMP_LOG(LOG_DEBUG, "\"%s\" %d", path, err);
                  }
          }
  
          return (err);
  }
--- 755,765 ----
                          char *p =
                              ndmp_get_relative_path(get_backup_path_v3(params),
                              path);
                          if ((err = ndmpd_api_file_history_file_v3(cbp->
                              fh_cookie, p, stp, off)) < 0)
!                                 syslog(LOG_DEBUG, "\"%s\" %d", path, err);
                  }
          }
  
          return (err);
  }
*** 799,826 ****
          DIR *dirp;
          char dirpath[PATH_MAX];
  
          if (!cbp) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "cbp is NULL");
          } else if (!cbp->fh_cookie) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "cookie is NULL");
          } else if (!dir) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "dir is NULL");
          } else if (!(nlp = ndmp_get_nlp(cbp->fh_cookie))) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "nlp is NULL");
          } else
                  err = 0;
  
          if (err != 0)
                  return (0);
  
-         NDMP_LOG(LOG_DEBUG, "d(%s)", dir);
- 
          if (!NLP_ISSET(nlp, NLPF_FH))
                  return (0);
  
          /*
           * Veritas net_backup accepts only 2 as the inode number of the backup
--- 783,808 ----
          DIR *dirp;
          char dirpath[PATH_MAX];
  
          if (!cbp) {
                  err = -1;
!                 syslog(LOG_DEBUG, "cbp is NULL");
          } else if (!cbp->fh_cookie) {
                  err = -1;
!                 syslog(LOG_DEBUG, "cookie is NULL");
          } else if (!dir) {
                  err = -1;
!                 syslog(LOG_DEBUG, "dir is NULL");
          } else if (!(nlp = ndmp_get_nlp(cbp->fh_cookie))) {
                  err = -1;
!                 syslog(LOG_DEBUG, "nlp is NULL");
          } else
                  err = 0;
  
          if (err != 0)
                  return (0);
  
          if (!NLP_ISSET(nlp, NLPF_FH))
                  return (0);
  
          /*
           * Veritas net_backup accepts only 2 as the inode number of the backup
*** 838,848 ****
           * been set.  Backup root directory is exception.  We
           * always send the dir file history records of it.
           */
          if (pino != ROOT_INODE &&
              !dbm_getone(nlp->nlp_bkmap, (u_longlong_t)stp->st_ino)) {
!                 NDMP_LOG(LOG_DEBUG, "nothing below here");
                  return (0);
          }
  
          params = nlp->nlp_params;
          if (!params || !params->mp_file_history_dir_func)
--- 820,830 ----
           * been set.  Backup root directory is exception.  We
           * always send the dir file history records of it.
           */
          if (pino != ROOT_INODE &&
              !dbm_getone(nlp->nlp_bkmap, (u_longlong_t)stp->st_ino)) {
!                 syslog(LOG_DEBUG, "nothing below here");
                  return (0);
          }
  
          params = nlp->nlp_params;
          if (!params || !params->mp_file_history_dir_func)
*** 857,867 ****
  
          do {
                  nml = PATH_MAX;
                  err = dp_readdir(dirp, &pos, nm, &nml, &ino);
                  if (err != 0) {
!                         NDMP_LOG(LOG_DEBUG,
                              "%d reading pos %u dir \"%s\"", err, pos, dir);
                          break;
                  }
                  if (nml == 0)
                          break;
--- 839,849 ----
  
          do {
                  nml = PATH_MAX;
                  err = dp_readdir(dirp, &pos, nm, &nml, &ino);
                  if (err != 0) {
!                         syslog(LOG_DEBUG,
                              "%d reading pos %u dir \"%s\"", err, pos, dir);
                          break;
                  }
                  if (nml == 0)
                          break;
*** 869,879 ****
  
                  if (pino == ROOT_INODE) {
                          if (rootfs_dot_or_dotdot(nm))
                                  ino = ROOT_INODE;
                  } else if (ino == nlp->nlp_bkdirino && IS_DOTDOT(nm)) {
-                         NDMP_LOG(LOG_DEBUG, "nm(%s): %lu", nm, ino);
                          ino = ROOT_INODE;
                  }
  
                  if (!dbm_getone(nlp->nlp_bkmap, (u_longlong_t)ino))
                          continue;
--- 851,860 ----
*** 880,898 ****
  
                  /*
                   * If the entry is on exclusion list dont send the info
                   */
                  if (tlm_is_excluded(dir, nm, ndmp_excl_list)) {
!                         NDMP_LOG(LOG_DEBUG,
!                             "name \"%s\" skipped", nm == 0 ? "nil" : nm);
                          continue;
                  }
  
                  err = (*params->mp_file_history_dir_func)(cbp->fh_cookie, nm,
                      ino, pino);
                  if (err < 0) {
!                         NDMP_LOG(LOG_DEBUG, "\"%s\": %d", dir, err);
                          break;
                  }
  
                  /*
                   * This is a requirement by some DMA's (net_vault) that during
--- 861,879 ----
  
                  /*
                   * If the entry is on exclusion list dont send the info
                   */
                  if (tlm_is_excluded(dir, nm, ndmp_excl_list)) {
!                         syslog(LOG_DEBUG,
!                             "name \"%s\" skipped", *nm == '\0' ? "nil" : nm);
                          continue;
                  }
  
                  err = (*params->mp_file_history_dir_func)(cbp->fh_cookie, nm,
                      ino, pino);
                  if (err < 0) {
!                         syslog(LOG_ERR, "\"%s\": %d", dir, err);
                          break;
                  }
  
                  /*
                   * This is a requirement by some DMA's (net_vault) that during
*** 906,925 ****
                          (void) strlcpy(dirpath, dir, PATH_MAX);
                          (void) strlcat(dirpath, "/", PATH_MAX);
                          (void) strlcat(dirpath, nm, PATH_MAX);
                          err = stat64(dirpath, &ret_attr);
                          if (err != 0) {
!                                 NDMP_LOG(LOG_DEBUG,
                                      "Error looking up %s", nm);
                                  break;
                          }
  
                          if (S_ISDIR(ret_attr.st_mode)) {
                                  err = (*params->mp_file_history_node_func)(cbp->
                                      fh_cookie, ino, &ret_attr, 0);
                                  if (err < 0) {
!                                         NDMP_LOG(LOG_DEBUG, "\"%s/\": %d",
                                              dir, err);
                                          break;
                                  }
                          }
                  }
--- 887,906 ----
                          (void) strlcpy(dirpath, dir, PATH_MAX);
                          (void) strlcat(dirpath, "/", PATH_MAX);
                          (void) strlcat(dirpath, nm, PATH_MAX);
                          err = stat64(dirpath, &ret_attr);
                          if (err != 0) {
!                                 syslog(LOG_ERR,
                                      "Error looking up %s", nm);
                                  break;
                          }
  
                          if (S_ISDIR(ret_attr.st_mode)) {
                                  err = (*params->mp_file_history_node_func)(cbp->
                                      fh_cookie, ino, &ret_attr, 0);
                                  if (err < 0) {
!                                         syslog(LOG_ERR, "\"%s/\": %d",
                                              dir, err);
                                          break;
                                  }
                          }
                  }
*** 944,995 ****
          ndmp_lbr_params_t *nlp;
          ndmpd_module_params_t *params;
  
          if (!cbp) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "cbp is NULL");
          } else if (!cbp->fh_cookie) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "cookie is NULL");
          } else if (!dir) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "dir is NULL");
          } else if (!file) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "file is NULL");
          } else if (!stp) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "stp is NULL");
          } else if (!(nlp = ndmp_get_nlp(cbp->fh_cookie))) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "nlp is NULL");
          } else {
                  err = 0;
          }
  
          if (err != 0)
                  return (0);
  
-         NDMP_LOG(LOG_DEBUG, "d(%s), f(%s)", dir, file);
  
          err = 0;
          if (NLP_ISSET(nlp, NLPF_FH)) {
                  if (!NLP_ISSET(nlp, NLPF_DIRECT))
                          off = 0LL;
                  if (stp->st_ino == nlp->nlp_bkdirino) {
                          ino = ROOT_INODE;
-                         NDMP_LOG(LOG_DEBUG,
-                             "bkroot %d -> %d", stp->st_ino, ROOT_INODE);
                  } else
                          ino = stp->st_ino;
  
                  params = nlp->nlp_params;
                  if (!params || !params->mp_file_history_node_func)
                          err = -1;
                  else if ((err = (*params->mp_file_history_node_func)(cbp->
                      fh_cookie, ino, stp, off)) < 0)
!                         NDMP_LOG(LOG_DEBUG, "\"%s/%s\" %d", dir, file, err);
          }
  
          return (err);
  }
  
--- 925,973 ----
          ndmp_lbr_params_t *nlp;
          ndmpd_module_params_t *params;
  
          if (!cbp) {
                  err = -1;
!                 syslog(LOG_DEBUG, "cbp is NULL");
          } else if (!cbp->fh_cookie) {
                  err = -1;
!                 syslog(LOG_DEBUG, "cookie is NULL");
          } else if (!dir) {
                  err = -1;
!                 syslog(LOG_DEBUG, "dir is NULL");
          } else if (!file) {
                  err = -1;
!                 syslog(LOG_DEBUG, "file is NULL");
          } else if (!stp) {
                  err = -1;
!                 syslog(LOG_DEBUG, "stp is NULL");
          } else if (!(nlp = ndmp_get_nlp(cbp->fh_cookie))) {
                  err = -1;
!                 syslog(LOG_DEBUG, "nlp is NULL");
          } else {
                  err = 0;
          }
  
          if (err != 0)
                  return (0);
  
  
          err = 0;
          if (NLP_ISSET(nlp, NLPF_FH)) {
                  if (!NLP_ISSET(nlp, NLPF_DIRECT))
                          off = 0LL;
                  if (stp->st_ino == nlp->nlp_bkdirino) {
                          ino = ROOT_INODE;
                  } else
                          ino = stp->st_ino;
  
                  params = nlp->nlp_params;
                  if (!params || !params->mp_file_history_node_func)
                          err = -1;
                  else if ((err = (*params->mp_file_history_node_func)(cbp->
                      fh_cookie, ino, stp, off)) < 0)
!                         syslog(LOG_ERR, "\"%s/%s\" %d", dir, file, err);
          }
  
          return (err);
  }
  
*** 1006,1028 ****
          int rv;
          mem_ndmp_name_v3_t *ep;
  
          rv = -1;
          if (!params) {
!                 NDMP_LOG(LOG_DEBUG, "params == NULL");
          } else if (!params->mp_file_recovered_func) {
!                 NDMP_LOG(LOG_DEBUG, "paramsfile_recovered_func == NULL");
          } else if (!nlp) {
!                 NDMP_LOG(LOG_DEBUG, "nlp == NULL");
          } else if (idx < 0) {
!                 NDMP_LOG(LOG_DEBUG, "idx(%d) < 0", idx);
          } else if (!(ep = (mem_ndmp_name_v3_t *)MOD_GETNAME(params, idx))) {
!                 NDMP_LOG(LOG_DEBUG, "nlist[%d] == NULL", idx);
          } else if (!ep->nm3_opath) {
!                 NDMP_LOG(LOG_DEBUG, "nlist[%d].nm3_opath == NULL", idx);
          } else {
!                 NDMP_LOG(LOG_DEBUG,
                      "ep[%d].nm3_opath \"%s\"", idx, ep->nm3_opath);
                  rv = MOD_FILERECOVERD(params, ep->nm3_opath, stat);
          }
  
          return (rv);
--- 984,1006 ----
          int rv;
          mem_ndmp_name_v3_t *ep;
  
          rv = -1;
          if (!params) {
!                 syslog(LOG_DEBUG, "params == NULL");
          } else if (!params->mp_file_recovered_func) {
!                 syslog(LOG_DEBUG, "paramsfile_recovered_func == NULL");
          } else if (!nlp) {
!                 syslog(LOG_DEBUG, "nlp == NULL");
          } else if (idx < 0) {
!                 syslog(LOG_DEBUG, "idx(%d) < 0", idx);
          } else if (!(ep = (mem_ndmp_name_v3_t *)MOD_GETNAME(params, idx))) {
!                 syslog(LOG_DEBUG, "nlist[%d] == NULL", idx);
          } else if (!ep->nm3_opath) {
!                 syslog(LOG_DEBUG, "nlist[%d].nm3_opath == NULL", idx);
          } else {
!                 syslog(LOG_DEBUG,
                      "ep[%d].nm3_opath \"%s\"", idx, ep->nm3_opath);
                  rv = MOD_FILERECOVERD(params, ep->nm3_opath, stat);
          }
  
          return (rv);
*** 1044,1070 ****
          ndmp_lbr_params_t *nlp;
          ndmpd_module_params_t *params;
          int idx = (int)ll_idx;
  
          if (!cbp) {
!                 NDMP_LOG(LOG_DEBUG, "cbp is NULL");
                  return (-1);
          }
          if (!name) {
!                 NDMP_LOG(LOG_DEBUG, "name is NULL");
                  return (-1);
          }
  
-         NDMP_LOG(LOG_DEBUG, "name: \"%s\", idx: %d", name, idx);
- 
          nlp = ndmp_get_nlp(cbp->fh_cookie);
          if (!nlp) {
!                 NDMP_LOG(LOG_DEBUG, "nlp is NULL");
                  return (-1);
          }
          if (idx < 0 || idx >= nlp->nlp_nfiles) {
!                 NDMP_LOG(LOG_DEBUG, "Invalid idx: %d", idx);
                  return (-1);
          }
          params = nlp->nlp_params;
          if (!params || !params->mp_file_recovered_func)
                  return (-1);
--- 1022,1046 ----
          ndmp_lbr_params_t *nlp;
          ndmpd_module_params_t *params;
          int idx = (int)ll_idx;
  
          if (!cbp) {
!                 syslog(LOG_DEBUG, "cbp is NULL");
                  return (-1);
          }
          if (!name) {
!                 syslog(LOG_DEBUG, "name is NULL");
                  return (-1);
          }
  
          nlp = ndmp_get_nlp(cbp->fh_cookie);
          if (!nlp) {
!                 syslog(LOG_DEBUG, "nlp is NULL");
                  return (-1);
          }
          if (idx < 0 || idx >= nlp->nlp_nfiles) {
!                 syslog(LOG_DEBUG, "Invalid idx: %d", idx);
                  return (-1);
          }
          params = nlp->nlp_params;
          if (!params || !params->mp_file_recovered_func)
                  return (-1);
*** 1272,1282 ****
          case 3:
          case 4:
                  ndmpd_file_history_cleanup_v3(session, send_flag);
                  break;
          default:
!                 NDMP_LOG(LOG_DEBUG, "Unknown version %d",
                      session->ns_protocol_version);
          }
  }
  
  /*
--- 1248,1258 ----
          case 3:
          case 4:
                  ndmpd_file_history_cleanup_v3(session, send_flag);
                  break;
          default:
!                 syslog(LOG_ERR, "Unknown version %d",
                      session->ns_protocol_version);
          }
  }
  
  /*
*** 1305,1319 ****
  fh_requested(void *cookie)
  {
          ndmp_lbr_params_t *nlp;
  
          if ((nlp = ndmp_get_nlp(cookie)) == NULL) {
!                 NDMP_LOG(LOG_DEBUG, "nlp is NULL");
                  return (FALSE);
          }
  
!         NDMP_LOG(LOG_DEBUG, "nlp_fh %c", NDMP_YORN(NLP_ISSET(nlp, NLPF_FH)));
  
          return (NLP_ISSET(nlp, NLPF_FH));
  }
  
  
--- 1281,1295 ----
  fh_requested(void *cookie)
  {
          ndmp_lbr_params_t *nlp;
  
          if ((nlp = ndmp_get_nlp(cookie)) == NULL) {
!                 syslog(LOG_DEBUG, "nlp is NULL");
                  return (FALSE);
          }
  
!         syslog(LOG_DEBUG, "nlp_fh %c", NDMP_YORN(NLP_ISSET(nlp, NLPF_FH)));
  
          return (NLP_ISSET(nlp, NLPF_FH));
  }
  
  
*** 1335,1370 ****
          int err;
          ndmpd_module_params_t *params;
  
          if (!cbp) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "cbp is NULL");
          } else if (!cbp->fh_cookie) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "cookie is NULL");
          } else if (!path) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "path is NULL");
          } else if (!stp) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "stp is NULL");
          } else
                  err = 0;
  
          if (err != 0)
                  return (0);
  
!         NDMP_LOG(LOG_DEBUG, "path: \"%s\"", path);
  
          err = 0;
          if (fh_requested(cbp->fh_cookie)) {
                  params = get_params(cbp->fh_cookie);
                  if (params == NULL || params->mp_file_history_path_func == NULL)
                          err = -1;
                  else if ((err = (*params->mp_file_history_path_func)(cbp->
                      fh_cookie, path, stp, 0)) < 0)
!                         NDMP_LOG(LOG_DEBUG, "\"%s\": %d", path, err);
          }
  
          return (err);
  }
  
--- 1311,1346 ----
          int err;
          ndmpd_module_params_t *params;
  
          if (!cbp) {
                  err = -1;
!                 syslog(LOG_DEBUG, "cbp is NULL");
          } else if (!cbp->fh_cookie) {
                  err = -1;
!                 syslog(LOG_DEBUG, "cookie is NULL");
          } else if (!path) {
                  err = -1;
!                 syslog(LOG_DEBUG, "path is NULL");
          } else if (!stp) {
                  err = -1;
!                 syslog(LOG_DEBUG, "stp is NULL");
          } else
                  err = 0;
  
          if (err != 0)
                  return (0);
  
!         syslog(LOG_DEBUG, "path: \"%s\"", path);
  
          err = 0;
          if (fh_requested(cbp->fh_cookie)) {
                  params = get_params(cbp->fh_cookie);
                  if (params == NULL || params->mp_file_history_path_func == NULL)
                          err = -1;
                  else if ((err = (*params->mp_file_history_path_func)(cbp->
                      fh_cookie, path, stp, 0)) < 0)
!                         syslog(LOG_DEBUG, "\"%s\": %d", path, err);
          }
  
          return (err);
  }
  
*** 1388,1417 ****
          DIR *dirp;
          char dirpath[PATH_MAX];
  
          if (!cbp) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "cbp is NULL");
          } else if (!cbp->fh_cookie) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "cookie is NULL");
          } else if (!dir) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "dir is NULL");
          } else if (!stp) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "stp is NULL");
          } if (!(nlp = ndmp_get_nlp(cbp->fh_cookie))) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "nlp is NULL");
          } else
                  err = 0;
  
          if (err != 0)
                  return (0);
  
!         NDMP_LOG(LOG_DEBUG, "dir: \"%s\"", dir);
  
          if (!fh_requested(cbp->fh_cookie))
                  return (0);
  
          /*
--- 1364,1393 ----
          DIR *dirp;
          char dirpath[PATH_MAX];
  
          if (!cbp) {
                  err = -1;
!                 syslog(LOG_DEBUG, "cbp is NULL");
          } else if (!cbp->fh_cookie) {
                  err = -1;
!                 syslog(LOG_DEBUG, "cookie is NULL");
          } else if (!dir) {
                  err = -1;
!                 syslog(LOG_DEBUG, "dir is NULL");
          } else if (!stp) {
                  err = -1;
!                 syslog(LOG_DEBUG, "stp is NULL");
          } if (!(nlp = ndmp_get_nlp(cbp->fh_cookie))) {
                  err = -1;
!                 syslog(LOG_DEBUG, "nlp is NULL");
          } else
                  err = 0;
  
          if (err != 0)
                  return (0);
  
!         syslog(LOG_DEBUG, "dir: \"%s\"", dir);
  
          if (!fh_requested(cbp->fh_cookie))
                  return (0);
  
          /*
*** 1430,1440 ****
           * been set.  Backup root directory is exception.  We
           * always send the dir file history records of it.
           */
          if (pino != ROOT_INODE &&
              !dbm_getone(nlp->nlp_bkmap, (u_longlong_t)stp->st_ino)) {
!                 NDMP_LOG(LOG_DEBUG, "nothing below here");
                  return (0);
          }
  
          params = get_params(cbp->fh_cookie);
          if (params == NULL || params->mp_file_history_dir_func == NULL) {
--- 1406,1416 ----
           * been set.  Backup root directory is exception.  We
           * always send the dir file history records of it.
           */
          if (pino != ROOT_INODE &&
              !dbm_getone(nlp->nlp_bkmap, (u_longlong_t)stp->st_ino)) {
!                 syslog(LOG_DEBUG, "nothing below here");
                  return (0);
          }
  
          params = get_params(cbp->fh_cookie);
          if (params == NULL || params->mp_file_history_dir_func == NULL) {
*** 1450,1460 ****
  
          do {
                  nml = PATH_MAX;
                  err = dp_readdir(dirp, &pos, nm, &nml, &ino);
                  if (err != 0) {
!                         NDMP_LOG(LOG_DEBUG,
                              "%d reading pos %u dir \"%s\"", err, pos, dir);
                          break;
                  }
                  if (nml == 0)
                          break;
--- 1426,1436 ----
  
          do {
                  nml = PATH_MAX;
                  err = dp_readdir(dirp, &pos, nm, &nml, &ino);
                  if (err != 0) {
!                         syslog(LOG_DEBUG,
                              "%d reading pos %u dir \"%s\"", err, pos, dir);
                          break;
                  }
                  if (nml == 0)
                          break;
*** 1462,1482 ****
  
                  if (pino == ROOT_INODE) {
                          if (rootfs_dot_or_dotdot(nm))
                                  ino = ROOT_INODE;
                  } else if (ino == nlp->nlp_bkdirino && IS_DOTDOT(nm)) {
!                         NDMP_LOG(LOG_DEBUG, "nm(%s): %lu", nm, ino);
                          ino = ROOT_INODE;
                  }
  
                  if (!dbm_getone(nlp->nlp_bkmap, (u_longlong_t)ino))
                          continue;
  
                  err = (*params->mp_file_history_dir_func)(cbp->fh_cookie, nm,
                      ino, pino);
                  if (err < 0) {
!                         NDMP_LOG(LOG_DEBUG, "\"%s/%s\": %d", dir, nm, err);
                          break;
                  }
  
                  /*
                   * This is a requirement by some DMA's (net_vault) that during
--- 1438,1458 ----
  
                  if (pino == ROOT_INODE) {
                          if (rootfs_dot_or_dotdot(nm))
                                  ino = ROOT_INODE;
                  } else if (ino == nlp->nlp_bkdirino && IS_DOTDOT(nm)) {
!                         syslog(LOG_DEBUG, "nm(%s): %lu", nm, ino);
                          ino = ROOT_INODE;
                  }
  
                  if (!dbm_getone(nlp->nlp_bkmap, (u_longlong_t)ino))
                          continue;
  
                  err = (*params->mp_file_history_dir_func)(cbp->fh_cookie, nm,
                      ino, pino);
                  if (err < 0) {
!                         syslog(LOG_ERR, "\"%s/%s\": %d", dir, nm, err);
                          break;
                  }
  
                  /*
                   * This is a requirement by some DMA's (net_vault) that during
*** 1490,1509 ****
                          (void) strlcpy(dirpath, dir, PATH_MAX);
                          (void) strlcat(dirpath, "/", PATH_MAX);
                          (void) strlcat(dirpath, nm, PATH_MAX);
                          err = stat64(dirpath, &ret_attr);
                          if (err != 0) {
!                                 NDMP_LOG(LOG_DEBUG,
!                                     "Error looking up %s", nm);
                                  break;
                          }
  
                          if (S_ISDIR(ret_attr.st_mode)) {
                                  err = (*params->mp_file_history_node_func)(cbp->
                                      fh_cookie, ino, &ret_attr, 0);
                                  if (err < 0) {
!                                         NDMP_LOG(LOG_DEBUG, "\"%s/\": %d",
                                              dir, err);
                                          break;
                                  }
                          }
                  }
--- 1466,1485 ----
                          (void) strlcpy(dirpath, dir, PATH_MAX);
                          (void) strlcat(dirpath, "/", PATH_MAX);
                          (void) strlcat(dirpath, nm, PATH_MAX);
                          err = stat64(dirpath, &ret_attr);
                          if (err != 0) {
!                                 syslog(LOG_ERR,
!                                     "Error looking up %s failed", nm);
                                  break;
                          }
  
                          if (S_ISDIR(ret_attr.st_mode)) {
                                  err = (*params->mp_file_history_node_func)(cbp->
                                      fh_cookie, ino, &ret_attr, 0);
                                  if (err < 0) {
!                                         syslog(LOG_DEBUG, "\"%s/\": %d",
                                              dir, err);
                                          break;
                                  }
                          }
                  }
*** 1529,1578 ****
          ndmp_lbr_params_t *nlp;
          ndmpd_module_params_t *params;
  
          if (!cbp) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "cbp is NULL");
          } else if (!cbp->fh_cookie) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "cookie is NULL");
          } else if (!dir) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "dir is NULL");
          } else if (!file) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "file is NULL");
          } else if (!stp) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "stp is NULL");
          } else if (!(nlp = ndmp_get_nlp(cbp->fh_cookie))) {
                  err = -1;
!                 NDMP_LOG(LOG_DEBUG, "nlp is NULL");
          } else
                  err = 0;
  
          if (err != 0)
                  return (0);
  
-         NDMP_LOG(LOG_DEBUG, "d(%s), f(%s)", dir, file);
- 
          err = 0;
          if (fh_requested(cbp->fh_cookie) == TRUE) {
                  if (stp->st_ino == nlp->nlp_bkdirino) {
                          ino = ROOT_INODE;
-                         NDMP_LOG(LOG_DEBUG,
-                             "bkroot %d -> %d", stp->st_ino, ROOT_INODE);
                  } else {
                          ino = stp->st_ino;
                  }
  
                  params = get_params(cbp->fh_cookie);
                  if (params == NULL || params->mp_file_history_node_func == NULL)
                          err = -1;
                  else if ((err = (*params->mp_file_history_node_func)(cbp->
                      fh_cookie, ino, stp, 0)) < 0)
!                         NDMP_LOG(LOG_DEBUG, "\"%s/\": %d", dir, file, err);
  
          }
  
          return (err);
  }
--- 1505,1550 ----
          ndmp_lbr_params_t *nlp;
          ndmpd_module_params_t *params;
  
          if (!cbp) {
                  err = -1;
!                 syslog(LOG_DEBUG, "cbp is NULL");
          } else if (!cbp->fh_cookie) {
                  err = -1;
!                 syslog(LOG_DEBUG, "cookie is NULL");
          } else if (!dir) {
                  err = -1;
!                 syslog(LOG_DEBUG, "dir is NULL");
          } else if (!file) {
                  err = -1;
!                 syslog(LOG_DEBUG, "file is NULL");
          } else if (!stp) {
                  err = -1;
!                 syslog(LOG_DEBUG, "stp is NULL");
          } else if (!(nlp = ndmp_get_nlp(cbp->fh_cookie))) {
                  err = -1;
!                 syslog(LOG_DEBUG, "nlp is NULL");
          } else
                  err = 0;
  
          if (err != 0)
                  return (0);
  
          err = 0;
          if (fh_requested(cbp->fh_cookie) == TRUE) {
                  if (stp->st_ino == nlp->nlp_bkdirino) {
                          ino = ROOT_INODE;
                  } else {
                          ino = stp->st_ino;
                  }
  
                  params = get_params(cbp->fh_cookie);
                  if (params == NULL || params->mp_file_history_node_func == NULL)
                          err = -1;
                  else if ((err = (*params->mp_file_history_node_func)(cbp->
                      fh_cookie, ino, stp, 0)) < 0)
!                         syslog(LOG_DEBUG, "\"%s/\": %d", dir, file, err);
  
          }
  
          return (err);
  }
*** 1593,1619 ****
          ndmp_lbr_params_t *nlp;
          ndmpd_module_params_t *params;
          int pos =  (int)ll_pos;
  
          if (cbp == NULL) {
!                 NDMP_LOG(LOG_DEBUG, "cbp is NULL");
                  return (-1);
          }
          if (name == NULL) {
!                 NDMP_LOG(LOG_DEBUG, "name is NULL");
                  return (-1);
          }
  
-         NDMP_LOG(LOG_DEBUG, "name: \"%s\", pos: %d",
-             name, pos);
- 
          if ((nlp = ndmp_get_nlp(cbp->fh_cookie)) == NULL) {
!                 NDMP_LOG(LOG_DEBUG, "nlp is NULL");
                  return (-1);
          }
          if (pos < 0 || pos >= nlp->nlp_nfiles) {
!                 NDMP_LOG(LOG_DEBUG, "Invalid pos: %d", pos);
                  return (-1);
          }
          params = get_params(cbp->fh_cookie);
          if (params == NULL || params->mp_file_recovered_func == NULL)
                  return (-1);
--- 1565,1588 ----
          ndmp_lbr_params_t *nlp;
          ndmpd_module_params_t *params;
          int pos =  (int)ll_pos;
  
          if (cbp == NULL) {
!                 syslog(LOG_DEBUG, "cbp is NULL");
                  return (-1);
          }
          if (name == NULL) {
!                 syslog(LOG_DEBUG, "name is NULL");
                  return (-1);
          }
  
          if ((nlp = ndmp_get_nlp(cbp->fh_cookie)) == NULL) {
!                 syslog(LOG_DEBUG, "nlp is NULL");
                  return (-1);
          }
          if (pos < 0 || pos >= nlp->nlp_nfiles) {
!                 syslog(LOG_DEBUG, "Invalid pos: %d", pos);
                  return (-1);
          }
          params = get_params(cbp->fh_cookie);
          if (params == NULL || params->mp_file_recovered_func == NULL)
                  return (-1);