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

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/ndmpd/ndmp/ndmpd_fhistory.c
          +++ new/usr/src/cmd/ndmpd/ndmp/ndmpd_fhistory.c
↓ open down ↓ 29 lines elided ↑ open up ↑
  30   30   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  31   31   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  32   32   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  33   33   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  34   34   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  35   35   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36   36   * POSSIBILITY OF SUCH DAMAGE.
  37   37   */
  38   38  /* Copyright (c) 1996, 1997 PDC, Network Appliance. All Rights Reserved */
  39   39  /* Copyright (c) 2007, The Storage Networking Industry Association. */
       40 +/* Copyright 2017 Nexenta Systems, Inc. All rights reserved. */
  40   41  
  41   42  /*
  42   43   * File history callback functions called by backup modules. NDMP file history
  43   44   * supports 2 file history models: path based and inode/directory based.
  44   45   * Backup/recover modules similar to unix dump/restore utilize the
  45   46   * inode/directory based model. During the filesystem scan pass,
  46   47   * ndmpd_file_history_dir() is called. During the file backup pass,
  47   48   * ndmpd_file_history_node() is called. This model is appropriate for
  48   49   * modules whose code is structured such that file name and file attribute
  49   50   * data is not available at the same time. Backup/recover modules similar
  50   51   * to tar or cpio utilize the path based model. The simple dump/restore module
  51   52   * included with the SDK uses the path based model.
  52   53   */
  53   54  
  54   55  #include <sys/stat.h>
  55   56  #include <sys/types.h>
       57 +#include <syslog.h>
  56   58  #include <dirent.h>
  57   59  #include <errno.h>
  58   60  #include <stdlib.h>
  59   61  #include <string.h>
  60   62  #include "ndmpd.h"
  61   63  #include <dirent.h>
  62   64  #include <bitmap.h>
  63   65  
  64   66  
  65   67  #define N_PATH_ENTRIES  1000
