--- old/usr/src/cmd/ndmpd/ndmp/ndmpd_tar3.c	Mon Aug  5 17:15:19 2019
+++ new/usr/src/cmd/ndmpd/ndmp/ndmpd_tar3.c	Mon Aug  5 17:15:19 2019
@@ -37,11 +37,12 @@
  */
 /* Copyright (c) 2007, The Storage Networking Industry Association. */
 /* Copyright (c) 1996, 1997 PDC, Network Appliance. All Rights Reserved */
-/* Copyright 2014 Nexenta Systems, Inc. All rights reserved. */
+/* Copyright 2017 Nexenta Systems, Inc. All rights reserved. */
 
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/time.h>
+#include <syslog.h>
 #include <ctype.h>
 #include <sys/socket.h>
 #include <sys/acl.h>
@@ -114,6 +115,8 @@
  */
 char **ndmp_excl_list = NULL;
 
+extern boolean_t fs_is_checkpointed(ndmp_lbr_params_t *);
+
 /*
  * split_env
  *
@@ -236,12 +239,12 @@
 prl(char **lpp)
 {
 	if (!lpp) {
-		NDMP_LOG(LOG_DEBUG, "empty");
+		syslog(LOG_DEBUG, "empty");
 		return;
 	}
 
 	while (*lpp)
-		NDMP_LOG(LOG_DEBUG, "\"%s\"", *lpp++);
+		syslog(LOG_DEBUG, "\"%s\"", *lpp++);
 }
 
 
@@ -263,7 +266,7 @@
 inlist(char **lpp, char *ent)
 {
 	if (!lpp || !ent) {
-		NDMP_LOG(LOG_DEBUG, "empty list");
+		syslog(LOG_DEBUG, "empty list");
 		return (FALSE);
 	}
 
@@ -276,16 +279,16 @@
 		if (strncmp(pattern, "./", 2) == 0)
 			pattern += 2;
 
-		NDMP_LOG(LOG_DEBUG, "pattern %s, ent %s", pattern, ent);
+		syslog(LOG_DEBUG, "pattern %s, ent %s", pattern, ent);
 
 		if (match(pattern, ent)) {
-			NDMP_LOG(LOG_DEBUG, "match(%s,%s)", pattern, ent);
+			syslog(LOG_DEBUG, "match(%s,%s)", pattern, ent);
 			return (TRUE);
 		}
 		lpp++;
 	}
 
-	NDMP_LOG(LOG_DEBUG, "no match");
+	syslog(LOG_DEBUG, "no match");
 	return (FALSE);
 }
 
@@ -411,7 +414,7 @@
 		if (len > 1 && ep->nm3_opath[len-2] == '/' &&
 		    ep->nm3_opath[len-1] == '.') {
 			ep->nm3_opath[len-1] = '\0';
-			NDMP_LOG(LOG_DEBUG,
+			syslog(LOG_DEBUG,
 			    "nm3_opath changed from %s. to %s",
 			    ep->nm3_opath, ep->nm3_opath);
 		}
@@ -486,7 +489,7 @@
 		np = "";
 
 	if (!tlm_cat_path(bp, np, pp)) {
-		NDMP_LOG(LOG_ERR, "Restore path too long %s/%s.", np, pp);
+		syslog(LOG_ERR, "Restore path too long %s/%s.", np, pp);
 		return (NULL);
 	}
 
@@ -513,47 +516,34 @@
 
 	rv = NULL;
 	if (!buf) {
-		NDMP_LOG(LOG_DEBUG, "buf is NULL");
+		syslog(LOG_DEBUG, "buf is NULL");
 	} else if (!path) {
-		NDMP_LOG(LOG_DEBUG, "path is NULL");
+		syslog(LOG_DEBUG, "path is NULL");
 	} else if ((nlp = rnp->rn_nlp) == 0) {
-		NDMP_LOG(LOG_DEBUG, "rnp->rn_nlp is NULL");
+		syslog(LOG_DEBUG, "rnp->rn_nlp is NULL");
 	} else if (!nlp->nlp_params) {
-		NDMP_LOG(LOG_DEBUG, "nlp->nlp_params is NULL");
+		syslog(LOG_DEBUG, "nlp->nlp_params is NULL");
 	} else
 		if (!ndmp_full_restore_path) {
 			if (idx < 0 || idx >= (int)nlp->nlp_nfiles) {
-				NDMP_LOG(LOG_DEBUG,
+				syslog(LOG_DEBUG,
 				    "Invalid idx %d range (0, %d)",
 				    idx, nlp->nlp_nfiles);
 			} else if (!(ep = (mem_ndmp_name_v3_t *)MOD_GETNAME(
 			    nlp->nlp_params, idx))) {
-				NDMP_LOG(LOG_DEBUG,
+				syslog(LOG_DEBUG,
 				    "nlist entry %d is NULL", idx);
 			} else {
 				rv = mkrsp(buf, path, ep->nm3_opath,
 				    ep->nm3_dpath);
-
-				NDMP_LOG(LOG_DEBUG,
-				    "idx %d org \"%s\" dst \"%s\"",
-				    idx, ep->nm3_opath, ep->nm3_dpath);
-				if (rv) {
-					NDMP_LOG(LOG_DEBUG,
-					    "path \"%s\": \"%s\"", path, rv);
-				} else {
-					NDMP_LOG(LOG_DEBUG,
-					    "path \"%s\": NULL", path);
-				}
 			}
 		} else {
 			if (!tlm_cat_path(buf, nlp->nlp_restore_path, path)) {
-				NDMP_LOG(LOG_ERR, "Path too long %s/%s.",
+				syslog(LOG_ERR, "Path too long %s/%s.",
 				    nlp->nlp_restore_path, path);
 				rv = NULL;
 			} else {
 				rv = buf;
-				NDMP_LOG(LOG_DEBUG,
-				    "path \"%s\": \"%s\"", path, rv);
 			}
 		}
 
@@ -621,7 +611,7 @@
 		return (0);
 
 	rv = !fs_is_rdonly(path) && !fs_is_chkpntvol(path);
-	NDMP_LOG(LOG_DEBUG, "%d path \"%s\"", rv, path);
+	syslog(LOG_DEBUG, "%d path \"%s\"", rv, path);
 	return (rv);
 
 }
@@ -790,7 +780,7 @@
     ndmp_lbr_params_t *nlp)
 {
 	MOD_LOGV3(params, NDMP_LOG_NORMAL, "Backing up \"%s\".\n",
-	    nlp->nlp_backup_path);
+	    NLP_ISCHKPNTED(nlp) ? nlp->nlp_mountpoint : nlp->nlp_backup_path);
 
 	if (session->ns_mover.md_data_addr.addr_type == NDMP_ADDR_LOCAL)
 		MOD_LOGV3(params, NDMP_LOG_NORMAL,
@@ -836,10 +826,10 @@
 	envp = MOD_GETENV(params, "UPDATE");
 	if (!envp) {
 		NLP_SET(nlp, NLPF_UPDATE);
-		NDMP_LOG(LOG_DEBUG,
+		syslog(LOG_DEBUG,
 		    "env(UPDATE) not defined, default to TRUE");
 	} else {
-		NDMP_LOG(LOG_DEBUG, "env(UPDATE): \"%s\"", envp);
+		syslog(LOG_DEBUG, "env(UPDATE): \"%s\"", envp);
 		if (IS_YORT(*envp))
 			NLP_SET(nlp, NLPF_UPDATE);
 		else
@@ -869,10 +859,10 @@
 
 	envp = MOD_GETENV(params, "HIST");
 	if (!envp) {
-		NDMP_LOG(LOG_DEBUG, "env(HIST) not defined");
+		syslog(LOG_DEBUG, "env(HIST) not defined");
 		NLP_UNSET(nlp, NLPF_FH);
 	} else {
-		NDMP_LOG(LOG_DEBUG, "env(HIST): \"%s\"", envp);
+		syslog(LOG_DEBUG, "env(HIST): \"%s\"", envp);
 		if (IS_YORT(*envp) || IS_F(*envp))
 			NLP_SET(nlp, NLPF_FH);
 		else
@@ -910,10 +900,10 @@
 
 	envp = MOD_GETENV(params, "EXCLUDE");
 	if (!envp) {
-		NDMP_LOG(LOG_DEBUG, "env(EXCLUDE) not defined");
+		syslog(LOG_DEBUG, "env(EXCLUDE) not defined");
 		nlp->nlp_exl = NULL;
 	} else {
-		NDMP_LOG(LOG_DEBUG, "env(EXCLUDE): \"%s\"", envp);
+		syslog(LOG_DEBUG, "env(EXCLUDE): \"%s\"", envp);
 		nlp->nlp_exl = split_env(envp, ',');
 		prl(nlp->nlp_exl);
 	}
@@ -942,10 +932,10 @@
 
 	envp = MOD_GETENV(params, "FILES");
 	if (!envp) {
-		NDMP_LOG(LOG_DEBUG, "env(FILES) not defined");
+		syslog(LOG_DEBUG, "env(FILES) not defined");
 		nlp->nlp_inc = NULL;
 	} else {
-		NDMP_LOG(LOG_DEBUG, "env(FILES): \"%s\"", envp);
+		syslog(LOG_DEBUG, "env(FILES): \"%s\"", envp);
 		nlp->nlp_inc = split_env(envp, ' ');
 		prl(nlp->nlp_inc);
 	}
@@ -977,7 +967,7 @@
 	 * needs to restore a directory they should disable the DAR.
 	 */
 	if (params->mp_operation == NDMP_DATA_OP_RECOVER && !ndmp_dar_support) {
-		NDMP_LOG(LOG_DEBUG, "Direct Access Restore Disabled");
+		syslog(LOG_INFO, "Direct Access Restore Disabled");
 		NLP_UNSET(nlp, NLPF_DIRECT);
 		MOD_LOGV3(params, NDMP_LOG_NORMAL,
 		    "DAR is disabled. Running Restore without DAR");
@@ -991,23 +981,23 @@
 	 * some clients do not set the MOVER window.
 	 */
 	if (params->mp_operation == NDMP_DATA_OP_BACKUP) {
-		NDMP_LOG(LOG_DEBUG, "backup default env(DIRECT): YES");
+		syslog(LOG_DEBUG, "backup default env(DIRECT): YES");
 		NLP_SET(nlp, NLPF_DIRECT);
 	} else {
 
 		envp = MOD_GETENV(params, "DIRECT");
 		if (!envp) {
-			NDMP_LOG(LOG_DEBUG, "env(DIRECT) not defined");
+			syslog(LOG_DEBUG, "env(DIRECT) not defined");
 			NLP_UNSET(nlp, NLPF_DIRECT);
 		} else {
-			NDMP_LOG(LOG_DEBUG, "env(DIRECT): \"%s\"", envp);
+			syslog(LOG_DEBUG, "env(DIRECT): \"%s\"", envp);
 			if (IS_YORT(*envp)) {
 				NLP_SET(nlp, NLPF_DIRECT);
-				NDMP_LOG(LOG_DEBUG,
+				syslog(LOG_DEBUG,
 				    "Direct Access Restore Enabled");
 			} else {
 				NLP_UNSET(nlp, NLPF_DIRECT);
-				NDMP_LOG(LOG_DEBUG,
+				syslog(LOG_DEBUG,
 				    "Direct Access Restore Disabled");
 			}
 		}
@@ -1087,8 +1077,6 @@
 
 	tstamp = tok & 0xffffffff;
 	seq = (tok >> 32) & 0xffffffff;
-	NDMP_LOG(LOG_DEBUG, "basedate \"%s\" %lld seq %u tstamp %u",
-	    basedate, tok, seq, tstamp);
 
 	if ((int)seq > ndmp_get_max_tok_seq()) {
 		rv = NDMP_ILLEGAL_ARGS_ERR;
@@ -1228,7 +1216,7 @@
 
 	envp = MOD_GETENV(params, "LEVEL");
 	if (!envp) {
-		NDMP_LOG(LOG_DEBUG, "env(LEVEL) not defined, default to 0");
+		syslog(LOG_DEBUG, "env(LEVEL) not defined, default to 0");
 		NLP_SET(nlp, NLPF_LEVELBK);
 		NLP_UNSET(nlp, NLPF_LBRBK);
 		NLP_UNSET(nlp, NLPF_TOKENBK);
@@ -1310,13 +1298,11 @@
 	tok = ((u_longlong_t)nlp->nlp_tokseq << 32) | nlp->nlp_cdate;
 	(void) snprintf(val, sizeof (val), "%llu", tok);
 
-	NDMP_LOG(LOG_DEBUG, "tok: %lld %s", tok, val);
-
 	if (MOD_SETENV(params, "DUMP_DATE", val) != 0) {
 		MOD_LOGV3(params, NDMP_LOG_ERROR,
 		    "Could not set DUMP_DATE to %s", val);
 	} else if (!nlp->nlp_dmpnm) {
-		NDMP_LOG(LOG_DEBUG, "No log file defined");
+		syslog(LOG_DEBUG, "No log file defined");
 	} else if (ndmpd_append_dumptime(nlp->nlp_dmpnm, nlp->nlp_backup_path,
 	    nlp->nlp_tokseq, nlp->nlp_tokdate) < 0) {
 		MOD_LOGV3(params, NDMP_LOG_ERROR,
@@ -1346,7 +1332,7 @@
 		return;
 
 	if (!nlp->nlp_dmpnm) {
-		NDMP_LOG(LOG_DEBUG, "No log file defined");
+		syslog(LOG_DEBUG, "No log file defined");
 	} else if (ndmpd_append_dumptime(nlp->nlp_dmpnm, nlp->nlp_backup_path,
 	    nlp->nlp_clevel, nlp->nlp_cdate) < 0) {
 		MOD_LOGV3(params, NDMP_LOG_ERROR,
@@ -1376,7 +1362,7 @@
 		return;
 
 	if (!NLP_SHOULD_UPDATE(nlp)) {
-		NDMP_LOG(LOG_DEBUG, "update not requested");
+		syslog(LOG_DEBUG, "update not requested");
 	} else if (ndmpd_put_dumptime(nlp->nlp_backup_path, nlp->nlp_clevel,
 	    nlp->nlp_cdate) < 0) {
 		MOD_LOGV3(params, NDMP_LOG_ERROR, "Logging backup date.\n");
@@ -1427,8 +1413,6 @@
  *
  * Parameters:
  *   session (input) - pointer to the session
- *   jname (input) - name assigned to the current backup for
- *	job stats strucure
  *
  * Returns:
  *   0: on success
@@ -1435,7 +1419,7 @@
  *   -1: otherwise
  */
 static int
-backup_alloc_structs_v3(ndmpd_session_t *session, char *jname)
+backup_alloc_structs_v3(ndmpd_session_t *session)
 {
 	int n;
 	long xfer_size;
@@ -1444,13 +1428,13 @@
 
 	nlp = ndmp_get_nlp(session);
 	if (!nlp) {
-		NDMP_LOG(LOG_DEBUG, "nlp == NULL");
+		syslog(LOG_ERR, "nlp == NULL");
 		return (-1);
 	}
 
-	nlp->nlp_jstat = tlm_new_job_stats(jname);
+	nlp->nlp_jstat = tlm_new_job_stats(nlp->nlp_job_name);
 	if (!nlp->nlp_jstat) {
-		NDMP_LOG(LOG_DEBUG, "Creating job stats");
+		syslog(LOG_ERR, "Creating job stats failed");
 		return (-1);
 	}
 
@@ -1468,13 +1452,13 @@
 		if (n <= 0)
 			n = 1;
 		xfer_size *= n;
-		NDMP_LOG(LOG_DEBUG, "Adjusted read size: %d",
+		syslog(LOG_DEBUG, "Adjusted read size: %d",
 		    xfer_size);
 	}
 
 	cmds->tcs_command = tlm_create_reader_writer_ipc(TRUE, xfer_size);
 	if (!cmds->tcs_command) {
-		tlm_un_ref_job_stats(jname);
+		tlm_un_ref_job_stats(nlp->nlp_job_name);
 		return (-1);
 	}
 
@@ -1482,7 +1466,7 @@
 	    ndmpd_fhpath_v3_cb, ndmpd_fhdir_v3_cb, ndmpd_fhnode_v3_cb);
 	if (!nlp->nlp_logcallbacks) {
 		tlm_release_reader_writer_ipc(cmds->tcs_command);
-		tlm_un_ref_job_stats(jname);
+		tlm_un_ref_job_stats(nlp->nlp_job_name);
 		return (-1);
 	}
 	nlp->nlp_jstat->js_callbacks = (void *)(nlp->nlp_logcallbacks);
@@ -1502,8 +1486,6 @@
  *
  * Parameters:
  *   session (input) - pointer to the session
- *   jname (input) - name assigned to the current backup for
- *	job stats strucure
  *
  * Returns:
  *   0: on success
@@ -1510,7 +1492,7 @@
  *   -1: otherwise
  */
 int
-restore_alloc_structs_v3(ndmpd_session_t *session, char *jname)
+restore_alloc_structs_v3(ndmpd_session_t *session)
 {
 	long xfer_size;
 	ndmp_lbr_params_t *nlp;
@@ -1518,7 +1500,7 @@
 
 	nlp = ndmp_get_nlp(session);
 	if (!nlp) {
-		NDMP_LOG(LOG_DEBUG, "nlp == NULL");
+		syslog(LOG_ERR, "nlp == NULL");
 		return (-1);
 	}
 
@@ -1525,9 +1507,9 @@
 	/* this is used in ndmpd_path_restored_v3() */
 	nlp->nlp_lastidx = -1;
 
-	nlp->nlp_jstat = tlm_new_job_stats(jname);
+	nlp->nlp_jstat = tlm_new_job_stats(nlp->nlp_job_name);
 	if (!nlp->nlp_jstat) {
-		NDMP_LOG(LOG_DEBUG, "Creating job stats");
+		syslog(LOG_ERR, "Creating job stats failed");
 		return (-1);
 	}
 
@@ -1537,7 +1519,7 @@
 	xfer_size = ndmp_buffer_get_size(session);
 	cmds->tcs_command = tlm_create_reader_writer_ipc(FALSE, xfer_size);
 	if (!cmds->tcs_command) {
-		tlm_un_ref_job_stats(jname);
+		tlm_un_ref_job_stats(nlp->nlp_job_name);
 		return (-1);
 	}
 
@@ -1545,7 +1527,7 @@
 	    ndmpd_path_restored_v3, NULL, NULL);
 	if (!nlp->nlp_logcallbacks) {
 		tlm_release_reader_writer_ipc(cmds->tcs_command);
-		tlm_un_ref_job_stats(jname);
+		tlm_un_ref_job_stats(nlp->nlp_job_name);
 		return (-1);
 	}
 	nlp->nlp_jstat->js_callbacks = (void *)(nlp->nlp_logcallbacks);
@@ -1552,10 +1534,10 @@
 
 	nlp->nlp_rsbm = bm_alloc(nlp->nlp_nfiles, 0);
 	if (nlp->nlp_rsbm < 0) {
-		NDMP_LOG(LOG_ERR, "Out of memory.");
+		syslog(LOG_ERR, "Out of memory.");
 		lbrlog_callbacks_done(nlp->nlp_logcallbacks);
 		tlm_release_reader_writer_ipc(cmds->tcs_command);
-		tlm_un_ref_job_stats(jname);
+		tlm_un_ref_job_stats(nlp->nlp_job_name);
 		return (-1);
 	}
 
@@ -1571,15 +1553,12 @@
  *
  * Parameters:
  *   session (input) - pointer to the session
- *   jname (input) - name assigned to the current backup for
- *	job stats strucure
  *
  * Returns:
  *   void
  */
-/*ARGSUSED*/
 static void
-free_structs_v3(ndmpd_session_t *session, char *jname)
+free_structs_v3(ndmpd_session_t *session)
 {
 	ndmp_lbr_params_t *nlp;
 	tlm_commands_t *cmds;
@@ -1586,12 +1565,12 @@
 
 	nlp = ndmp_get_nlp(session);
 	if (!nlp) {
-		NDMP_LOG(LOG_DEBUG, "nlp == NULL");
+		syslog(LOG_DEBUG, "nlp == NULL");
 		return;
 	}
 	cmds = &nlp->nlp_cmds;
 	if (!cmds) {
-		NDMP_LOG(LOG_DEBUG, "cmds == NULL");
+		syslog(LOG_DEBUG, "cmds == NULL");
 		return;
 	}
 
@@ -1599,16 +1578,16 @@
 		lbrlog_callbacks_done(nlp->nlp_logcallbacks);
 		nlp->nlp_logcallbacks = NULL;
 	} else
-		NDMP_LOG(LOG_DEBUG, "FH CALLBACKS == NULL");
+		syslog(LOG_DEBUG, "FH CALLBACKS == NULL");
 
 	if (cmds->tcs_command) {
 		if (cmds->tcs_command->tc_buffers != NULL)
 			tlm_release_reader_writer_ipc(cmds->tcs_command);
 		else
-			NDMP_LOG(LOG_DEBUG, "BUFFERS == NULL");
+			syslog(LOG_DEBUG, "BUFFERS == NULL");
 		cmds->tcs_command = NULL;
 	} else
-		NDMP_LOG(LOG_DEBUG, "COMMAND == NULL");
+		syslog(LOG_DEBUG, "COMMAND == NULL");
 
 	if (nlp->nlp_bkmap >= 0) {
 		(void) dbm_free(nlp->nlp_bkmap);
@@ -1617,7 +1596,7 @@
 
 	if (session->ns_data.dd_operation == NDMP_DATA_OP_RECOVER) {
 		if (nlp->nlp_rsbm < 0) {
-			NDMP_LOG(LOG_DEBUG, "nlp_rsbm < 0 %d", nlp->nlp_rsbm);
+			syslog(LOG_DEBUG, "nlp_rsbm < 0 %d", nlp->nlp_rsbm);
 		} else {
 			(void) bm_free(nlp->nlp_rsbm);
 			nlp->nlp_rsbm = -1;
@@ -1653,17 +1632,15 @@
 	char *p;
 
 	if (!bpp || !pnp || !enp) {
-		NDMP_LOG(LOG_DEBUG, "Invalid argument");
+		syslog(LOG_ERR, "Invalid argument in backup_dirv3");
 		return (-1);
 	}
 
-	NDMP_LOG(LOG_DEBUG, "d(%s)", bpp->bp_tmp);
-
 	if (lstat64(bpp->bp_tmp, &st) != 0)
 		return (0);
 
 	if (acl_get(bpp->bp_tmp, ACL_NO_TRIVIAL, &aclp) != 0) {
-		NDMP_LOG(LOG_DEBUG, "acl_get error errno=%d", errno);
+		syslog(LOG_DEBUG, "acl_get error errno=%d", errno);
 		return (-1);
 	}
 	if (aclp && (acltp = acl_totext(aclp,
@@ -1718,7 +1695,7 @@
     fst_node_t *enp)
 {
 	char *ent;
-	longlong_t rv;
+	int rv = -1;
 	longlong_t apos, bpos;
 	acl_t *aclp = NULL;
 	char *acltp;
@@ -1727,18 +1704,16 @@
 	char *p;
 
 	if (!bpp || !pnp || !enp) {
-		NDMP_LOG(LOG_DEBUG, "Invalid argument");
+		syslog(LOG_ERR, "Invalid argument in backup_filev3");
 		return (-1);
 	}
 
-	NDMP_LOG(LOG_DEBUG, "f(%s)", bpp->bp_tmp);
-
 	if (lstat64(bpp->bp_tmp, &st) != 0)
 		return (0);
 
 	if (!S_ISLNK(bpp->bp_tlmacl->acl_attr.st_mode)) {
 		if (acl_get(bpp->bp_tmp, ACL_NO_TRIVIAL, &aclp) != 0) {
-			NDMP_LOG(LOG_DEBUG, "acl_get error");
+			syslog(LOG_DEBUG, "acl_get error");
 			return (-1);
 		}
 
@@ -1803,21 +1778,21 @@
 
 	if (!bpp) {
 		rv = -1;
-		NDMP_LOG(LOG_DEBUG, "Lost bpp");
+		syslog(LOG_DEBUG, "Lost bpp");
 	} else if (!bpp->bp_session) {
 		rv = -1;
-		NDMP_LOG(LOG_DEBUG, "Session is NULL");
+		syslog(LOG_DEBUG, "Session is NULL");
 	} else if (bpp->bp_session->ns_eof) {
 		rv = -1;
-		NDMP_LOG(LOG_INFO,
+		syslog(LOG_INFO,
 		    "Connection client is closed for backup \"%s\"",
 		    bpp->bp_nlp->nlp_backup_path);
 	} else if (!bpp->bp_nlp) {
-		NDMP_LOG(LOG_DEBUG, "Lost nlp");
+		syslog(LOG_DEBUG, "Lost nlp");
 		return (-1);
 	} else if (bpp->bp_session->ns_data.dd_abort) {
 		rv = -1;
-		NDMP_LOG(LOG_INFO, "Backup aborted \"%s\"",
+		syslog(LOG_INFO, "Backup aborted \"%s\"",
 		    bpp->bp_nlp->nlp_backup_path);
 	} else
 		rv = 0;
@@ -1852,7 +1827,7 @@
 	struct stat64 *estp;
 
 	if (!bpp || !pnp || !enp || !errp) {
-		NDMP_LOG(LOG_DEBUG, "Invalid argument");
+		syslog(LOG_DEBUG, "Invalid argument in shouldskip");
 		return (TRUE);
 	}
 
@@ -1872,23 +1847,16 @@
 	if (!dbm_getone(bpp->bp_nlp->nlp_bkmap, (u_longlong_t)estp->st_ino)) {
 		rv = TRUE;
 		*errp = S_ISDIR(estp->st_mode) ? FST_SKIP : 0;
-		NDMP_LOG(LOG_DEBUG, "Skipping %d %s/%s",
-		    *errp, pnp->tn_path, ent);
 	} else if (tlm_is_excluded(pnp->tn_path, ent, bpp->bp_excls)) {
 		rv = TRUE;
 		*errp = S_ISDIR(estp->st_mode) ? FST_SKIP : 0;
-		NDMP_LOG(LOG_DEBUG, "excl %d \"%s/%s\"",
-		    *errp, pnp->tn_path, ent);
 	} else if (inexl(bpp->bp_nlp->nlp_exl, ent)) {
 		rv = TRUE;
 		*errp = S_ISDIR(estp->st_mode) ? FST_SKIP : 0;
-		NDMP_LOG(LOG_DEBUG, "out %d \"%s/%s\"",
-		    *errp, pnp->tn_path, ent);
 	} else if (!S_ISDIR(estp->st_mode) &&
 	    !ininc(bpp->bp_nlp->nlp_inc, ent)) {
 		rv = TRUE;
 		*errp = 0;
-		NDMP_LOG(LOG_DEBUG, "!in \"%s/%s\"", pnp->tn_path, ent);
 	} else
 		rv = FALSE;
 
@@ -1923,10 +1891,10 @@
 
 	if (!stp) {
 		rv = FALSE;
-		NDMP_LOG(LOG_DEBUG, "stp is NULL");
+		syslog(LOG_DEBUG, "stp is NULL");
 	} else if (!nlp) {
 		rv = FALSE;
-		NDMP_LOG(LOG_DEBUG, "nlp is NULL");
+		syslog(LOG_DEBUG, "nlp is NULL");
 	} else if (t == 0) {
 		/*
 		 * if we are doing base backup then we do not need to
@@ -1933,10 +1901,8 @@
 		 * check the time, for we should backup everything.
 		 */
 		rv = TRUE;
-		NDMP_LOG(LOG_DEBUG, "Base Backup");
 	} else if (S_ISDIR(stp->st_mode) && ndmp_force_bk_dirs) {
 		rv = TRUE;
-		NDMP_LOG(LOG_DEBUG, "d(%lu)", (uint_t)stp->st_ino);
 	} else if (S_ISDIR(stp->st_mode) &&
 	    dbm_getone(nlp->nlp_bkmap, (u_longlong_t)stp->st_ino) &&
 	    ((NLP_ISDUMP(nlp) && ndmp_dump_path_node) ||
@@ -1957,26 +1923,23 @@
 		 * need not to be reported.
 		 */
 		rv = TRUE;
-		NDMP_LOG(LOG_DEBUG, "p(%lu)", (u_longlong_t)stp->st_ino);
 	} else if (stp->st_mtime > t) {
 		rv = TRUE;
-		NDMP_LOG(LOG_DEBUG, "m(%lu): %lu > %lu",
-		    (uint_t)stp->st_ino, (uint_t)stp->st_mtime, (uint_t)t);
 	} else if (stp->st_ctime > t) {
 		if (NLP_IGNCTIME(nlp)) {
 			rv = FALSE;
-			NDMP_LOG(LOG_DEBUG, "ign c(%lu): %lu > %lu",
+			syslog(LOG_DEBUG, "ign c(%lu): %lu > %lu",
 			    (uint_t)stp->st_ino, (uint_t)stp->st_ctime,
 			    (uint_t)t);
 		} else {
 			rv = TRUE;
-			NDMP_LOG(LOG_DEBUG, "c(%lu): %lu > %lu",
+			syslog(LOG_DEBUG, "c(%lu): %lu > %lu",
 			    (uint_t)stp->st_ino, (uint_t)stp->st_ctime,
 			    (uint_t)t);
 		}
 	} else {
 		rv = FALSE;
-		NDMP_LOG(LOG_DEBUG, "mc(%lu): (%lu,%lu) < %lu",
+		syslog(LOG_DEBUG, "mc(%lu): (%lu,%lu) < %lu",
 		    (uint_t)stp->st_ino, (uint_t)stp->st_mtime,
 		    (uint_t)stp->st_ctime, (uint_t)t);
 	}
@@ -2000,13 +1963,13 @@
 	acl_t *aclp = NULL;
 	char *acltp;
 
-	NDMP_LOG(LOG_DEBUG, "flags %x", nlp->nlp_flags);
+	syslog(LOG_DEBUG, "flags %x", nlp->nlp_flags);
 	if (NLP_INCLMTIME(nlp) == FALSE)
 		return (0);
 
 	ret = acl_get(name, ACL_NO_TRIVIAL, &aclp);
 	if (ret != 0) {
-		NDMP_LOG(LOG_DEBUG,
+		syslog(LOG_DEBUG,
 		    "Error getting the acl information: err %d", ret);
 		return (0);
 	}
@@ -2092,7 +2055,7 @@
 
 
 	if (!tlm_cat_path(bpp->bp_tmp, pnp->tn_path, ent)) {
-		NDMP_LOG(LOG_ERR, "Path too long %s/%s.", pnp->tn_path, ent);
+		syslog(LOG_ERR, "Path too long %s/%s.", pnp->tn_path, ent);
 		return (FST_SKIP);
 	}
 	if (NLP_ISSET(bpp->bp_nlp, NLPF_TOKENBK))
@@ -2100,7 +2063,7 @@
 	else if (NLP_ISSET(bpp->bp_nlp, NLPF_LEVELBK)) {
 		t = bpp->bp_nlp->nlp_ldate;
 	} else {
-		NDMP_LOG(LOG_DEBUG, "Unknown backup type on \"%s/%s\"",
+		syslog(LOG_ERR, "Unknown backup type on \"%s/%s\"",
 		    pnp->tn_path, ent);
 		return (-1);
 	}
@@ -2177,11 +2140,11 @@
 	}
 
 	if (!tlm_cat_path(bpp->bp_tmp, pnp->tn_path, ent)) {
-		NDMP_LOG(LOG_ERR, "Path too long %s/%s.", pnp->tn_path, ent);
+		syslog(LOG_ERR, "Path too long %s/%s.", pnp->tn_path, ent);
 		return (FST_SKIP);
 	}
 	if (!NLP_ISSET(bpp->bp_nlp, NLPF_LBRBK)) {
-		NDMP_LOG(LOG_DEBUG, "!NLPF_LBRBK");
+		syslog(LOG_DEBUG, "!NLPF_LBRBK");
 		return (-1);
 	}
 
@@ -2213,10 +2176,7 @@
  * way.
  *
  * Parameters:
- *   jname (input) - name assigned to the current backup for
- *	job stats strucure
- *   nlp (input) - pointer to the nlp structure
- *   cmds (input) - pointer to the tlm_commands_t structure
+ *   argp (input) - backup reader argument
  *
  * Returns:
  *   0: on success
@@ -2231,14 +2191,13 @@
 	longlong_t bpos, n;
 	bk_param_v3_t bp;
 	fs_traverse_t ft;
-	char *jname;
 	ndmp_lbr_params_t *nlp;
 	tlm_commands_t *cmds;
+	int rc;
 
 	if (!argp)
 		return (-1);
 
-	jname = argp->br_jname;
 	nlp = argp->br_nlp;
 	cmds = argp->br_cmds;
 
@@ -2254,7 +2213,7 @@
 	bp.bp_nlp = nlp;
 
 	/* LBR-related parameters  */
-	bp.bp_js = tlm_ref_job_stats(jname);
+	bp.bp_js = tlm_ref_job_stats(nlp->nlp_job_name);
 	bp.bp_cmds = cmds;
 	bp.bp_lcmd = lcmd;
 	bp.bp_tlmacl = &tlm_acls;
@@ -2261,7 +2220,10 @@
 	bp.bp_opr = 0;
 
 	/* release the parent thread, after referencing the job stats */
-	(void) pthread_barrier_wait(&argp->br_barrier);
+	rc = pthread_barrier_wait(&argp->br_barrier);
+	if (rc == PTHREAD_BARRIER_SERIAL_THREAD) {
+		(void) pthread_barrier_destroy(&argp->br_barrier);
+	}
 
 	bp.bp_tmp = ndmp_malloc(sizeof (char) * TLM_MAX_PATH_NAME);
 	if (!bp.bp_tmp)
@@ -2273,7 +2235,7 @@
 	 */
 	bp.bp_unchkpnm = nlp->nlp_backup_path;
 	if (!NLP_ISCHKPNTED(nlp)) {
-		tlm_acls.acl_checkpointed = TRUE;
+		tlm_acls.acl_checkpointed = FALSE;
 		bp.bp_chkpnm = ndmp_malloc(sizeof (char) * TLM_MAX_PATH_NAME);
 		if (!bp.bp_chkpnm) {
 			NDMP_FREE(bp.bp_tmp);
@@ -2282,8 +2244,8 @@
 		(void) tlm_build_snapshot_name(nlp->nlp_backup_path,
 		    bp.bp_chkpnm, nlp->nlp_jstat->js_job_name);
 	} else {
-		tlm_acls.acl_checkpointed = FALSE;
-		bp.bp_chkpnm = nlp->nlp_backup_path;
+		tlm_acls.acl_checkpointed = TRUE;
+		bp.bp_chkpnm = nlp->nlp_mountpoint;
 	}
 	bp.bp_excls = ndmpd_make_exc_list();
 
@@ -2291,7 +2253,6 @@
 	ft.ft_path = nlp->nlp_backup_path;
 	ft.ft_lpath = bp.bp_chkpnm;
 
-	NDMP_LOG(LOG_DEBUG, "path %s lpath %s", ft.ft_path, ft.ft_lpath);
 	if (NLP_ISSET(nlp, NLPF_TOKENBK) || NLP_ISSET(nlp, NLPF_LEVELBK)) {
 		ft.ft_callbk = timebk_v3;
 		tlm_acls.acl_clear_archive = FALSE;
@@ -2299,17 +2260,20 @@
 		ft.ft_callbk = lbrbk_v3;
 		tlm_acls.acl_clear_archive = FALSE;
 
-		NDMP_LOG(LOG_DEBUG, "bp_opr %x clr_arc %c",
+		syslog(LOG_DEBUG, "bp_opr %x clr_arc %c",
 		    bp.bp_opr, NDMP_YORN(tlm_acls.acl_clear_archive));
 	} else {
 		rv = -1;
 		MOD_LOGV3(nlp->nlp_params, NDMP_LOG_ERROR,
-		    "Unknow backup type.\n");
+		    "Unknown backup type.\n");
 	}
+
 	ft.ft_arg = &bp;
-	ft.ft_logfp = (ft_log_t)ndmp_log;
+	ft.ft_logfp = (ft_log_t)syslog;
 	ft.ft_flags = FST_VERBOSE | FST_STOP_ONERR;
 
+	syslog(LOG_DEBUG, "Traverse logical path [%s]", ft.ft_lpath);
+
 	/* take into account the header written to the stream so far */
 	n = tlm_get_data_offset(lcmd);
 	nlp->nlp_session->ns_data.dd_module.dm_stats.ms_bytes_processed = n;
@@ -2340,9 +2304,9 @@
 	cmds->tcs_reader_count--;
 	lcmd->tc_writer = TLM_STOP;
 	tlm_release_reader_writer_ipc(lcmd);
-	tlm_un_ref_job_stats(jname);
-	return (rv);
+	tlm_un_ref_job_stats(nlp->nlp_job_name);
 
+	return (rv);
 }
 
 
@@ -2356,7 +2320,6 @@
  *   session (input) - pointer to the session
  *   params (input) - pointer to the parameters structure
  *   nlp (input) - pointer to the nlp structure
- *   jname (input) - job name
  *
  * Returns:
  *   0: on success
@@ -2364,7 +2327,7 @@
  */
 static int
 tar_backup_v3(ndmpd_session_t *session, ndmpd_module_params_t *params,
-    ndmp_lbr_params_t *nlp, char *jname)
+    ndmp_lbr_params_t *nlp)
 {
 	tlm_commands_t *cmds;
 	backup_reader_arg_t arg;
@@ -2373,18 +2336,21 @@
 	int result;
 	ndmp_context_t nctx;
 	int err;
+	int rc;
 
-	if (ndmp_get_bk_dir_ino(nlp))
+	if (ndmp_get_bk_dir_ino(nlp)) {
+		syslog(LOG_ERR, "Couldn't get backup directory inode");
 		return (-1);
+	}
 
 	result = err = 0;
 
 	/* exit as if there was an internal error */
-	if (session->ns_eof)
+	if (session->ns_eof) {
 		return (-1);
-
+	}
 	if (!session->ns_data.dd_abort) {
-		if (backup_alloc_structs_v3(session, jname) < 0) {
+		if (backup_alloc_structs_v3(session) < 0) {
 			nlp->nlp_bkmap = -1;
 			return (-1);
 		}
@@ -2394,7 +2360,7 @@
 				(void) dbm_free(nlp->nlp_bkmap);
 				nlp->nlp_bkmap = -1;
 			}
-			free_structs_v3(session, jname);
+			free_structs_v3(session);
 			return (-1);
 		}
 
@@ -2408,12 +2374,13 @@
 		cmds->tcs_command->tc_writer = TLM_BACKUP_RUN;
 
 		if (ndmp_write_utf8magic(cmds->tcs_command) < 0) {
-			free_structs_v3(session, jname);
+			free_structs_v3(session);
 			return (-1);
 		}
 
-		NDMP_LOG(LOG_DEBUG,
-		    "Backing up \"%s\" started.", nlp->nlp_backup_path);
+		syslog(LOG_DEBUG, "Backing up \"%s\" started.",
+		    NLP_ISCHKPNTED(nlp)
+		    ? nlp->nlp_mountpoint : nlp->nlp_backup_path);
 
 		/* Plug-in module */
 		if (ndmp_pl != NULL &&
@@ -2426,13 +2393,12 @@
 			nctx.nc_ddata = (void *) session;
 			if ((err = ndmp_pl->np_pre_backup(ndmp_pl, &nctx,
 			    nlp->nlp_backup_path)) != 0) {
-				NDMP_LOG(LOG_ERR, "Pre-backup plug-in: %m");
+				syslog(LOG_ERR, "Pre-backup plug-in: %m");
 				goto backup_out;
 			}
 		}
 
 		(void) memset(&arg, 0, sizeof (backup_reader_arg_t));
-		arg.br_jname = jname;
 		arg.br_nlp = nlp;
 		arg.br_cmds = cmds;
 
@@ -2441,12 +2407,15 @@
 		err = pthread_create(&rdtp, NULL, (funct_t)backup_reader_v3,
 		    (void *)&arg);
 		if (err == 0) {
-			(void) pthread_barrier_wait(&arg.br_barrier);
-			(void) pthread_barrier_destroy(&arg.br_barrier);
+			rc =  pthread_barrier_wait(&arg.br_barrier);
+			if (rc == PTHREAD_BARRIER_SERIAL_THREAD) {
+				(void) pthread_barrier_destroy(&arg.br_barrier);
+			}
 		} else {
 			(void) pthread_barrier_destroy(&arg.br_barrier);
-			free_structs_v3(session, jname);
-			NDMP_LOG(LOG_DEBUG, "Launch backup_reader_v3: %m");
+			free_structs_v3(session);
+			syslog(LOG_ERR, "Launch backup_reader_v3 failed on %s",
+			    nlp->nlp_job_name);
 			return (-1);
 		}
 
@@ -2456,7 +2425,7 @@
 		nlp->nlp_jstat->js_stop_time = time(NULL);
 
 		(void) snprintf(info, sizeof (info),
-		    "Runtime [%s] %llu bytes (%llu): %d seconds\n",
+		    "Runtime [%s] %lu bytes (%lu): %d seconds\n",
 		    nlp->nlp_backup_path,
 		    session->ns_data.dd_module.dm_stats.ms_bytes_processed,
 		    session->ns_data.dd_module.dm_stats.ms_bytes_processed,
@@ -2466,7 +2435,6 @@
 
 		ndmp_wait_for_reader(cmds);
 		(void) pthread_join(rdtp, NULL);
-
 		/* exit as if there was an internal error */
 		if (session->ns_eof) {
 			result = EPIPE;
@@ -2477,8 +2445,9 @@
 			    nlp->nlp_backup_path,
 			    session->ns_data.dd_data_addr.addr_type,
 			    session->ns_tape.td_adapter_name, result);
-			NDMP_LOG(LOG_DEBUG, "Backing up \"%s\" Finished.",
-			    nlp->nlp_backup_path);
+			syslog(LOG_DEBUG, "Backing up \"%s\" Finished.",
+			    NLP_ISCHKPNTED(nlp) ?
+			    nlp->nlp_mountpoint : nlp->nlp_backup_path);
 		}
 	}
 
@@ -2487,8 +2456,9 @@
 		    nlp->nlp_backup_path,
 		    session->ns_data.dd_data_addr.addr_type,
 		    session->ns_tape.td_adapter_name, EINTR);
-		NDMP_LOG(LOG_DEBUG,
-		    "Backing up \"%s\" aborted.", nlp->nlp_backup_path);
+		syslog(LOG_INFO, "Backing up \"%s\" aborted.",
+		    NLP_ISCHKPNTED(nlp) ?
+		    nlp->nlp_mountpoint : nlp->nlp_backup_path);
 		err = -1;
 	} else {
 
@@ -2497,12 +2467,12 @@
 		if (ndmp_pl != NULL &&
 		    ndmp_pl->np_post_backup != NULL &&
 		    ndmp_pl->np_post_backup(ndmp_pl, &nctx, err) == -1) {
-			NDMP_LOG(LOG_DEBUG, "Post-backup plug-in: %m");
+			syslog(LOG_ERR, "Post-backup plug-in: %m");
 			return (-1);
 		}
 	}
 
-	free_structs_v3(session, jname);
+	free_structs_v3(session);
 	return (err);
 }
 
@@ -2513,19 +2483,19 @@
  * of the progress of backup during NDMP backup.
  */
 void
-get_backup_size(ndmp_bkup_size_arg_t *sarg)
+get_backup_size(ndmp_lbr_params_t *nlp)
 {
 	fs_traverse_t ft;
-	u_longlong_t bk_size;
+	u_longlong_t bk_size = 0;
+	char buf[256];
 	char spath[PATH_MAX];
 	int rv;
 
-	bk_size = 0;
-	if (fs_is_chkpntvol(sarg->bs_path)) {
-		ft.ft_path = sarg->bs_path;
+	if (NLP_ISCHKPNTED(nlp)) {
+		ft.ft_path = nlp->nlp_mountpoint;
 	} else {
-		(void) tlm_build_snapshot_name(sarg->bs_path,
-		    spath, sarg->bs_jname);
+		(void) tlm_build_snapshot_name(nlp->nlp_backup_path,
+		    spath, nlp->nlp_job_name);
 		ft.ft_path = spath;
 	}
 
@@ -2532,17 +2502,21 @@
 	ft.ft_lpath = ft.ft_path;
 	ft.ft_callbk = size_cb;
 	ft.ft_arg = &bk_size;
-	ft.ft_logfp = (ft_log_t)ndmp_log;
+	ft.ft_logfp = (ft_log_t)syslog;
 	ft.ft_flags = FST_VERBOSE;
 
 	if ((rv = traverse_level(&ft)) != 0) {
-		NDMP_LOG(LOG_DEBUG, "bksize err=%d", rv);
+		syslog(LOG_DEBUG, "bksize err=%d", rv);
+		syslog(LOG_DEBUG, "[%s] backup will be reported as [0]\n",
+		    nlp->nlp_job_name, buf);
 		bk_size = 0;
 	} else {
-		NDMP_LOG(LOG_DEBUG, "bksize %lld, %lldKB, %lldMB\n",
-		    bk_size, bk_size / 1024, bk_size /(1024 * 1024));
+		(void) zfs_nicenum(bk_size, buf, sizeof (buf));
+		syslog(LOG_DEBUG, "[%s] backup size is [%s]\n",
+		    nlp->nlp_job_name, buf);
 	}
-	sarg->bs_session->ns_data.dd_data_size = bk_size;
+
+	nlp->nlp_session->ns_data.dd_data_size = bk_size;
 }
 
 /*
@@ -2554,7 +2528,7 @@
 get_rs_path_v3(ndmpd_module_params_t *params, ndmp_lbr_params_t *nlp)
 {
 	char *dp;
-	ndmp_error rv;
+	ndmp_error rv = -1;
 	mem_ndmp_name_v3_t *ep;
 	int i, nm_cnt;
 	char *nm_dpath_list[MULTIPLE_DEST_DIRS];
@@ -2565,7 +2539,7 @@
 	for (i = 0, nm_cnt = 0; i < (int)nlp->nlp_nfiles; i++) {
 		ep = (mem_ndmp_name_v3_t *)MOD_GETNAME(params, i);
 		if (!ep) {
-			NDMP_LOG(LOG_DEBUG, "Can't get Nlist[%d]", i);
+			syslog(LOG_ERR, "Can't get Nlist[%d]", i);
 			return (NDMP_ILLEGAL_ARGS_ERR);
 		}
 		if (strcmp(nm_dpath_list[nm_cnt], ep->nm3_dpath) != 0 &&
@@ -2597,7 +2571,7 @@
 			rv = NDMP_NO_ERR;
 			(void) strlcat(nlp->nlp_restore_path, dp,
 			    sizeof (mdest_buf));
-			NDMP_LOG(LOG_DEBUG, "rspath: \"%s\"", dp);
+			syslog(LOG_DEBUG, "rspath: \"%s\"", dp);
 		}
 
 		/*
@@ -2767,12 +2741,12 @@
 		NDMP_FREE(ep->nm3_opath);
 		ep->nm3_opath = cp;
 
-		NDMP_LOG(LOG_DEBUG, "orig[%d]: \"%s\"", i, ep->nm3_opath);
+		syslog(LOG_DEBUG, "orig[%d]: \"%s\"", i, ep->nm3_opath);
 		if (ep->nm3_dpath) {
-			NDMP_LOG(LOG_DEBUG,
+			syslog(LOG_DEBUG,
 			    "dest[%d]: \"%s\"", i, ep->nm3_dpath);
 		} else {
-			NDMP_LOG(LOG_DEBUG, "dest[%d]: \"%s\"", i, "NULL");
+			syslog(LOG_INFO, "dest[%d]: \"%s\"", i, "NULL");
 		}
 	}
 
@@ -2867,11 +2841,11 @@
 	int err;
 
 	if (!params) {
-		NDMP_LOG(LOG_DEBUG, "params == NULL");
+		syslog(LOG_ERR, "params == NULL");
 		return (-1);
 	}
 	if (!nlp) {
-		NDMP_LOG(LOG_DEBUG, "nlp == NULL");
+		syslog(LOG_ERR, "nlp == NULL");
 		return (-1);
 	}
 
@@ -2908,7 +2882,6 @@
  *
  * Parameters:
  *   session (input) - pointer to the session
- *   jname (input) - Job name
  *
  * Returns:
  *    0: on success
@@ -2915,7 +2888,7 @@
  *   -1: on error
  */
 int
-restore_dar_alloc_structs_v3(ndmpd_session_t *session, char *jname)
+restore_dar_alloc_structs_v3(ndmpd_session_t *session)
 {
 	long xfer_size;
 	ndmp_lbr_params_t *nlp;
@@ -2923,7 +2896,7 @@
 
 	nlp = ndmp_get_nlp(session);
 	if (!nlp) {
-		NDMP_LOG(LOG_DEBUG, "nlp == NULL");
+		syslog(LOG_ERR, "nlp == NULL");
 		return (-1);
 	}
 
@@ -2933,7 +2906,7 @@
 	xfer_size = ndmp_buffer_get_size(session);
 	cmds->tcs_command = tlm_create_reader_writer_ipc(FALSE, xfer_size);
 	if (!cmds->tcs_command) {
-		tlm_un_ref_job_stats(jname);
+		tlm_un_ref_job_stats(nlp->nlp_job_name);
 		return (-1);
 	}
 
@@ -2949,7 +2922,6 @@
  *
  * Parameters:
  *   session (input) - pointer to the session
- *   jname (input) - job name
  *
  * Returns:
  *	NONE
@@ -2956,7 +2928,7 @@
  */
 /*ARGSUSED*/
 static void
-free_dar_structs_v3(ndmpd_session_t *session, char *jname)
+free_dar_structs_v3(ndmpd_session_t *session)
 {
 	ndmp_lbr_params_t *nlp;
 	tlm_commands_t *cmds;
@@ -2963,12 +2935,12 @@
 
 	nlp = ndmp_get_nlp(session);
 	if (!nlp) {
-		NDMP_LOG(LOG_DEBUG, "nlp == NULL");
+		syslog(LOG_DEBUG, "nlp == NULL");
 		return;
 	}
 	cmds = &nlp->nlp_cmds;
 	if (!cmds) {
-		NDMP_LOG(LOG_DEBUG, "cmds == NULL");
+		syslog(LOG_DEBUG, "cmds == NULL");
 		return;
 	}
 
@@ -2976,10 +2948,10 @@
 		if (cmds->tcs_command->tc_buffers != NULL)
 			tlm_release_reader_writer_ipc(cmds->tcs_command);
 		else
-			NDMP_LOG(LOG_DEBUG, "BUFFERS == NULL");
+			syslog(LOG_DEBUG, "BUFFERS == NULL");
 		cmds->tcs_command = NULL;
 	} else
-		NDMP_LOG(LOG_DEBUG, "COMMAND == NULL");
+		syslog(LOG_DEBUG, "COMMAND == NULL");
 }
 
 
@@ -3008,11 +2980,14 @@
 	if (!jname)
 		return (NULL);
 
-	(void) ndmp_new_job_name(jname);
+	if (ndmp_new_job_name(jname, TLM_MAX_BACKUP_JOB_NAME) <= 0) {
+		free(jname);
+		return (NULL);
+	}
 
 	if (!nlp) {
 		free(jname);
-		NDMP_LOG(LOG_DEBUG, "nlp == NULL");
+		syslog(LOG_DEBUG, "nlp == NULL");
 		return (NULL);
 	}
 
@@ -3019,7 +2994,7 @@
 	nlp->nlp_jstat = tlm_new_job_stats(jname);
 	if (!nlp->nlp_jstat) {
 		free(jname);
-		NDMP_LOG(LOG_DEBUG, "Creating job stats");
+		syslog(LOG_DEBUG, "Creating job stats");
 		return (NULL);
 	}
 
@@ -3037,7 +3012,7 @@
 
 	nlp->nlp_rsbm = bm_alloc(nlp->nlp_nfiles, 0);
 	if (nlp->nlp_rsbm < 0) {
-		NDMP_LOG(LOG_ERR, "Out of memory.");
+		syslog(LOG_ERR, "Out of memory.");
 		lbrlog_callbacks_done(nlp->nlp_logcallbacks);
 		tlm_un_ref_job_stats(jname);
 		free(jname);
@@ -3047,7 +3022,7 @@
 	/* this is used in ndmpd_path_restored_v3() */
 	nlp->nlp_lastidx = -1;
 
-	NDMP_LOG(LOG_DEBUG, "Restoring from %s tape(s).",
+	syslog(LOG_DEBUG, "Restoring from %s tape(s).",
 	    ndmp_data_get_mover_mode(session));
 
 	return (jname);
@@ -3075,7 +3050,7 @@
 	int err = 0;
 
 
-	NDMP_LOG(LOG_DEBUG, "lastidx %d", nlp->nlp_lastidx);
+	syslog(LOG_DEBUG, "lastidx %d", nlp->nlp_lastidx);
 
 	/* nothing restored. */
 	(void) send_unrecovered_list_v3(params, nlp);
@@ -3086,7 +3061,7 @@
 		tlm_un_ref_job_stats(jname);
 		nlp->nlp_jstat = NULL;
 	} else {
-		NDMP_LOG(LOG_DEBUG, "JSTAT == NULL");
+		syslog(LOG_DEBUG, "JSTAT == NULL");
 	}
 
 	if (nlp->nlp_logcallbacks) {
@@ -3093,15 +3068,15 @@
 		lbrlog_callbacks_done(nlp->nlp_logcallbacks);
 		nlp->nlp_logcallbacks = NULL;
 	} else {
-		NDMP_LOG(LOG_DEBUG, "FH CALLBACKS == NULL");
+		syslog(LOG_DEBUG, "FH CALLBACKS == NULL");
 	}
 
 	if (session->ns_data.dd_abort) {
-		NDMP_LOG(LOG_DEBUG, "Restoring to \"%s\" aborted.",
+		syslog(LOG_DEBUG, "Restoring to \"%s\" aborted.",
 		    (nlp->nlp_restore_path) ? nlp->nlp_restore_path : "NULL");
 		err = EINTR;
 	} else {
-		NDMP_LOG(LOG_DEBUG, "Restoring to \"%s\" finished. (%d)",
+		syslog(LOG_DEBUG, "Restoring to \"%s\" finished. (%d)",
 		    (nlp->nlp_restore_path) ? nlp->nlp_restore_path :
 		    "NULL", err);
 	}
@@ -3108,7 +3083,7 @@
 
 	if (session->ns_data.dd_operation == NDMP_DATA_OP_RECOVER) {
 		if (nlp->nlp_rsbm < 0) {
-			NDMP_LOG(LOG_DEBUG, "nlp_rsbm < 0 %d", nlp->nlp_rsbm);
+			syslog(LOG_DEBUG, "nlp_rsbm < 0 %d", nlp->nlp_rsbm);
 		} else {
 			(void) bm_free(nlp->nlp_rsbm);
 			nlp->nlp_rsbm = -1;
@@ -3134,7 +3109,6 @@
  *   session (input) - pointer to the session
  *   params (input) - pointer to the parameters structure
  *   nlp (input) - pointer to the nlp structure
- *   jname (input) - job name
  *   dar_index(input) - Index of this entry in the restore list
  *
  * Returns:
@@ -3143,7 +3117,7 @@
  */
 static int
 ndmpd_dar_tar_v3(ndmpd_session_t *session, ndmpd_module_params_t *params,
-    ndmp_lbr_params_t *nlp, char *jname, int dar_index)
+    ndmp_lbr_params_t *nlp, int dar_index)
 {
 	char *excl;
 	char **sels;
@@ -3163,12 +3137,12 @@
 	 * We have to allocate and deallocate buffers every time we
 	 * run the restore, for we need to flush the buffers.
 	 */
-	if (restore_dar_alloc_structs_v3(session, jname) < 0)
+	if (restore_dar_alloc_structs_v3(session) < 0)
 		return (-1);
 
 	sels = setupsels(session, params, nlp, dar_index);
 	if (!sels) {
-		free_dar_structs_v3(session, jname);
+		free_dar_structs_v3(session);
 		return (-1);
 	}
 	excl = NULL;
@@ -3191,7 +3165,7 @@
 		if (err == 0) {
 			tlm_cmd_wait(cmds->tcs_command, TLM_TAR_READER);
 		} else {
-			NDMP_LOG(LOG_DEBUG, "launch ndmp_tar_reader: %m");
+			syslog(LOG_ERR, "launch ndmp_tar_reader failed");
 			return (-1);
 		}
 
@@ -3211,7 +3185,7 @@
 			if ((err = ndmp_pl->np_pre_restore(ndmp_pl, &nctx,
 			    ep->nm3_opath, ep->nm3_dpath))
 			    != 0) {
-				NDMP_LOG(LOG_ERR, "Pre-restore plug-in: %m");
+				syslog(LOG_ERR, "Pre-restore plug-in: %m");
 				ndmp_stop_local_reader(session, cmds);
 				ndmp_wait_for_reader(cmds);
 				(void) pthread_join(rdtp, NULL);
@@ -3225,7 +3199,7 @@
 
 			err = (tm_tar_ops.tm_getdir)(cmds, cmds->tcs_command,
 			    nlp->nlp_jstat, &rn, 1, 1, sels, &excl, flags,
-			    dar_index, nlp->nlp_backup_path,
+			    dar_index, nlp->nlp_mountpoint,
 			    session->hardlink_q);
 			/*
 			 * If the fatal error from tm_getdir looks like an
@@ -3241,7 +3215,7 @@
 
 		cmds->tcs_writer_count--;
 		cmds->tcs_command->tc_ref--;
-		NDMP_LOG(LOG_DEBUG, "stop local reader.");
+		syslog(LOG_DEBUG, "stop local reader.");
 		ndmp_stop_local_reader(session, cmds);
 
 		ndmp_wait_for_reader(cmds);
@@ -3253,7 +3227,7 @@
 		 */
 		if ((data_addr_type == NDMP_ADDR_TCP) &&
 		    (dar_index == (int)session->ns_data.dd_nlist_len)) {
-			NDMP_LOG(LOG_DEBUG, "stop remote reader.");
+			syslog(LOG_DEBUG, "stop remote reader.");
 			ndmp_stop_remote_reader(session);
 		}
 
@@ -3265,7 +3239,7 @@
 		if (ndmp_pl != NULL &&
 		    ndmp_pl->np_post_restore != NULL &&
 		    ndmp_pl->np_post_restore(ndmp_pl, &nctx, err) == -1) {
-			NDMP_LOG(LOG_DEBUG, "Post-restore plug-in: %m");
+			syslog(LOG_DEBUG, "Post-restore plug-in: %m");
 			err = -1;
 		}
 	}
@@ -3272,7 +3246,7 @@
 
 	NDMP_FREE(sels);
 
-	free_dar_structs_v3(session, jname);
+	free_dar_structs_v3(session);
 
 	return (err);
 }
@@ -3304,11 +3278,12 @@
 	for (; ; ) {
 		ret = (*params->mp_seek_func)(session, fh_info, len);
 
-		NDMP_LOG(LOG_DEBUG, "ret %d", ret);
+		syslog(LOG_DEBUG, "ret %d", ret);
 		if (ret == 0) /* Seek was done successfully */
 			break;
 		else if (ret < 0) {
-			NDMP_LOG(LOG_DEBUG, "Seek error");
+			syslog(LOG_ERR,
+			    "Seek error in ndmpd_dar_locate_window_v3");
 			break;
 		}
 
@@ -3369,10 +3344,10 @@
 	for (i = 0; i < n; ++i) {
 		ep = (mem_ndmp_name_v3_t *)MOD_GETNAME(params, i);
 		if (!ep) {
-			NDMP_LOG(LOG_DEBUG, "ep NULL, i %d", i);
+			syslog(LOG_DEBUG, "ep NULL, i %d", i);
 			continue;
 		}
-		NDMP_LOG(LOG_DEBUG,
+		syslog(LOG_DEBUG,
 		    "restoring opath %s, dpath %s, fh_info %lld",
 		    ep->nm3_opath ? ep->nm3_opath : "NULL",
 		    ep->nm3_dpath ? ep->nm3_dpath : "NULL",
@@ -3391,7 +3366,7 @@
 		 * We are inside the target window.
 		 * for each restore we will use one entry as selection list
 		 */
-		if ((ret = ndmpd_dar_tar_v3(session, params, nlp, jname, i+1))
+		if ((ret = ndmpd_dar_tar_v3(session, params, nlp, i+1))
 		    != 0)
 			result = EIO;
 		ndmpd_audit_restore(session->ns_connection,
@@ -3400,7 +3375,7 @@
 		    session->ns_tape.td_adapter_name, result);
 	}
 
-	NDMP_LOG(LOG_DEBUG, "End of restore list");
+	syslog(LOG_DEBUG, "End of restore list");
 
 	(void) ndmpd_dar_tar_end_v3(session, params, nlp, jname);
 
@@ -3458,7 +3433,7 @@
 		return (NULL);
 
 	if ((rv = realpath(bkpath, pbuf)) == NULL) {
-		NDMP_LOG(LOG_DEBUG, "Invalid path [%s] err=%d",
+		syslog(LOG_ERR, "Invalid path [%s] err=%d",
 		    bkpath, errno);
 	}
 	return (rv);
@@ -3506,7 +3481,6 @@
 ndmpd_rs_sar_tar_v3(ndmpd_session_t *session, ndmpd_module_params_t *params,
     ndmp_lbr_params_t *nlp)
 {
-	char jname[TLM_MAX_BACKUP_JOB_NAME];
 	char *excl;
 	char **sels;
 	int flags;
@@ -3519,13 +3493,13 @@
 	ndmp_context_t nctx;
 
 	result = err = 0;
-	(void) ndmp_new_job_name(jname);
-	if (restore_alloc_structs_v3(session, jname) < 0)
-		return (-1);
 
+	if (restore_alloc_structs_v3(session) < 0) {
+		return (-1);
+	}
 	sels = setupsels(session, params, nlp, 0);
 	if (!sels) {
-		free_structs_v3(session, jname);
+		free_structs_v3(session);
 		return (-1);
 	}
 	excl = NULL;
@@ -3542,7 +3516,7 @@
 		cmds->tcs_command->tc_reader = TLM_RESTORE_RUN;
 		cmds->tcs_command->tc_writer = TLM_RESTORE_RUN;
 
-		NDMP_LOG(LOG_DEBUG, "Restoring to \"%s\" started.",
+		syslog(LOG_DEBUG, "Restoring to \"%s\" started.",
 		    (nlp->nlp_restore_path) ? nlp->nlp_restore_path : "NULL");
 
 		arg.tr_session = session;
@@ -3553,15 +3527,15 @@
 		if (err == 0) {
 			tlm_cmd_wait(cmds->tcs_command, TLM_TAR_READER);
 		} else {
-			NDMP_LOG(LOG_DEBUG, "Launch ndmp_tar_reader: %m");
-			free_structs_v3(session, jname);
+			syslog(LOG_ERR, "Launch ndmp_tar_reader failed");
+			free_structs_v3(session);
 			return (-1);
 		}
 
 		if (!ndmp_check_utf8magic(cmds->tcs_command)) {
-			NDMP_LOG(LOG_DEBUG, "UTF8Magic not found!");
+			syslog(LOG_DEBUG, "UTF8Magic not found!");
 		} else {
-			NDMP_LOG(LOG_DEBUG, "UTF8Magic found");
+			syslog(LOG_DEBUG, "UTF8Magic found");
 		}
 
 		/* Plug-in module */
@@ -3574,7 +3548,7 @@
 			if ((err = ndmp_plugin_pre_restore(&nctx, params,
 			    nlp->nlp_nfiles))
 			    != 0) {
-				NDMP_LOG(LOG_ERR, "Pre-restore plug-in: %m");
+				syslog(LOG_ERR, "Pre-restore plug-in: %m");
 				ndmp_stop_local_reader(session, cmds);
 				ndmp_wait_for_reader(cmds);
 				(void) pthread_join(rdtp, NULL);
@@ -3591,7 +3565,7 @@
 
 			err = (tm_tar_ops.tm_getdir)(cmds, cmds->tcs_command,
 			    nlp->nlp_jstat, &rn, 1, 1, sels, &excl, flags, 0,
-			    nlp->nlp_backup_path, session->hardlink_q);
+			    nlp->nlp_mountpoint, session->hardlink_q);
 			/*
 			 * If the fatal error from tm_getdir looks like an
 			 * errno code, we send the error description to DMA.
@@ -3626,7 +3600,7 @@
 
 	(void) send_unrecovered_list_v3(params, nlp); /* nothing restored. */
 	if (session->ns_data.dd_abort) {
-		NDMP_LOG(LOG_DEBUG, "Restoring to \"%s\" aborted.",
+		syslog(LOG_DEBUG, "Restoring to \"%s\" aborted.",
 		    (nlp->nlp_restore_path) ? nlp->nlp_restore_path : "NULL");
 		result = EINTR;
 		ndmpd_audit_restore(session->ns_connection,
@@ -3635,7 +3609,7 @@
 		    session->ns_tape.td_adapter_name, result);
 		err = -1;
 	} else {
-		NDMP_LOG(LOG_DEBUG, "Restoring to \"%s\" finished. (%d)",
+		syslog(LOG_DEBUG, "Restoring to \"%s\" finished. (%d)",
 		    (nlp->nlp_restore_path) ? nlp->nlp_restore_path : "NULL",
 		    err);
 		ndmpd_audit_restore(session->ns_connection,
@@ -3648,13 +3622,13 @@
 		if (ndmp_pl != NULL &&
 		    ndmp_pl->np_post_restore != NULL &&
 		    ndmp_pl->np_post_restore(ndmp_pl, &nctx, err) == -1) {
-			NDMP_LOG(LOG_DEBUG, "Post-restore plug-in: %m");
+			syslog(LOG_DEBUG, "Post-restore plug-in: %m");
 			err = -1;
 		}
 	}
 
 	NDMP_FREE(sels);
-	free_structs_v3(session, jname);
+	free_structs_v3(session);
 
 	return (err);
 }
@@ -3694,21 +3668,49 @@
 		    !is_valid_backup_dir_v3(params, nlp->nlp_backup_path))
 		return (NDMP_ILLEGAL_ARGS_ERR);
 	}
-
 	nlp->nlp_backup_path = get_absolute_path(nlp->nlp_backup_path);
 	if (!nlp->nlp_backup_path)
 		return (NDMP_ILLEGAL_ARGS_ERR);
 
-	if (fs_is_chkpntvol(nlp->nlp_backup_path) ||
-	    fs_is_rdonly(nlp->nlp_backup_path) ||
-	    !fs_is_chkpnt_enabled(nlp->nlp_backup_path))
+	/*
+	 * Assume volume is not checkpointed unless found to be below
+	 */
+	NLP_UNSET(nlp, NLPF_CHKPNTED_PATH);
+
+	/*
+	 * Get the zfs volume name from the backup path and store in
+	 * nlp_vol.
+	 */
+	if (get_zfsvolname(nlp->nlp_vol,
+	    sizeof (nlp->nlp_vol), nlp->nlp_backup_path) == -1) {
+		syslog(LOG_ERR,
+		    "Cannot get volume from [%s] on create",
+		    nlp->nlp_backup_path);
+		NDMP_FREE(nlp->nlp_params);
+		return (-1);
+	}
+
+	/*
+	 * Find out if this data is already checkpointed via. an AutoSync
+	 * or HPR snapshot. If it is, set the flag, and extract the snapshot
+	 * name to use as the nlp_job_name otherwise use the normal
+	 * 'NdmpBackup-nnnn' format.
+	 */
+	if (fs_is_checkpointed(nlp) &&
+	    (ndmp_autosync_support || ndmp_hpr_support)) {
 		NLP_SET(nlp, NLPF_CHKPNTED_PATH);
-	else
-		NLP_UNSET(nlp, NLPF_CHKPNTED_PATH);
+		syslog(LOG_DEBUG, ">>>> Checkpointed dataset found <<<<");
+	}
 
+	(void) ndmp_new_job_name(nlp->nlp_job_name,
+	    sizeof (nlp->nlp_job_name));
+
+	syslog(LOG_DEBUG, "New backup job name [%s]",
+	    nlp->nlp_job_name);
+
 	/* Should the st_ctime be ignored when backing up? */
 	if (ndmp_ignore_ctime) {
-		NDMP_LOG(LOG_DEBUG, "ignoring st_ctime");
+		syslog(LOG_DEBUG, "ignoring st_ctime");
 		NLP_SET(nlp, NLPF_IGNCTIME);
 	} else {
 		NLP_UNSET(nlp, NLPF_IGNCTIME);
@@ -3715,13 +3717,13 @@
 	}
 
 	if (ndmp_include_lmtime == TRUE) {
-		NDMP_LOG(LOG_DEBUG, "including st_lmtime");
+		syslog(LOG_DEBUG, "including st_lmtime");
 		NLP_SET(nlp, NLPF_INCLMTIME);
 	} else {
 		NLP_UNSET(nlp, NLPF_INCLMTIME);
 	}
 
-	NDMP_LOG(LOG_DEBUG, "flags %x", nlp->nlp_flags);
+	syslog(LOG_DEBUG, "flags %x", nlp->nlp_flags);
 
 	get_hist_env_v3(params, nlp);
 	get_exc_env_v3(params, nlp);
@@ -3753,18 +3755,15 @@
 	int err;
 	ndmpd_session_t *session;
 	ndmp_lbr_params_t *nlp;
-	char jname[TLM_MAX_BACKUP_JOB_NAME];
-	ndmp_bkup_size_arg_t sarg;
-	pthread_t tid;
 
 	session = (ndmpd_session_t *)(params->mp_daemon_cookie);
 	*(params->mp_module_cookie) = nlp = ndmp_get_nlp(session);
 	ndmp_session_ref(session);
-	(void) ndmp_new_job_name(jname);
 
+	pthread_cleanup_push(backup_dataset_destroy, nlp);
+
 	err = 0;
-	if (!NLP_ISCHKPNTED(nlp) &&
-	    ndmp_create_snapshot(nlp->nlp_backup_path, jname) < 0) {
+	if (backup_dataset_create(nlp) < 0) {
 		MOD_LOGV3(params, NDMP_LOG_ERROR,
 		    "Creating checkpoint on \"%s\".\n",
 		    nlp->nlp_backup_path);
@@ -3771,34 +3770,24 @@
 		err = -1;
 	}
 
-	NDMP_LOG(LOG_DEBUG, "err %d, chkpnted %c",
-	    err, NDMP_YORN(NLP_ISCHKPNTED(nlp)));
+	syslog(LOG_DEBUG, "BACKUP STARTED [%s]", nlp->nlp_snapname);
 
 	if (err == 0) {
-		sarg.bs_session = session;
-		sarg.bs_jname = jname;
-		sarg.bs_path = nlp->nlp_backup_path;
-
 		/* Get an estimate of the data size */
-		if (pthread_create(&tid, NULL, (funct_t)get_backup_size,
-		    (void *)&sarg) == 0)
-			(void) pthread_detach(tid);
+		(void) get_backup_size(nlp);
 
-		err = ndmp_get_cur_bk_time(nlp, &nlp->nlp_cdate, jname);
+		err = ndmp_get_cur_bk_time(nlp, &nlp->nlp_cdate);
 		if (err != 0) {
-			NDMP_LOG(LOG_DEBUG, "err %d", err);
+			syslog(LOG_ERR,
+			    "Failed to get current backup time %d", err);
 		} else {
 			log_bk_params_v3(session, params, nlp);
-			err = tar_backup_v3(session, params, nlp, jname);
+			err = tar_backup_v3(session, params, nlp);
 		}
 	}
 
-	if (!NLP_ISCHKPNTED(nlp))
-		(void) ndmp_remove_snapshot(nlp->nlp_backup_path, jname);
+	pthread_cleanup_pop(B_TRUE);
 
-	NDMP_LOG(LOG_DEBUG, "err %d, update %c",
-	    err, NDMP_YORN(NLP_SHOULD_UPDATE(nlp)));
-
 	if (err == 0)
 		save_backup_date_v3(params, nlp);
 
@@ -3810,8 +3799,9 @@
 
 	NS_DEC(nbk);
 	ndmp_session_unref(session);
+	syslog(LOG_DEBUG, "BACKUP COMPLETE [%s] (as jobname %s)",
+	    nlp->nlp_snapname, nlp->nlp_job_name);
 	return (err);
-
 }
 
 
@@ -3868,17 +3858,17 @@
 	ndmp_lbr_params_t *nlp;
 
 	if (!(nlp = ndmp_get_nlp(session))) {
-		NDMP_LOG(LOG_DEBUG, "nlp is NULL");
+		syslog(LOG_DEBUG, "nlp is NULL");
 		rv = NDMP_ILLEGAL_ARGS_ERR;
 	} else if (!(nlp->nlp_backup_path = get_backup_path_v3(params)))
 		rv = NDMP_ILLEGAL_ARGS_ERR;
 	else if ((nlp->nlp_nfiles = session->ns_data.dd_nlist_len) == 0) {
-		NDMP_LOG(LOG_DEBUG, "nfiles: %d", nlp->nlp_nfiles);
+		syslog(LOG_DEBUG, "nfiles: %d", nlp->nlp_nfiles);
 		rv = NDMP_ILLEGAL_ARGS_ERR;
 	} else if (get_rs_path_v3(params, nlp) != NDMP_NO_ERR) {
 		rv = NDMP_ILLEGAL_ARGS_ERR;
 	} else if ((rv = fix_nlist_v3(session, params, nlp)) != NDMP_NO_ERR) {
-		NDMP_LOG(LOG_DEBUG, "fix_nlist_v3: %d", rv);
+		syslog(LOG_DEBUG, "fix_nlist_v3: %d", rv);
 	} else {
 		rv = NDMP_NO_ERR;
 		get_direct_env_v3(params, nlp);
@@ -3885,7 +3875,7 @@
 		if (NLP_ISSET(nlp, NLPF_DIRECT)) {
 			if (NLP_ISSET(nlp, NLPF_RECURSIVE)) {
 				/* Currently we dont support DAR on directory */
-				NDMP_LOG(LOG_DEBUG,
+				syslog(LOG_DEBUG,
 				    "Can't have RECURSIVE and DIRECT together");
 				rv = NDMP_ILLEGAL_ARGS_ERR;
 				return (rv);