↓ open down ↓ 61 lines elided ↑ open up ↑
 127  129           * for the current entry, send the buffered data to the client.
 128  130           * A NULL name indicates that any buffered data should be sent.
 129  131           */
 130  132          if (name == NULL ||
 131  133              (ndmp_syncfh && session->ns_fh.fh_path_index != 0) ||
 132  134              session->ns_fh.fh_path_index == N_PATH_ENTRIES ||
 133  135              session->ns_fh.fh_path_name_buf_index + strlen(name) + 1 >
 134  136              PATH_NAMEBUF_SIZE) {
 135  137                  ndmp_fh_add_unix_path_request request;
 136  138  
 137      -                NDMP_LOG(LOG_DEBUG,
 138      -                    "sending %ld entries", session->ns_fh.fh_path_index);
 139  139  
 140  140                  request.paths.paths_val = session->ns_fh.fh_path_entries;
 141  141                  request.paths.paths_len = session->ns_fh.fh_path_index;
 142  142  
 143  143                  if (ndmp_send_request_lock(session->ns_connection,
 144  144                      NDMP_FH_ADD_UNIX_PATH, NDMP_NO_ERR, (void *) &request,
 145  145                      0) < 0) {
 146      -                        NDMP_LOG(LOG_DEBUG, "Sending file history data");
      146 +                        syslog(LOG_ERR, "Sending file history data failed");
 147  147                          return (-1);
 148  148                  }
 149  149                  session->ns_fh.fh_path_index = 0;
 150  150                  session->ns_fh.fh_path_name_buf_index = 0;
 151  151          }
 152  152          if (name == NULL)
 153  153                  return (0);
 154  154  
 155  155          if (session->ns_fh.fh_path_entries == 0) {
 156  156                  session->ns_fh.fh_path_entries = ndmp_malloc(N_PATH_ENTRIES *
↓ open down ↓ 62 lines elided ↑ open up ↑
 219  219           * send the buffered data to the client. A NULL name indicates
 220  220           * that any buffered data should be sent.
 221  221           */
 222  222          if (name == NULL ||
 223  223              (ndmp_syncfh && session->ns_fh.fh_dir_index != 0) ||
 224  224              session->ns_fh.fh_dir_index == N_DIR_ENTRIES ||
 225  225              session->ns_fh.fh_dir_name_buf_index + strlen(name) + 1 >
 226  226              DIR_NAMEBUF_SIZE) {
 227  227                  ndmp_fh_add_unix_dir_request request;
 228  228  
 229      -                NDMP_LOG(LOG_DEBUG,
 230      -                    "sending %ld entries", session->ns_fh.fh_dir_index);
 231      -
 232  229                  request.dirs.dirs_val = session->ns_fh.fh_dir_entries;
 233  230                  request.dirs.dirs_len = session->ns_fh.fh_dir_index;
 234  231                  if (ndmp_send_request_lock(session->ns_connection,
 235  232                      NDMP_FH_ADD_UNIX_DIR, NDMP_NO_ERR, (void *) &request,
 236  233                      0) < 0) {
 237      -                        NDMP_LOG(LOG_DEBUG, "Sending file history data");
      234 +                        syslog(LOG_DEBUG, "Sending file history data");
 238  235                          return (-1);
 239  236                  }
 240  237                  session->ns_fh.fh_dir_index = 0;
 241  238                  session->ns_fh.fh_dir_name_buf_index = 0;
 242  239          }
 243  240          if (name == NULL)
 244  241                  return (0);
 245  242  
 246  243          if (session->ns_fh.fh_dir_entries == 0) {
 247  244                  session->ns_fh.fh_dir_entries = ndmp_malloc(N_DIR_ENTRIES
↓ open down ↓ 58 lines elided ↑ open up ↑
 306  303           * If the buffer does not have space
 307  304           * for the current entry, send the buffered data to the client.
 308  305           * A 0 file_stat pointer indicates that any buffered data should
 309  306           * be sent.
 310  307           */
 311  308          if (file_stat == NULL ||
 312  309              (ndmp_syncfh && session->ns_fh.fh_node_index != 0) ||
 313  310              session->ns_fh.fh_node_index == N_NODE_ENTRIES) {
 314  311                  ndmp_fh_add_unix_node_request request;
 315  312  
 316      -                NDMP_LOG(LOG_DEBUG,
 317      -                    "sending %ld entries", session->ns_fh.fh_node_index);
 318      -
 319  313                  request.nodes.nodes_val = session->ns_fh.fh_node_entries;
 320  314                  request.nodes.nodes_len = session->ns_fh.fh_node_index;
 321  315                  /*
 322  316                   * Need to send Dir entry as well. Since Dir entry is more than
 323  317                   * Node entry, we may send a Node entry that hasn't have
 324  318                   * its dir entry sent. Therefore, we need to flush Dir entry
 325  319                   * as well everytime the Dir entry is send.
 326  320                   */
 327  321                  (void) ndmpd_api_file_history_dir_v2(session, 0, 0, 0);
 328  322  
 329  323                  if (ndmp_send_request_lock(session->ns_connection,
 330  324                      NDMP_FH_ADD_UNIX_NODE, NDMP_NO_ERR, (void *) &request,
 331  325                      0) < 0) {
 332      -                        NDMP_LOG(LOG_DEBUG, "Sending file history data");
      326 +                        syslog(LOG_ERR, "Sending file history data failed");
 333  327                          return (-1);
 334  328                  }
 335  329                  session->ns_fh.fh_node_index = 0;
 336  330          }
 337  331          if (file_stat == NULL)
 338  332                  return (0);
 339  333  
 340  334          if (session->ns_fh.fh_node_entries == 0) {
 341  335                  session->ns_fh.fh_node_entries = ndmp_malloc(N_NODE_ENTRIES
 342  336                      * sizeof (ndmp_fh_unix_node));
↓ open down ↓ 59 lines elided ↑ open up ↑
 402  396          /*
 403  397           * If the buffer does not have space
 404  398           * for the current entry, send the buffered data to the client.
 405  399           * A NULL name indicates that any buffered data should be sent.
 406  400           */
 407  401          if (name == NULL ||
 408  402              session->ns_fh_v3.fh_file_index == N_FILE_ENTRIES ||
 409  403              session->ns_fh_v3.fh_file_name_buf_index + strlen(name) + 1 >
 410  404              PATH_NAMEBUF_SIZE) {
 411  405  
 412      -                NDMP_LOG(LOG_DEBUG, "sending %ld entries",
 413      -                    session->ns_fh_v3.fh_file_index);
 414      -
 415  406                  request.files.files_len = session->ns_fh_v3.fh_file_index;
 416  407                  request.files.files_val = session->ns_fh_v3.fh_files;
 417  408  
 418  409                  if (ndmp_send_request_lock(session->ns_connection,
 419  410                      NDMP_FH_ADD_FILE, NDMP_NO_ERR, (void *) &request, 0) < 0) {
 420      -                        NDMP_LOG(LOG_DEBUG,
 421      -                            "Sending ndmp_fh_add_file request");
      411 +                        syslog(LOG_ERR,
      412 +                            "Sending ndmp_fh_add_file request failed");
 422  413                          return (-1);
 423  414                  }
 424  415  
 425  416                  session->ns_fh_v3.fh_file_index = 0;
 426  417                  session->ns_fh_v3.fh_file_name_buf_index = 0;
 427  418          }
 428  419  
 429  420          if (name == NULL)
 430  421                  return (0);
 431  422  
↓ open down ↓ 100 lines elided ↑ open up ↑
 532  523          /*
 533  524           * If the buffer does not have space
 534  525           * for the current entry, send the buffered data to the client.
 535  526           * A NULL name indicates that any buffered data should be sent.
 536  527           */
 537  528          if (name == NULL ||
 538  529              session->ns_fh_v3.fh_dir_index == N_DIR_ENTRIES ||
 539  530              session->ns_fh_v3.fh_dir_name_buf_index + strlen(name) + 1 >
 540  531              DIR_NAMEBUF_SIZE) {
 541  532  
 542      -                NDMP_LOG(LOG_DEBUG, "sending %ld entries",
 543      -                    session->ns_fh_v3.fh_dir_index);
 544      -
 545  533                  request.dirs.dirs_val = session->ns_fh_v3.fh_dirs;
 546  534                  request.dirs.dirs_len = session->ns_fh_v3.fh_dir_index;
 547  535  
 548  536                  if (ndmp_send_request_lock(session->ns_connection,
 549  537                      NDMP_FH_ADD_DIR, NDMP_NO_ERR, (void *) &request, 0) < 0) {
 550      -                        NDMP_LOG(LOG_DEBUG,
 551      -                            "Sending ndmp_fh_add_dir request");
      538 +                        syslog(LOG_ERR,
      539 +                            "Sending ndmp_fh_add_dir request failed");
 552  540                          return (-1);
 553  541                  }
 554  542  
 555  543                  session->ns_fh_v3.fh_dir_index = 0;
 556  544                  session->ns_fh_v3.fh_dir_name_buf_index = 0;
 557  545          }
 558  546  
 559  547          if (name == NULL)
 560  548                  return (0);
 561  549  
↓ open down ↓ 76 lines elided ↑ open up ↑
 638  626                  return (0);
 639  627  
 640  628          /*
 641  629           * If the buffer does not have space
 642  630           * for the current entry, send the buffered data to the client.
 643  631           * A 0 file_stat pointer indicates that any buffered data should
 644  632           * be sent.
 645  633           */
 646  634          if (file_stat == NULL ||
 647  635              session->ns_fh_v3.fh_node_index == N_NODE_ENTRIES) {
 648      -                NDMP_LOG(LOG_DEBUG, "sending %ld entries",
 649      -                    session->ns_fh_v3.fh_node_index);
 650  636  
 651  637                  /*
 652  638                   * Need to send Dir entry as well. Since Dir entry is more
 653  639                   * than a Node entry, we may send a Node entry that hasn't
 654  640                   * had its Dir entry sent. Therefore, we need to flush Dir
 655  641                   * entry as well every time the Dir entry is sent.
 656  642                   */
 657  643                  (void) ndmpd_api_file_history_dir_v3(session, 0, 0, 0);
 658  644  
 659  645                  request.nodes.nodes_len = session->ns_fh_v3.fh_node_index;
 660  646                  request.nodes.nodes_val = session->ns_fh_v3.fh_nodes;
 661  647  
 662  648                  if (ndmp_send_request_lock(session->ns_connection,
 663  649                      NDMP_FH_ADD_NODE,
 664  650                      NDMP_NO_ERR, (void *) &request, 0) < 0) {
 665      -                        NDMP_LOG(LOG_DEBUG,
 666      -                            "Sending ndmp_fh_add_node request");
      651 +                        syslog(LOG_ERR,
      652 +                            "Sending ndmp_fh_add_node request failed");
 667  653                          return (-1);
 668  654                  }
 669  655  
 670  656                  session->ns_fh_v3.fh_node_index = 0;
 671  657          }
 672  658  
 673  659          if (file_stat == NULL)
 674  660                  return (0);
 675  661  
 676  662          if (session->ns_fh_v3.fh_nodes == 0) {
↓ open down ↓ 55 lines elided ↑ open up ↑
 732  718  int
 733  719  ndmpd_fhpath_v3_cb(lbr_fhlog_call_backs_t *cbp, char *path, struct stat64 *stp,
 734  720      u_longlong_t off)
 735  721  {
 736  722          int err;
 737  723          ndmp_lbr_params_t *nlp;
 738  724          ndmpd_module_params_t *params;
 739  725  
 740  726          if (!cbp) {
 741  727                  err = -1;
 742      -                NDMP_LOG(LOG_DEBUG, "cbp is NULL");
      728 +                syslog(LOG_DEBUG, "cbp is NULL");
 743  729          } else if (!cbp->fh_cookie) {
 744  730                  err = -1;
 745      -                NDMP_LOG(LOG_DEBUG, "cookie is NULL");
      731 +                syslog(LOG_DEBUG, "cookie is NULL");
 746  732          } else if (!path) {
 747  733                  err = -1;
 748      -                NDMP_LOG(LOG_DEBUG, "path is NULL");
      734 +                syslog(LOG_DEBUG, "path is NULL");
 749  735          } else if (!(nlp = ndmp_get_nlp(cbp->fh_cookie))) {
 750  736                  err = -1;
 751      -                NDMP_LOG(LOG_DEBUG, "nlp is NULL");
      737 +                syslog(LOG_DEBUG, "nlp is NULL");
 752  738          } else
 753  739                  err = 0;
 754  740  
 755  741          if (err != 0)
 756  742                  return (0);
 757  743  
 758      -        NDMP_LOG(LOG_DEBUG, "pname(%s)", path);
 759      -
 760  744          err = 0;
 761  745          if (NLP_ISSET(nlp, NLPF_FH)) {
 762  746                  if (!NLP_ISSET(nlp, NLPF_DIRECT)) {
 763      -                        NDMP_LOG(LOG_DEBUG, "DAR NOT SET!");
      747 +                        syslog(LOG_DEBUG, "DAR NOT SET!");
 764  748                          off = 0LL;
 765  749                  }
 766  750  
 767  751                  params = get_params(cbp->fh_cookie);
 768  752                  if (!params || !params->mp_file_history_path_func) {
 769  753                          err = -1;
 770  754                  } else {
 771  755                          char *p =
 772  756                              ndmp_get_relative_path(get_backup_path_v3(params),
 773  757                              path);
 774  758                          if ((err = ndmpd_api_file_history_file_v3(cbp->
 775  759                              fh_cookie, p, stp, off)) < 0)
 776      -                                NDMP_LOG(LOG_DEBUG, "\"%s\" %d", path, err);
      760 +                                syslog(LOG_DEBUG, "\"%s\" %d", path, err);
 777  761                  }
 778  762          }
 779  763  
 780  764          return (err);
 781  765  }
 782  766  
 783  767  
 784  768  /*
 785  769   * ndmpd_fhdir_v3_cb
 786  770   *
↓ open down ↓ 7 lines elided ↑ open up ↑
 794  778          int err;
 795  779          ulong_t ino, pino;
 796  780          ulong_t pos;
 797  781          ndmp_lbr_params_t *nlp;
 798  782          ndmpd_module_params_t *params;
 799  783          DIR *dirp;
 800  784          char dirpath[PATH_MAX];
 801  785  
 802  786          if (!cbp) {
 803  787                  err = -1;
 804      -                NDMP_LOG(LOG_DEBUG, "cbp is NULL");
      788 +                syslog(LOG_DEBUG, "cbp is NULL");
 805  789          } else if (!cbp->fh_cookie) {
 806  790                  err = -1;
 807      -                NDMP_LOG(LOG_DEBUG, "cookie is NULL");
      791 +                syslog(LOG_DEBUG, "cookie is NULL");
 808  792          } else if (!dir) {
 809  793                  err = -1;
 810      -                NDMP_LOG(LOG_DEBUG, "dir is NULL");
      794 +                syslog(LOG_DEBUG, "dir is NULL");
 811  795          } else if (!(nlp = ndmp_get_nlp(cbp->fh_cookie))) {
 812  796                  err = -1;
 813      -                NDMP_LOG(LOG_DEBUG, "nlp is NULL");
      797 +                syslog(LOG_DEBUG, "nlp is NULL");
 814  798          } else
 815  799                  err = 0;
 816  800  
 817  801          if (err != 0)
 818  802                  return (0);
 819  803  
 820      -        NDMP_LOG(LOG_DEBUG, "d(%s)", dir);
 821      -
 822  804          if (!NLP_ISSET(nlp, NLPF_FH))
 823  805                  return (0);
 824  806  
 825  807          /*
 826  808           * Veritas net_backup accepts only 2 as the inode number of the backup
 827  809           * root directory.  The other way compares the path against the
 828  810           * backup path which is slower.
 829  811           */
 830  812          if (stp->st_ino == nlp->nlp_bkdirino)
 831  813                  pino = ROOT_INODE;
↓ open down ↓ 1 lines elided ↑ open up ↑
 833  815                  pino = stp->st_ino;
 834  816  
 835  817          /*
 836  818           * There is nothing below this directory to be backed up.
 837  819           * If there was, the bit for this directory would have
 838  820           * been set.  Backup root directory is exception.  We
 839  821           * always send the dir file history records of it.
 840  822           */
 841  823          if (pino != ROOT_INODE &&
 842  824              !dbm_getone(nlp->nlp_bkmap, (u_longlong_t)stp->st_ino)) {
 843      -                NDMP_LOG(LOG_DEBUG, "nothing below here");
      825 +                syslog(LOG_DEBUG, "nothing below here");
 844  826                  return (0);
 845  827          }
 846  828  
 847  829          params = nlp->nlp_params;
 848  830          if (!params || !params->mp_file_history_dir_func)
 849  831                  return (-1);
 850  832  
 851  833          pos = 0;
 852  834          err = 0;
 853  835  
 854  836          dirp = opendir(dir);
 855  837          if (dirp == NULL)
 856  838                  return (0);
 857  839  
 858  840          do {
 859  841                  nml = PATH_MAX;
 860  842                  err = dp_readdir(dirp, &pos, nm, &nml, &ino);
 861  843                  if (err != 0) {
 862      -                        NDMP_LOG(LOG_DEBUG,
      844 +                        syslog(LOG_DEBUG,
 863  845                              "%d reading pos %u dir \"%s\"", err, pos, dir);
 864  846                          break;
 865  847                  }
 866  848                  if (nml == 0)
 867  849                          break;
 868  850                  nm[nml] = '\0';
 869  851  
 870  852                  if (pino == ROOT_INODE) {
 871  853                          if (rootfs_dot_or_dotdot(nm))
 872  854                                  ino = ROOT_INODE;
 873  855                  } else if (ino == nlp->nlp_bkdirino && IS_DOTDOT(nm)) {
 874      -                        NDMP_LOG(LOG_DEBUG, "nm(%s): %lu", nm, ino);
 875  856                          ino = ROOT_INODE;
 876  857                  }
 877  858  
 878  859                  if (!dbm_getone(nlp->nlp_bkmap, (u_longlong_t)ino))
 879  860                          continue;
 880  861  
 881  862                  /*
 882  863                   * If the entry is on exclusion list dont send the info
 883  864                   */
 884  865                  if (tlm_is_excluded(dir, nm, ndmp_excl_list)) {
 885      -                        NDMP_LOG(LOG_DEBUG,
 886      -                            "name \"%s\" skipped", nm == 0 ? "nil" : nm);
      866 +                        syslog(LOG_DEBUG,
      867 +                            "name \"%s\" skipped", *nm == '\0' ? "nil" : nm);
 887  868                          continue;
 888  869                  }
 889  870  
 890  871                  err = (*params->mp_file_history_dir_func)(cbp->fh_cookie, nm,
 891  872                      ino, pino);
 892  873                  if (err < 0) {
 893      -                        NDMP_LOG(LOG_DEBUG, "\"%s\": %d", dir, err);
      874 +                        syslog(LOG_ERR, "\"%s\": %d", dir, err);
 894  875                          break;
 895  876                  }
 896  877  
 897  878                  /*
 898  879                   * This is a requirement by some DMA's (net_vault) that during
 899  880                   * the incremental backup, the node info should also be sent
 900  881                   * along with the dir info for all directories leading to a
 901  882                   * backed up file.
 902  883                   */
 903  884                  if (ndmp_fhinode) {
 904  885                          struct stat64 ret_attr;
 905  886  
 906  887                          (void) strlcpy(dirpath, dir, PATH_MAX);
 907  888                          (void) strlcat(dirpath, "/", PATH_MAX);
 908  889                          (void) strlcat(dirpath, nm, PATH_MAX);
 909  890                          err = stat64(dirpath, &ret_attr);
 910  891                          if (err != 0) {
 911      -                                NDMP_LOG(LOG_DEBUG,
      892 +                                syslog(LOG_ERR,
 912  893                                      "Error looking up %s", nm);
 913  894                                  break;
 914  895                          }
 915  896  
 916  897                          if (S_ISDIR(ret_attr.st_mode)) {
 917  898                                  err = (*params->mp_file_history_node_func)(cbp->
 918  899                                      fh_cookie, ino, &ret_attr, 0);
 919  900                                  if (err < 0) {
 920      -                                        NDMP_LOG(LOG_DEBUG, "\"%s/\": %d",
      901 +                                        syslog(LOG_ERR, "\"%s/\": %d",
 921  902                                              dir, err);
 922  903                                          break;
 923  904                                  }
 924  905                          }
 925  906                  }
 926  907          } while (err == 0);
 927  908  
 928  909          (void) closedir(dirp);
 929  910          return (err);
 930  911  }
↓ open down ↓ 8 lines elided ↑ open up ↑
 939  920  ndmpd_fhnode_v3_cb(lbr_fhlog_call_backs_t *cbp, char *dir, char *file,
 940  921      struct stat64 *stp, u_longlong_t off)
 941  922  {
 942  923          int err;
 943  924          ulong_t ino;
 944  925          ndmp_lbr_params_t *nlp;
 945  926          ndmpd_module_params_t *params;
 946  927  
 947  928          if (!cbp) {
 948  929                  err = -1;
 949      -                NDMP_LOG(LOG_DEBUG, "cbp is NULL");
      930 +                syslog(LOG_DEBUG, "cbp is NULL");
 950  931          } else if (!cbp->fh_cookie) {
 951  932                  err = -1;
 952      -                NDMP_LOG(LOG_DEBUG, "cookie is NULL");
      933 +                syslog(LOG_DEBUG, "cookie is NULL");
 953  934          } else if (!dir) {
 954  935                  err = -1;
 955      -                NDMP_LOG(LOG_DEBUG, "dir is NULL");
      936 +                syslog(LOG_DEBUG, "dir is NULL");
 956  937          } else if (!file) {
 957  938                  err = -1;
 958      -                NDMP_LOG(LOG_DEBUG, "file is NULL");
      939 +                syslog(LOG_DEBUG, "file is NULL");
 959  940          } else if (!stp) {
 960  941                  err = -1;
 961      -                NDMP_LOG(LOG_DEBUG, "stp is NULL");
      942 +                syslog(LOG_DEBUG, "stp is NULL");
 962  943          } else if (!(nlp = ndmp_get_nlp(cbp->fh_cookie))) {
 963  944                  err = -1;
 964      -                NDMP_LOG(LOG_DEBUG, "nlp is NULL");
      945 +                syslog(LOG_DEBUG, "nlp is NULL");
 965  946          } else {
 966  947                  err = 0;
 967  948          }
 968  949  
 969  950          if (err != 0)
 970  951                  return (0);
 971  952  
 972      -        NDMP_LOG(LOG_DEBUG, "d(%s), f(%s)", dir, file);
 973  953  
 974  954          err = 0;
 975  955          if (NLP_ISSET(nlp, NLPF_FH)) {
 976  956                  if (!NLP_ISSET(nlp, NLPF_DIRECT))
 977  957                          off = 0LL;
 978  958                  if (stp->st_ino == nlp->nlp_bkdirino) {
 979  959                          ino = ROOT_INODE;
 980      -                        NDMP_LOG(LOG_DEBUG,
 981      -                            "bkroot %d -> %d", stp->st_ino, ROOT_INODE);
 982  960                  } else
 983  961                          ino = stp->st_ino;
 984  962  
 985  963                  params = nlp->nlp_params;
 986  964                  if (!params || !params->mp_file_history_node_func)
 987  965                          err = -1;
 988  966                  else if ((err = (*params->mp_file_history_node_func)(cbp->
 989  967                      fh_cookie, ino, stp, off)) < 0)
 990      -                        NDMP_LOG(LOG_DEBUG, "\"%s/%s\" %d", dir, file, err);
      968 +                        syslog(LOG_ERR, "\"%s/%s\" %d", dir, file, err);
 991  969          }
 992  970  
 993  971          return (err);
 994  972  }
 995  973  
 996  974  
 997  975  /*
 998  976   * ndmp_send_recovery_stat_v3
 999  977   *
1000  978   * Send the recovery status to the DMA
1001  979   */
1002  980  int
1003  981  ndmp_send_recovery_stat_v3(ndmpd_module_params_t *params,
1004  982      ndmp_lbr_params_t *nlp, int idx, int stat)
1005  983  {
1006  984          int rv;
1007  985          mem_ndmp_name_v3_t *ep;
1008  986  
1009  987          rv = -1;
1010  988          if (!params) {
1011      -                NDMP_LOG(LOG_DEBUG, "params == NULL");
      989 +                syslog(LOG_DEBUG, "params == NULL");
1012  990          } else if (!params->mp_file_recovered_func) {
1013      -                NDMP_LOG(LOG_DEBUG, "paramsfile_recovered_func == NULL");
      991 +                syslog(LOG_DEBUG, "paramsfile_recovered_func == NULL");
1014  992          } else if (!nlp) {
1015      -                NDMP_LOG(LOG_DEBUG, "nlp == NULL");
      993 +                syslog(LOG_DEBUG, "nlp == NULL");
1016  994          } else if (idx < 0) {
1017      -                NDMP_LOG(LOG_DEBUG, "idx(%d) < 0", idx);
      995 +                syslog(LOG_DEBUG, "idx(%d) < 0", idx);
1018  996          } else if (!(ep = (mem_ndmp_name_v3_t *)MOD_GETNAME(params, idx))) {
1019      -                NDMP_LOG(LOG_DEBUG, "nlist[%d] == NULL", idx);
      997 +                syslog(LOG_DEBUG, "nlist[%d] == NULL", idx);
1020  998          } else if (!ep->nm3_opath) {
1021      -                NDMP_LOG(LOG_DEBUG, "nlist[%d].nm3_opath == NULL", idx);
      999 +                syslog(LOG_DEBUG, "nlist[%d].nm3_opath == NULL", idx);
1022 1000          } else {
1023      -                NDMP_LOG(LOG_DEBUG,
     1001 +                syslog(LOG_DEBUG,
1024 1002                      "ep[%d].nm3_opath \"%s\"", idx, ep->nm3_opath);
1025 1003                  rv = MOD_FILERECOVERD(params, ep->nm3_opath, stat);
1026 1004          }
1027 1005  
1028 1006          return (rv);
1029 1007  }
1030 1008  
1031 1009  
1032 1010  /*
1033 1011   * ndmpd_path_restored_v3
↓ open down ↓ 5 lines elided ↑ open up ↑
1039 1017  int
1040 1018  ndmpd_path_restored_v3(lbr_fhlog_call_backs_t *cbp, char *name,
1041 1019      struct stat64 *st, u_longlong_t ll_idx)
1042 1020  {
1043 1021          int rv;
1044 1022          ndmp_lbr_params_t *nlp;
1045 1023          ndmpd_module_params_t *params;
1046 1024          int idx = (int)ll_idx;
1047 1025  
1048 1026          if (!cbp) {
1049      -                NDMP_LOG(LOG_DEBUG, "cbp is NULL");
     1027 +                syslog(LOG_DEBUG, "cbp is NULL");
1050 1028                  return (-1);
1051 1029          }
1052 1030          if (!name) {
1053      -                NDMP_LOG(LOG_DEBUG, "name is NULL");
     1031 +                syslog(LOG_DEBUG, "name is NULL");
1054 1032                  return (-1);
1055 1033          }
1056 1034  
1057      -        NDMP_LOG(LOG_DEBUG, "name: \"%s\", idx: %d", name, idx);
1058      -
1059 1035          nlp = ndmp_get_nlp(cbp->fh_cookie);
1060 1036          if (!nlp) {
1061      -                NDMP_LOG(LOG_DEBUG, "nlp is NULL");
     1037 +                syslog(LOG_DEBUG, "nlp is NULL");
1062 1038                  return (-1);
1063 1039          }
1064 1040          if (idx < 0 || idx >= nlp->nlp_nfiles) {
1065      -                NDMP_LOG(LOG_DEBUG, "Invalid idx: %d", idx);
     1041 +                syslog(LOG_DEBUG, "Invalid idx: %d", idx);
1066 1042                  return (-1);
1067 1043          }
1068 1044          params = nlp->nlp_params;
1069 1045          if (!params || !params->mp_file_recovered_func)
1070 1046                  return (-1);
1071 1047  
1072 1048          if (nlp->nlp_lastidx == -1)
1073 1049                  nlp->nlp_lastidx = idx;
1074 1050  
1075 1051          rv = 0;
↓ open down ↓ 191 lines elided ↑ open up ↑
1267 1243          switch (session->ns_protocol_version) {
1268 1244          case 1:
1269 1245          case 2:
1270 1246                  ndmpd_file_history_cleanup_v2(session, send_flag);
1271 1247                  break;
1272 1248          case 3:
1273 1249          case 4:
1274 1250                  ndmpd_file_history_cleanup_v3(session, send_flag);
1275 1251                  break;
1276 1252          default:
1277      -                NDMP_LOG(LOG_DEBUG, "Unknown version %d",
     1253 +                syslog(LOG_ERR, "Unknown version %d",
1278 1254                      session->ns_protocol_version);
1279 1255          }
1280 1256  }
1281 1257  
1282 1258  /*
1283 1259   * get_params
1284 1260   *
1285 1261   * Callbacks from LBR.
1286 1262   */
1287 1263  static ndmpd_module_params_t *
↓ open down ↓ 12 lines elided ↑ open up ↑
1300 1276   * fh_requested
1301 1277   *
1302 1278   * Check in LB parameters if file history is requested
1303 1279   */
1304 1280  static boolean_t
1305 1281  fh_requested(void *cookie)
1306 1282  {
1307 1283          ndmp_lbr_params_t *nlp;
1308 1284  
1309 1285          if ((nlp = ndmp_get_nlp(cookie)) == NULL) {
1310      -                NDMP_LOG(LOG_DEBUG, "nlp is NULL");
     1286 +                syslog(LOG_DEBUG, "nlp is NULL");
1311 1287                  return (FALSE);
1312 1288          }
1313 1289  
1314      -        NDMP_LOG(LOG_DEBUG, "nlp_fh %c", NDMP_YORN(NLP_ISSET(nlp, NLPF_FH)));
     1290 +        syslog(LOG_DEBUG, "nlp_fh %c", NDMP_YORN(NLP_ISSET(nlp, NLPF_FH)));
1315 1291  
1316 1292          return (NLP_ISSET(nlp, NLPF_FH));
1317 1293  }
1318 1294  
1319 1295  
1320 1296  /*
1321 1297   * ndmpd_file_history_path
1322 1298   *
1323 1299   * Generates file history path information posts
1324 1300   *
↓ open down ↓ 5 lines elided ↑ open up ↑
1330 1306  /*ARGSUSED*/
1331 1307  int
1332 1308  ndmpd_file_history_path(lbr_fhlog_call_backs_t *cbp, char *path,
1333 1309      struct stat64 *stp, u_longlong_t off)
1334 1310  {
1335 1311          int err;
1336 1312          ndmpd_module_params_t *params;
1337 1313  
1338 1314          if (!cbp) {
1339 1315                  err = -1;
1340      -                NDMP_LOG(LOG_DEBUG, "cbp is NULL");
     1316 +                syslog(LOG_DEBUG, "cbp is NULL");
1341 1317          } else if (!cbp->fh_cookie) {
1342 1318                  err = -1;
1343      -                NDMP_LOG(LOG_DEBUG, "cookie is NULL");
     1319 +                syslog(LOG_DEBUG, "cookie is NULL");
1344 1320          } else if (!path) {
1345 1321                  err = -1;
1346      -                NDMP_LOG(LOG_DEBUG, "path is NULL");
     1322 +                syslog(LOG_DEBUG, "path is NULL");
1347 1323          } else if (!stp) {
1348 1324                  err = -1;
1349      -                NDMP_LOG(LOG_DEBUG, "stp is NULL");
     1325 +                syslog(LOG_DEBUG, "stp is NULL");
1350 1326          } else
1351 1327                  err = 0;
1352 1328  
1353 1329          if (err != 0)
1354 1330                  return (0);
1355 1331  
1356      -        NDMP_LOG(LOG_DEBUG, "path: \"%s\"", path);
     1332 +        syslog(LOG_DEBUG, "path: \"%s\"", path);
1357 1333  
1358 1334          err = 0;
1359 1335          if (fh_requested(cbp->fh_cookie)) {
1360 1336                  params = get_params(cbp->fh_cookie);
1361 1337                  if (params == NULL || params->mp_file_history_path_func == NULL)
1362 1338                          err = -1;
1363 1339                  else if ((err = (*params->mp_file_history_path_func)(cbp->
1364 1340                      fh_cookie, path, stp, 0)) < 0)
1365      -                        NDMP_LOG(LOG_DEBUG, "\"%s\": %d", path, err);
     1341 +                        syslog(LOG_DEBUG, "\"%s\": %d", path, err);
1366 1342          }
1367 1343  
1368 1344          return (err);
1369 1345  }
1370 1346  
1371 1347  
1372 1348  /*
1373 1349   * ndmpd_file_history_dir
1374 1350   *
1375 1351   * Generate file history directory information posts
↓ open down ↓ 7 lines elided ↑ open up ↑
1383 1359          int err;
1384 1360          ulong_t ino, pino;
1385 1361          ulong_t pos;
1386 1362          ndmp_lbr_params_t *nlp;
1387 1363          ndmpd_module_params_t *params;
1388 1364          DIR *dirp;
1389 1365          char dirpath[PATH_MAX];
1390 1366  
1391 1367          if (!cbp) {
1392 1368                  err = -1;
1393      -                NDMP_LOG(LOG_DEBUG, "cbp is NULL");
     1369 +                syslog(LOG_DEBUG, "cbp is NULL");
1394 1370          } else if (!cbp->fh_cookie) {
1395 1371                  err = -1;
1396      -                NDMP_LOG(LOG_DEBUG, "cookie is NULL");
     1372 +                syslog(LOG_DEBUG, "cookie is NULL");
1397 1373          } else if (!dir) {
1398 1374                  err = -1;
1399      -                NDMP_LOG(LOG_DEBUG, "dir is NULL");
     1375 +                syslog(LOG_DEBUG, "dir is NULL");
1400 1376          } else if (!stp) {
1401 1377                  err = -1;
1402      -                NDMP_LOG(LOG_DEBUG, "stp is NULL");
     1378 +                syslog(LOG_DEBUG, "stp is NULL");
1403 1379          } if (!(nlp = ndmp_get_nlp(cbp->fh_cookie))) {
1404 1380                  err = -1;
1405      -                NDMP_LOG(LOG_DEBUG, "nlp is NULL");
     1381 +                syslog(LOG_DEBUG, "nlp is NULL");
1406 1382          } else
1407 1383                  err = 0;
1408 1384  
1409 1385          if (err != 0)
1410 1386                  return (0);
1411 1387  
1412      -        NDMP_LOG(LOG_DEBUG, "dir: \"%s\"", dir);
     1388 +        syslog(LOG_DEBUG, "dir: \"%s\"", dir);
1413 1389  
1414 1390          if (!fh_requested(cbp->fh_cookie))
1415 1391                  return (0);
1416 1392  
1417 1393          /*
1418 1394           * Veritas net_backup accepts only 2 as the inode number of the backup
1419 1395           * root directory.  The other way compares the path against the
1420 1396           * backup path which is slower.
1421 1397           */
1422 1398          if (stp->st_ino == nlp->nlp_bkdirino)
↓ open down ↓ 2 lines elided ↑ open up ↑
1425 1401                  pino = stp->st_ino;
1426 1402  
1427 1403          /*
1428 1404           * There is nothing below this directory to be backed up.
1429 1405           * If there was, the bit for this directory would have
1430 1406           * been set.  Backup root directory is exception.  We
1431 1407           * always send the dir file history records of it.
1432 1408           */
1433 1409          if (pino != ROOT_INODE &&
1434 1410              !dbm_getone(nlp->nlp_bkmap, (u_longlong_t)stp->st_ino)) {
1435      -                NDMP_LOG(LOG_DEBUG, "nothing below here");
     1411 +                syslog(LOG_DEBUG, "nothing below here");
1436 1412                  return (0);
1437 1413          }
1438 1414  
1439 1415          params = get_params(cbp->fh_cookie);
1440 1416          if (params == NULL || params->mp_file_history_dir_func == NULL) {
1441 1417                  return (0);
1442 1418          }
1443 1419  
1444 1420          pos = 0;
1445 1421          err = 0;
1446 1422  
1447 1423          dirp = opendir(dir);
1448 1424          if (dirp == NULL)
1449 1425                  return (0);
1450 1426  
1451 1427          do {
1452 1428                  nml = PATH_MAX;
1453 1429                  err = dp_readdir(dirp, &pos, nm, &nml, &ino);
1454 1430                  if (err != 0) {
1455      -                        NDMP_LOG(LOG_DEBUG,
     1431 +                        syslog(LOG_DEBUG,
1456 1432                              "%d reading pos %u dir \"%s\"", err, pos, dir);
1457 1433                          break;
1458 1434                  }
1459 1435                  if (nml == 0)
1460 1436                          break;
1461 1437                  nm[nml] = '\0';
1462 1438  
1463 1439                  if (pino == ROOT_INODE) {
1464 1440                          if (rootfs_dot_or_dotdot(nm))
1465 1441                                  ino = ROOT_INODE;
1466 1442                  } else if (ino == nlp->nlp_bkdirino && IS_DOTDOT(nm)) {
1467      -                        NDMP_LOG(LOG_DEBUG, "nm(%s): %lu", nm, ino);
     1443 +                        syslog(LOG_DEBUG, "nm(%s): %lu", nm, ino);
1468 1444                          ino = ROOT_INODE;
1469 1445                  }
1470 1446  
1471 1447                  if (!dbm_getone(nlp->nlp_bkmap, (u_longlong_t)ino))
1472 1448                          continue;
1473 1449  
1474 1450                  err = (*params->mp_file_history_dir_func)(cbp->fh_cookie, nm,
1475 1451                      ino, pino);
1476 1452                  if (err < 0) {
1477      -                        NDMP_LOG(LOG_DEBUG, "\"%s/%s\": %d", dir, nm, err);
     1453 +                        syslog(LOG_ERR, "\"%s/%s\": %d", dir, nm, err);
1478 1454                          break;
1479 1455                  }
1480 1456  
1481 1457                  /*
1482 1458                   * This is a requirement by some DMA's (net_vault) that during
1483 1459                   * the incremental backup, the node info should also be sent
1484 1460                   * along with the dir info for all directories leading to a
1485 1461                   * backed up file.
1486 1462                   */
1487 1463                  if (ndmp_fhinode) {
1488 1464                          struct stat64 ret_attr;
1489 1465  
1490 1466                          (void) strlcpy(dirpath, dir, PATH_MAX);
1491 1467                          (void) strlcat(dirpath, "/", PATH_MAX);
1492 1468                          (void) strlcat(dirpath, nm, PATH_MAX);
1493 1469                          err = stat64(dirpath, &ret_attr);
1494 1470                          if (err != 0) {
1495      -                                NDMP_LOG(LOG_DEBUG,
1496      -                                    "Error looking up %s", nm);
     1471 +                                syslog(LOG_ERR,
     1472 +                                    "Error looking up %s failed", nm);
1497 1473                                  break;
1498 1474                          }
1499 1475  
1500 1476                          if (S_ISDIR(ret_attr.st_mode)) {
1501 1477                                  err = (*params->mp_file_history_node_func)(cbp->
1502 1478                                      fh_cookie, ino, &ret_attr, 0);
1503 1479                                  if (err < 0) {
1504      -                                        NDMP_LOG(LOG_DEBUG, "\"%s/\": %d",
     1480 +                                        syslog(LOG_DEBUG, "\"%s/\": %d",
1505 1481                                              dir, err);
1506 1482                                          break;
1507 1483                                  }
1508 1484                          }
1509 1485                  }
1510 1486          } while (err == 0);
1511 1487  
1512 1488          (void) closedir(dirp);
1513 1489          return (err);
1514 1490  }
↓ open down ↓ 9 lines elided ↑ open up ↑
1524 1500  ndmpd_file_history_node(lbr_fhlog_call_backs_t *cbp, char *dir, char *file,
1525 1501      struct stat64 *stp, u_longlong_t off)
1526 1502  {
1527 1503          int err;
1528 1504          ulong_t ino;
1529 1505          ndmp_lbr_params_t *nlp;
1530 1506          ndmpd_module_params_t *params;
1531 1507  
1532 1508          if (!cbp) {
1533 1509                  err = -1;
1534      -                NDMP_LOG(LOG_DEBUG, "cbp is NULL");
     1510 +                syslog(LOG_DEBUG, "cbp is NULL");
1535 1511          } else if (!cbp->fh_cookie) {
1536 1512                  err = -1;
1537      -                NDMP_LOG(LOG_DEBUG, "cookie is NULL");
     1513 +                syslog(LOG_DEBUG, "cookie is NULL");
1538 1514          } else if (!dir) {
1539 1515                  err = -1;
1540      -                NDMP_LOG(LOG_DEBUG, "dir is NULL");
     1516 +                syslog(LOG_DEBUG, "dir is NULL");
1541 1517          } else if (!file) {
1542 1518                  err = -1;
1543      -                NDMP_LOG(LOG_DEBUG, "file is NULL");
     1519 +                syslog(LOG_DEBUG, "file is NULL");
1544 1520          } else if (!stp) {
1545 1521                  err = -1;
1546      -                NDMP_LOG(LOG_DEBUG, "stp is NULL");
     1522 +                syslog(LOG_DEBUG, "stp is NULL");
1547 1523          } else if (!(nlp = ndmp_get_nlp(cbp->fh_cookie))) {
1548 1524                  err = -1;
1549      -                NDMP_LOG(LOG_DEBUG, "nlp is NULL");
     1525 +                syslog(LOG_DEBUG, "nlp is NULL");
1550 1526          } else
1551 1527                  err = 0;
1552 1528  
1553 1529          if (err != 0)
1554 1530                  return (0);
1555 1531  
1556      -        NDMP_LOG(LOG_DEBUG, "d(%s), f(%s)", dir, file);
1557      -
1558 1532          err = 0;
1559 1533          if (fh_requested(cbp->fh_cookie) == TRUE) {
1560 1534                  if (stp->st_ino == nlp->nlp_bkdirino) {
1561 1535                          ino = ROOT_INODE;
1562      -                        NDMP_LOG(LOG_DEBUG,
1563      -                            "bkroot %d -> %d", stp->st_ino, ROOT_INODE);
1564 1536                  } else {
1565 1537                          ino = stp->st_ino;
1566 1538                  }
1567 1539  
1568 1540                  params = get_params(cbp->fh_cookie);
1569 1541                  if (params == NULL || params->mp_file_history_node_func == NULL)
1570 1542                          err = -1;
1571 1543                  else if ((err = (*params->mp_file_history_node_func)(cbp->
1572 1544                      fh_cookie, ino, stp, 0)) < 0)
1573      -                        NDMP_LOG(LOG_DEBUG, "\"%s/\": %d", dir, file, err);
     1545 +                        syslog(LOG_DEBUG, "\"%s/\": %d", dir, file, err);
1574 1546  
1575 1547          }
1576 1548  
1577 1549          return (err);
1578 1550  }
1579 1551  
1580 1552  
1581 1553  /*
1582 1554   * ndmpd_path_restored
1583 1555   *
↓ open down ↓ 4 lines elided ↑ open up ↑
1588 1560  ndmpd_path_restored(lbr_fhlog_call_backs_t *cbp, char *name, struct stat64 *stp,
1589 1561      u_longlong_t ll_pos)
1590 1562  {
1591 1563          int rv;
1592 1564          ndmp_name *entp;
1593 1565          ndmp_lbr_params_t *nlp;
1594 1566          ndmpd_module_params_t *params;
1595 1567          int pos =  (int)ll_pos;
1596 1568  
1597 1569          if (cbp == NULL) {
1598      -                NDMP_LOG(LOG_DEBUG, "cbp is NULL");
     1570 +                syslog(LOG_DEBUG, "cbp is NULL");
1599 1571                  return (-1);
1600 1572          }
1601 1573          if (name == NULL) {
1602      -                NDMP_LOG(LOG_DEBUG, "name is NULL");
     1574 +                syslog(LOG_DEBUG, "name is NULL");
1603 1575                  return (-1);
1604 1576          }
1605 1577  
1606      -        NDMP_LOG(LOG_DEBUG, "name: \"%s\", pos: %d",
1607      -            name, pos);
1608      -
1609 1578          if ((nlp = ndmp_get_nlp(cbp->fh_cookie)) == NULL) {
1610      -                NDMP_LOG(LOG_DEBUG, "nlp is NULL");
     1579 +                syslog(LOG_DEBUG, "nlp is NULL");
1611 1580                  return (-1);
1612 1581          }
1613 1582          if (pos < 0 || pos >= nlp->nlp_nfiles) {
1614      -                NDMP_LOG(LOG_DEBUG, "Invalid pos: %d", pos);
     1583 +                syslog(LOG_DEBUG, "Invalid pos: %d", pos);
1615 1584                  return (-1);
1616 1585          }
1617 1586          params = get_params(cbp->fh_cookie);
1618 1587          if (params == NULL || params->mp_file_recovered_func == NULL)
1619 1588                  return (-1);
1620 1589  
1621 1590          rv = 0;
1622 1591          if (!nlp->nlp_restored[pos]) {
1623 1592                  entp = (ndmp_name *)MOD_GETNAME(params, pos);
1624 1593                  if (entp && entp->name)
↓ open down ↓ 38 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX