summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr/src/cmd/ndmpadm/ndmpadm_print.c6
-rw-r--r--usr/src/cmd/ndmpd/include/tlm.h68
-rw-r--r--usr/src/cmd/ndmpd/ndmp/ndmpd_callbacks.c5
-rw-r--r--usr/src/cmd/ndmpd/ndmp/ndmpd_comm.c3
-rw-r--r--usr/src/cmd/ndmpd/ndmp/ndmpd_config.c38
-rw-r--r--usr/src/cmd/ndmpd/ndmp/ndmpd_connect.c2
-rw-r--r--usr/src/cmd/ndmpd/ndmp/ndmpd_data.c8
-rw-r--r--usr/src/cmd/ndmpd/ndmp/ndmpd_mover.c2
-rw-r--r--usr/src/cmd/ndmpd/ndmp/ndmpd_tar3.c68
-rw-r--r--usr/src/cmd/ndmpd/tlm/tlm_backup_reader.c12
-rw-r--r--usr/src/cmd/ndmpd/tlm/tlm_init.c124
-rw-r--r--usr/src/cmd/ndmpd/tlm/tlm_restore_writer.c6
-rw-r--r--usr/src/lib/libndmp/common/libndmp.c2
-rw-r--r--usr/src/lib/libndmp/common/libndmp.h2
14 files changed, 278 insertions, 68 deletions
diff --git a/usr/src/cmd/ndmpadm/ndmpadm_print.c b/usr/src/cmd/ndmpadm/ndmpadm_print.c
index d5ffc62277..3e558ec415 100644
--- a/usr/src/cmd/ndmpadm/ndmpadm_print.c
+++ b/usr/src/cmd/ndmpadm/ndmpadm_print.c
@@ -798,6 +798,12 @@ ndmp_devinfo_print(ndmp_devinfo_t *dip, size_t size)
if (dip->nd_revision)
(void) fprintf(stdout,
gettext("\tRevision : %s\n"), dip->nd_revision);
+ if (dip->nd_serial)
+ (void) fprintf(stdout,
+ gettext("\tSerial : %s\n"), dip->nd_serial);
+ if (dip->nd_wwn)
+ (void) fprintf(stdout,
+ gettext("\tWWN : %s\n"), dip->nd_wwn);
(void) fprintf(stdout, "\n");
}
}
diff --git a/usr/src/cmd/ndmpd/include/tlm.h b/usr/src/cmd/ndmpd/include/tlm.h
index bd073edecc..349fd63d88 100644
--- a/usr/src/cmd/ndmpd/include/tlm.h
+++ b/usr/src/cmd/ndmpd/include/tlm.h
@@ -90,10 +90,17 @@
#define TLM_TAR_READER 0x00000040
#define TLM_TAR_WRITER 0x00000080
-#define SCMD_READ_ELEMENT_STATUS 0xB8
+#define SCSI_SERIAL_PAGE 0x80
+#define SCSI_DEVICE_IDENT_PAGE 0x83
+#define SCMD_READ_ELEMENT_STATUS 0xB8
typedef int (*func_t)();
+typedef struct scsi_serial {
+ int sr_flags;
+ char sr_num[16];
+} scsi_serial_t;
+
typedef struct fs_fhandle {
int fh_fid;
char *fh_fpath;
@@ -122,6 +129,8 @@ typedef struct sasd_drive {
char sd_vendor[8 + 1];
char sd_id[16 + 1];
char sd_rev[4 + 1];
+ char sd_serial[16 + 1];
+ char sd_wwn[32 + 1];
} sasd_drive_t;
typedef struct scsi_sasd_drive {
@@ -206,6 +215,63 @@ typedef struct tlm_library {
tlm_slot_t *tl_slot;
} tlm_library_t;
+typedef struct {
+ unsigned char d_name[8];
+} device_info_t;
+
+typedef struct {
+ unsigned char p_number[4];
+} port_info_t;
+
+typedef struct {
+#ifdef _BIG_ENDIAN
+ uint8_t di_peripheral_qual : 3,
+ di_peripheral_dev_type : 5;
+ uint8_t di_page_code;
+ uint16_t di_page_length;
+#else
+ uint8_t di_peripheral_dev_type : 5,
+ di_peripheral_qual : 3;
+ uint8_t di_page_code;
+ uint16_t di_page_length;
+#endif
+} device_ident_header_t;
+
+typedef struct {
+#ifdef _BIG_ENDIAN
+ uint8_t ni_proto_ident : 4,
+ ni_code_set : 4;
+
+ uint8_t ni_PIV : 1,
+ : 1,
+ ni_asso : 2,
+ ni_ident_type : 4;
+
+ uint8_t ni_reserved;
+ uint8_t ni_ident_length;
+#else
+ uint8_t ni_code_set : 4,
+ ni_proto_ident : 4;
+
+ uint8_t ni_ident_type : 4,
+ ni_asso : 2,
+ : 1,
+ ni_PIV : 1;
+ uint8_t ni_reserved;
+ uint8_t ni_ident_length;
+#endif
+} name_ident_t;
+
+typedef struct {
+ device_ident_header_t np_header;
+ name_ident_t np_node;
+ device_info_t np_node_info;
+ name_ident_t np_port;
+ device_info_t np_port_info;
+ name_ident_t np_portno;
+ port_info_t np_portid;
+} device_name_page_t;
+
#define TLM_NO_ERRORS 0x00000000
#define TLM_ERROR_BUSY 0x00000001
#define TLM_ERROR_INTERNAL 0x00000002
diff --git a/usr/src/cmd/ndmpd/ndmp/ndmpd_callbacks.c b/usr/src/cmd/ndmpd/ndmp/ndmpd_callbacks.c
index e2b6f8d54f..a750ad756f 100644
--- a/usr/src/cmd/ndmpd/ndmp/ndmpd_callbacks.c
+++ b/usr/src/cmd/ndmpd/ndmp/ndmpd_callbacks.c
@@ -271,9 +271,10 @@ ndmpd_api_seek_v2(void *cookie, u_longlong_t offset, u_longlong_t length)
request.offset = long_long_to_quad(offset);
request.length = long_long_to_quad(length);
- if (ndmp_send_request(session->ns_connection,
+ if (ndmp_send_request_lock(session->ns_connection,
NDMP_NOTIFY_DATA_READ, NDMP_NO_ERR,
(void *)&request, 0) < 0) {
+
NDMP_LOG(LOG_DEBUG,
"Sending notify_data_read request");
return (-1);
@@ -698,7 +699,7 @@ ndmpd_api_seek_v3(void *cookie, u_longlong_t offset, u_longlong_t length)
request.offset = long_long_to_quad(offset);
request.length = long_long_to_quad(length);
- if (ndmp_send_request(session->ns_connection,
+ if (ndmp_send_request_lock(session->ns_connection,
NDMP_NOTIFY_DATA_READ, NDMP_NO_ERR,
(void *)&request, 0) < 0) {
NDMP_LOG(LOG_DEBUG,
diff --git a/usr/src/cmd/ndmpd/ndmp/ndmpd_comm.c b/usr/src/cmd/ndmpd/ndmp/ndmpd_comm.c
index eb3f839124..f8dca7dcd4 100644
--- a/usr/src/cmd/ndmpd/ndmp/ndmpd_comm.c
+++ b/usr/src/cmd/ndmpd/ndmp/ndmpd_comm.c
@@ -882,7 +882,7 @@ connection_handler(ndmp_connection_t *connection)
req.protocol_version = ndmp_ver;
req.text_reason = "";
- if (ndmp_send_request(connection, NDMP_NOTIFY_CONNECTION_STATUS,
+ if (ndmp_send_request_lock(connection, NDMP_NOTIFY_CONNECTION_STATUS,
NDMP_NO_ERR, (void *)&req, 0) < 0) {
NDMP_LOG(LOG_DEBUG, "Connection terminated");
return;
@@ -971,7 +971,6 @@ connection_file_handler(void *cookie, int fd, ulong_t mode)
/* ************* private functions *************************************** */
-
/*
* ndmp_readit
*
diff --git a/usr/src/cmd/ndmpd/ndmp/ndmpd_config.c b/usr/src/cmd/ndmpd/ndmp/ndmpd_config.c
index 763ff5074e..751d798f28 100644
--- a/usr/src/cmd/ndmpd/ndmp/ndmpd_config.c
+++ b/usr/src/cmd/ndmpd/ndmp/ndmpd_config.c
@@ -664,17 +664,19 @@ ndmpd_config_get_tape_info_v3(ndmp_connection_t *connection, void *body)
int i, n, max;
sasd_drive_t *sd;
scsi_link_t *sl;
- ndmp_pval env;
- ndmp_pval *envp = &env;
+ ndmp_pval *envp, *envp_save = NULL;
+ ndmp_pval *envp_head;
(void) memset((void*)&reply, 0, sizeof (reply));
max = sasd_dev_count();
tip_save = tip = ndmp_malloc(sizeof (ndmp_device_info_v3) * max);
dcp_save = dcp = ndmp_malloc(sizeof (ndmp_device_capability_v3) * max);
- if (!tip_save || !dcp_save) {
+ envp_save = envp = ndmp_malloc(sizeof (ndmp_pval) * max * 3);
+ if (!tip_save || !dcp_save || !envp_save) {
free(tip_save);
free(dcp_save);
+ free(envp_save);
reply.error = NDMP_NO_MEM_ERR;
ndmp_send_reply(connection, (void *)&reply,
"error sending ndmp_config_get_tape_info reply");
@@ -682,7 +684,6 @@ ndmpd_config_get_tape_info_v3(ndmp_connection_t *connection, void *body)
}
reply.error = NDMP_NO_ERR;
- NDMP_SETENV(envp, "EXECUTE_CDB", "b");
for (i = n = 0; i < max; i++) {
if (!(sl = sasd_dev_slink(i)) || !(sd = sasd_drive(i)))
@@ -693,13 +694,18 @@ ndmpd_config_get_tape_info_v3(ndmp_connection_t *connection, void *body)
NDMP_LOG(LOG_DEBUG,
"model \"%s\" dev \"%s\"", sd->sd_id, sd->sd_name);
+ envp_head = envp;
+ NDMP_SETENV(envp, "EXECUTE_CDB", "b");
+ NDMP_SETENV(envp, "SERIAL_NUMBER", sd->sd_serial);
+ NDMP_SETENV(envp, "WORLD_WIDE_NAME", sd->sd_wwn);
+
tip->model = sd->sd_id; /* like "DLT7000 " */
tip->caplist.caplist_len = 1;
tip->caplist.caplist_val = dcp;
dcp->device = sd->sd_name; /* like "isp1t060" */
dcp->attr = 0;
- dcp->capability.capability_len = 1;
- dcp->capability.capability_val = &env;
+ dcp->capability.capability_len = 3;
+ dcp->capability.capability_val = envp_head;
tip++;
dcp++;
n++;
@@ -716,7 +722,7 @@ ndmpd_config_get_tape_info_v3(ndmp_connection_t *connection, void *body)
reply.error = NDMP_NO_DEVICE_ERR;
ndmp_send_reply(connection, (void *)&reply,
"error sending ndmp_config_get_tape_info reply");
- free(tip_save); free(dcp_save);
+ free(tip_save); free(dcp_save); free(envp_save);
return;
}
@@ -729,6 +735,7 @@ ndmpd_config_get_tape_info_v3(ndmp_connection_t *connection, void *body)
free(tip_save);
free(dcp_save);
+ free(envp_save);
}
@@ -756,17 +763,21 @@ ndmpd_config_get_scsi_info_v3(ndmp_connection_t *connection, void *body)
int i, n, max;
sasd_drive_t *sd;
scsi_link_t *sl;
+ ndmp_pval *envp, *envp_save = NULL;
+ ndmp_pval *envp_head;
(void) memset((void*)&reply, 0, sizeof (reply));
max = sasd_dev_count();
sip_save = sip = ndmp_malloc(sizeof (ndmp_device_info_v3) * max);
dcp_save = dcp = ndmp_malloc(sizeof (ndmp_device_capability_v3) * max);
- if (!sip_save || !dcp_save) {
+ envp_save = envp = ndmp_malloc(sizeof (ndmp_pval) * max * 2);
+ if (!sip_save || !dcp_save || !envp_save) {
free(sip_save);
free(dcp_save);
+ free(envp_save);
reply.error = NDMP_NO_MEM_ERR;
ndmp_send_reply(connection, (void *)&reply,
- "error sending ndmp_config_get_tape_info reply");
+ "error sending ndmp_config_get_scsi_info reply");
return;
}
@@ -780,14 +791,18 @@ ndmpd_config_get_scsi_info_v3(ndmp_connection_t *connection, void *body)
NDMP_LOG(LOG_DEBUG,
"model \"%s\" dev \"%s\"", sd->sd_id, sd->sd_name);
+ envp_head = envp;
+ NDMP_SETENV(envp, "SERIAL_NUMBER", sd->sd_serial);
+ NDMP_SETENV(envp, "WORLD_WIDE_NAME", sd->sd_wwn);
+
sip->model = sd->sd_id; /* like "Powerstor L200 " */
sip->caplist.caplist_len = 1;
sip->caplist.caplist_val = dcp;
dcp->device = sd->sd_name; /* like "isp1m000" */
dcp->attr = 0;
- dcp->capability.capability_len = 0;
- dcp->capability.capability_val = NULL;
+ dcp->capability.capability_len = 2;
+ dcp->capability.capability_val = envp_head;
sip++;
dcp++;
n++;
@@ -803,6 +818,7 @@ ndmpd_config_get_scsi_info_v3(ndmp_connection_t *connection, void *body)
free(sip_save);
free(dcp_save);
+ free(envp_save);
}
diff --git a/usr/src/cmd/ndmpd/ndmp/ndmpd_connect.c b/usr/src/cmd/ndmpd/ndmp/ndmpd_connect.c
index c48b65dfd4..6a84b387b7 100644
--- a/usr/src/cmd/ndmpd/ndmp/ndmpd_connect.c
+++ b/usr/src/cmd/ndmpd/ndmp/ndmpd_connect.c
@@ -1140,6 +1140,8 @@ ndmpd_get_devs(ndmp_door_ctx_t *enc_ctx)
ndmp_door_put_string(enc_ctx, sd->sd_vendor);
ndmp_door_put_string(enc_ctx, sd->sd_id);
ndmp_door_put_string(enc_ctx, sd->sd_rev);
+ ndmp_door_put_string(enc_ctx, sd->sd_serial);
+ ndmp_door_put_string(enc_ctx, sd->sd_wwn);
}
}
diff --git a/usr/src/cmd/ndmpd/ndmp/ndmpd_data.c b/usr/src/cmd/ndmpd/ndmp/ndmpd_data.c
index 1ecabceaac..9b471e469a 100644
--- a/usr/src/cmd/ndmpd/ndmp/ndmpd_data.c
+++ b/usr/src/cmd/ndmpd/ndmp/ndmpd_data.c
@@ -38,7 +38,6 @@
*/
/* Copyright (c) 2007, The Storage Networking Industry Association. */
/* Copyright (c) 1996, 1997 PDC, Network Appliance. All Rights Reserved */
-
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
@@ -50,7 +49,6 @@
#include "ndmpd_common.h"
#include "ndmpd.h"
-
static int ndmpd_data_error_send_v4(ndmpd_session_t *session,
ndmp_data_halt_reason reason);
static int ndmpd_data_error_send(ndmpd_session_t *session,
@@ -1592,8 +1590,6 @@ discard_data_v3(ndmpd_session_t *session, ulong_t length)
toread = (length < MAX_RECORD_SIZE) ? length :
MAX_RECORD_SIZE;
- NDMP_LOG(LOG_DEBUG, "discard data, length = %u", length);
-
/* Read and discard the data. */
n = read(session->ns_data.dd_sock, buf, toread);
if (n < 0) {
@@ -1691,7 +1687,7 @@ ndmpd_remote_read_v3(ndmpd_session_t *session, char *data, ulong_t length)
session->ns_data.dd_read_offset,
session->ns_data.dd_read_length);
- if (ndmp_send_request(session->ns_connection,
+ if (ndmp_send_request_lock(session->ns_connection,
NDMP_NOTIFY_DATA_READ, NDMP_NO_ERR,
&request, 0) < 0) {
NDMP_LOG(LOG_DEBUG,
@@ -1738,11 +1734,9 @@ ndmpd_remote_read_v3(ndmpd_session_t *session, char *data, ulong_t length)
session->ns_data.dd_bytes_left_to_read -= n;
session->ns_data.dd_position += n;
}
-
return (0);
}
-
/*
* nlp_release_job_stat
*
diff --git a/usr/src/cmd/ndmpd/ndmp/ndmpd_mover.c b/usr/src/cmd/ndmpd/ndmp/ndmpd_mover.c
index 02c252a90b..da9af110f8 100644
--- a/usr/src/cmd/ndmpd/ndmp/ndmpd_mover.c
+++ b/usr/src/cmd/ndmpd/ndmp/ndmpd_mover.c
@@ -1784,7 +1784,7 @@ ndmpd_remote_read(ndmpd_session_t *session, char *data, ulong_t length)
request.length =
long_long_to_quad(session->ns_data.dd_read_length);
- if (ndmp_send_request(session->ns_connection,
+ if (ndmp_send_request_lock(session->ns_connection,
NDMP_NOTIFY_DATA_READ, NDMP_NO_ERR,
(void *) &request, 0) < 0) {
NDMP_LOG(LOG_DEBUG,
diff --git a/usr/src/cmd/ndmpd/ndmp/ndmpd_tar3.c b/usr/src/cmd/ndmpd/ndmp/ndmpd_tar3.c
index d2a79deec5..57db92cb5c 100644
--- a/usr/src/cmd/ndmpd/ndmp/ndmpd_tar3.c
+++ b/usr/src/cmd/ndmpd/ndmp/ndmpd_tar3.c
@@ -1705,8 +1705,12 @@ backup_dirv3(bk_param_v3_t *bpp, fst_node_t *pnp,
bpos = tlm_get_data_offset(bpp->bp_lcmd);
p = bpp->bp_tmp + strlen(bpp->bp_chkpnm);
- (void) snprintf(fullpath, TLM_MAX_PATH_NAME, "%s/%s",
- bpp->bp_unchkpnm, p);
+ if (*p == '/')
+ (void) snprintf(fullpath, TLM_MAX_PATH_NAME, "%s%s",
+ bpp->bp_unchkpnm, p);
+ else
+ (void) snprintf(fullpath, TLM_MAX_PATH_NAME, "%s/%s",
+ bpp->bp_unchkpnm, p);
if (tm_tar_ops.tm_putdir != NULL)
(void) (tm_tar_ops.tm_putdir)(fullpath, bpp->bp_tlmacl,
@@ -1780,8 +1784,12 @@ backup_filev3(bk_param_v3_t *bpp, fst_node_t *pnp,
ent = enp->tn_path ? enp->tn_path : "";
p = pnp->tn_path + strlen(bpp->bp_chkpnm);
- (void) snprintf(fullpath, TLM_MAX_PATH_NAME, "%s/%s",
- bpp->bp_unchkpnm, p);
+ if (*p == '/')
+ (void) snprintf(fullpath, TLM_MAX_PATH_NAME, "%s%s",
+ bpp->bp_unchkpnm, p);
+ else
+ (void) snprintf(fullpath, TLM_MAX_PATH_NAME, "%s/%s",
+ bpp->bp_unchkpnm, p);
if (tm_tar_ops.tm_putfile != NULL)
rv = (tm_tar_ops.tm_putfile)(fullpath, ent, pnp->tn_path,
@@ -3156,6 +3164,7 @@ ndmpd_dar_tar_v3(ndmpd_session_t *session, ndmpd_module_params_t *params,
ndmp_tar_reader_arg_t arg;
pthread_t rdtp;
ndmp_context_t nctx;
+ mem_ndmp_name_v3_t *ep;
err = 0;
@@ -3202,8 +3211,11 @@ ndmpd_dar_tar_v3(ndmpd_session_t *session, ndmpd_module_params_t *params,
if (ndmp_pl != NULL &&
ndmp_pl->np_pre_restore != NULL) {
nctx.nc_cmds = cmds;
+ ep = (mem_ndmp_name_v3_t *)MOD_GETNAME(params,
+ dar_index - 1);
+
if ((err = ndmp_pl->np_pre_restore(ndmp_pl, &nctx,
- nlp->nlp_backup_path, nlp->nlp_restore_path))
+ ep->nm3_opath, ep->nm3_dpath))
!= 0) {
NDMP_LOG(LOG_DEBUG, "Pre-restore plug-in: %m");
cmds->tcs_command->tc_reader = TLM_STOP;
@@ -3282,8 +3294,9 @@ restore_out:
* 0: on success
* -1: on error
*/
-static int ndmpd_dar_locate_window_v3(ndmpd_session_t *session,
- ndmpd_module_params_t *params, u_longlong_t fh_info, long len)
+static int
+ndmpd_dar_locate_window_v3(ndmpd_session_t *session,
+ ndmpd_module_params_t *params, u_longlong_t fh_info, u_longlong_t len)
{
int ret = 0;
@@ -3395,45 +3408,26 @@ ndmpd_rs_dar_tar_v3(ndmpd_session_t *session, ndmpd_module_params_t *params,
}
/*
- * ndmp_get_next_path
- *
- * Get the next path from a comma-separated path list
- */
-static int
-ndmp_get_next_path(char **p, char *buf)
-{
- int len;
-
- if (!*p || !**p)
- return (0);
-
- while (isspace((unsigned char)**p))
- (*p)++;
- len = strcspn(*p, ",");
- (void) strlcpy(buf, *p, len + 1);
- (*p) += len;
- if (**p == ',')
- (*p)++;
- return (len);
-}
-
-/*
* ndmp_plugin_pre_restore
*
* Wrapper for pre-restore callback with multiple path
*/
static int
-ndmp_plugin_pre_restore(ndmp_context_t *ctxp, char *orig_path, char *path)
+ndmp_plugin_pre_restore(ndmp_context_t *ctxp, ndmpd_module_params_t *params,
+ int ncount)
{
- char buf[PATH_MAX];
- char *p = path;
+ mem_ndmp_name_v3_t *ep;
int err;
+ int i;
- while (ndmp_get_next_path(&p, buf) != 0) {
+ for (i = 0; i < ncount; i++) {
+ if (!(ep = (mem_ndmp_name_v3_t *)MOD_GETNAME(params, i)))
+ continue;
if ((err = ndmp_pl->np_pre_restore(ndmp_pl, ctxp,
- orig_path, buf)) != 0)
+ ep->nm3_opath, ep->nm3_dpath)) != 0)
return (err);
}
+
return (0);
}
@@ -3519,8 +3513,8 @@ ndmpd_rs_sar_tar_v3(ndmpd_session_t *session, ndmpd_module_params_t *params,
if (ndmp_pl != NULL &&
ndmp_pl->np_pre_restore != NULL) {
nctx.nc_cmds = cmds;
- if ((err = ndmp_plugin_pre_restore(&nctx,
- nlp->nlp_backup_path, nlp->nlp_restore_path))
+ if ((err = ndmp_plugin_pre_restore(&nctx, params,
+ nlp->nlp_nfiles))
!= 0) {
NDMP_LOG(LOG_DEBUG, "Pre-restore plug-in: %m");
cmds->tcs_command->tc_reader = TLM_STOP;
diff --git a/usr/src/cmd/ndmpd/tlm/tlm_backup_reader.c b/usr/src/cmd/ndmpd/tlm/tlm_backup_reader.c
index d448c17868..fe9aabea9f 100644
--- a/usr/src/cmd/ndmpd/tlm/tlm_backup_reader.c
+++ b/usr/src/cmd/ndmpd/tlm/tlm_backup_reader.c
@@ -475,7 +475,7 @@ output_file_header(char *name, char *link,
tar_hdr->th_linkflag = LF_LINK;
(void) snprintf(tar_hdr->th_shared.th_hlink_ino,
sizeof (tar_hdr->th_shared.th_hlink_ino),
- "%011o ", attr->st_ino);
+ "%011llo ", attr->st_ino);
} else {
tar_hdr->th_linkflag = *link == 0 ? LF_NORMAL : LF_SYMLINK;
NDMP_LOG(LOG_DEBUG, "linkflag: '%c'", tar_hdr->th_linkflag);
@@ -817,7 +817,7 @@ tlm_output_file(char *dir, char *name, char *chkdir,
goto err_out;
}
} else {
- NDMP_LOG(LOG_DEBUG, "found hardlink, inode = %u, pos = %10lld ",
+ NDMP_LOG(LOG_DEBUG, "found hardlink, inode = %llu, pos = %llu ",
tlm_acls->acl_attr.st_ino, hardlink_pos);
fd = -1;
@@ -941,19 +941,17 @@ tlm_output_file(char *dir, char *name, char *chkdir,
(void) hardlink_q_add(hardlink_q, tlm_acls->acl_attr.st_ino,
pos, NULL, 0);
NDMP_LOG(LOG_DEBUG,
- "backed up hardlink file %s, inode = %u, pos = %10lld ",
+ "backed up hardlink file %s, inode = %llu, pos = %llu ",
fullname, tlm_acls->acl_attr.st_ino, pos);
}
/*
* For hardlink, if other link belonging to the same inode has been
- * backed up, send the offset of the data records for that link.
+ * backed up, no add_node entry should be sent for this link.
*/
if (hardlink_done) {
- (void) tlm_log_fhnode(job_stats, dir, name,
- &tlm_acls->acl_attr, hardlink_pos);
NDMP_LOG(LOG_DEBUG,
- "backed up hardlink link %s, inode = %u, pos = %10lld ",
+ "backed up hardlink link %s, inode = %llu, pos = %llu ",
fullname, tlm_acls->acl_attr.st_ino, hardlink_pos);
} else {
(void) tlm_log_fhnode(job_stats, dir, name,
diff --git a/usr/src/cmd/ndmpd/tlm/tlm_init.c b/usr/src/cmd/ndmpd/tlm/tlm_init.c
index 31f7a674f5..f4bb425930 100644
--- a/usr/src/cmd/ndmpd/tlm/tlm_init.c
+++ b/usr/src/cmd/ndmpd/tlm/tlm_init.c
@@ -111,6 +111,121 @@ read_inquiry_page(scsi_link_t *slink, struct scsi_inquiry *inq)
}
/*
+ * Read the Product Data Page.
+ */
+static int
+read_data_page(scsi_link_t *slink, int pcode, char *snum, int size)
+{
+ char cmd[CDB_GROUP0];
+
+ (void) memset(cmd, 0, sizeof (cmd));
+
+ cmd[0] = SCMD_INQUIRY;
+ cmd[1] = pcode ? 0x01 : 0x00;
+ cmd[2] = pcode;
+ cmd[4] = size;
+
+ /* LINTED improper alignment */
+ return (read_scsi_page(slink, (union scsi_cdb *)&cmd, CDB_GROUP0,
+ (caddr_t)snum, size) == -1 ? -1 : 0);
+}
+
+
+/*
+ * Read the Serial Number Page.
+ */
+static int
+read_serial_num_page(scsi_link_t *slink, char *snum, int size)
+{
+ scsi_serial_t serial;
+ int rv;
+
+ (void) memset(&serial, 0, sizeof (scsi_serial_t));
+ rv = read_data_page(slink, SCSI_SERIAL_PAGE, (caddr_t)&serial,
+ sizeof (scsi_serial_t));
+ (void) strlcpy(snum, serial.sr_num, size);
+
+ return (rv == -1 ? -1 : 0);
+}
+
+
+/*
+ * Read the Device Name Page.
+ */
+static int
+read_dev_name_page(scsi_link_t *slink, device_name_page_t *devp)
+{
+ (void) memset(devp, 0, sizeof (device_name_page_t));
+
+ if (read_data_page(slink, SCSI_DEVICE_IDENT_PAGE, (caddr_t)devp,
+ sizeof (device_name_page_t)) == -1)
+ return (-1);
+
+ if (devp->np_header.di_page_code == SCSI_DEVICE_IDENT_PAGE &&
+ devp->np_node.ni_code_set == 1 &&
+ devp->np_node.ni_ident_type == 3 &&
+ devp->np_node.ni_ident_length == 8)
+ return (0);
+
+ if (devp->np_header.di_page_code == SCSI_DEVICE_IDENT_PAGE)
+ return (0);
+
+ return (-1);
+}
+
+/*
+ * Formatted print of WWN
+ */
+char *
+snprintf_wwn(char *buf, int size, uint8_t *wwn)
+{
+ if (wwn == NULL || buf == NULL)
+ return (0);
+
+ (void) snprintf(buf, size, "0x%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X%2.2X",
+ wwn[0], wwn[1], wwn[2], wwn[3], wwn[4], wwn[5], wwn[6], wwn[7]);
+ return (buf);
+}
+
+
+/*
+ * Extract and print the world wide name (WWN)
+ */
+int
+read_device_wwn(scsi_link_t *slink, char *wwnp, int wsize)
+{
+ device_name_page_t dinfo;
+
+ (void) memset(wwnp, 0, wsize);
+ if (read_dev_name_page(slink, &dinfo) == -1)
+ return (-1);
+
+ if (dinfo.np_port.ni_code_set == 1 &&
+ dinfo.np_port.ni_ident_type == 3) {
+ (void) snprintf_wwn(wwnp, wsize, dinfo.np_port_info.d_name);
+ return (0);
+ }
+ if (dinfo.np_node.ni_code_set == 1 &&
+ dinfo.np_node.ni_ident_type == 3) {
+ (void) snprintf_wwn(wwnp, wsize, dinfo.np_node_info.d_name);
+ return (0);
+ }
+ if (dinfo.np_port.ni_code_set == 2 &&
+ dinfo.np_port.ni_ident_type == 1) {
+ (void) snprintf(wwnp, wsize, "%.*s",
+ dinfo.np_port.ni_ident_length, dinfo.np_port_info.d_name);
+ return (0);
+ }
+ if (dinfo.np_node.ni_code_set == 2 &&
+ dinfo.np_node.ni_ident_type == 1) {
+ (void) snprintf(wwnp, wsize, "%.*s",
+ dinfo.np_node.ni_ident_length, dinfo.np_node_info.d_name);
+ return (0);
+ }
+ return (-1);
+}
+
+/*
* Add the tape library call back function (used while scanning the bus)
*/
static int
@@ -143,6 +258,10 @@ add_lib(scsi_link_t *slink, struct scsi_inquiry *sd, void *arg)
sizeof (ssd->sd_id));
(void) strlcpy(ssd->sd_rev, sd->inq_revision,
sizeof (ssd->sd_rev));
+ (void) read_serial_num_page(slink, ssd->sd_serial,
+ sizeof (ssd->sd_serial));
+ (void) read_device_wwn(slink, ssd->sd_wwn,
+ sizeof (ssd->sd_wwn));
}
}
@@ -241,6 +360,7 @@ new_drive(scsi_link_t *slink, int *lib)
return (0);
}
+
/*
* Add the tape library call back function (used while scanning the bus)
*/
@@ -295,6 +415,10 @@ add_drv(scsi_link_t *slink, struct scsi_inquiry *sd, void *arg)
sizeof (ssd->sd_id));
(void) strlcpy(ssd->sd_rev, sd->inq_revision,
sizeof (ssd->sd_rev));
+ (void) read_serial_num_page(slink, ssd->sd_serial,
+ sizeof (ssd->sd_serial));
+ (void) read_device_wwn(slink, ssd->sd_wwn,
+ sizeof (ssd->sd_wwn));
}
}
diff --git a/usr/src/cmd/ndmpd/tlm/tlm_restore_writer.c b/usr/src/cmd/ndmpd/tlm/tlm_restore_writer.c
index e04fa715cc..8733166c25 100644
--- a/usr/src/cmd/ndmpd/tlm/tlm_restore_writer.c
+++ b/usr/src/cmd/ndmpd/tlm/tlm_restore_writer.c
@@ -386,6 +386,12 @@ tar_getdir(tlm_commands_t *commands,
} else {
tar_hdr = (tlm_tar_hdr_t *)get_read_buffer(want,
&erc, &actual_size, local_commands);
+
+ if (tar_hdr == NULL) {
+ rv = -1;
+ continue;
+ }
+
/*
* we can ignore read errors here because
* 1) they are logged by Restore Reader
diff --git a/usr/src/lib/libndmp/common/libndmp.c b/usr/src/lib/libndmp/common/libndmp.c
index 997d4d85a9..c063f06fc3 100644
--- a/usr/src/lib/libndmp/common/libndmp.c
+++ b/usr/src/lib/libndmp/common/libndmp.c
@@ -90,6 +90,8 @@ ndmp_get_devinfo(ndmp_devinfo_t **dip, size_t *size)
dipptr->nd_vendor = ndmp_door_get_string(dec_ctx);
dipptr->nd_product = ndmp_door_get_string(dec_ctx);
dipptr->nd_revision = ndmp_door_get_string(dec_ctx);
+ dipptr->nd_serial = ndmp_door_get_string(dec_ctx);
+ dipptr->nd_wwn = ndmp_door_get_string(dec_ctx);
}
if (ndmp_door_fini()) {
free(*dip);
diff --git a/usr/src/lib/libndmp/common/libndmp.h b/usr/src/lib/libndmp/common/libndmp.h
index 4e1b2c246d..026df5bac0 100644
--- a/usr/src/lib/libndmp/common/libndmp.h
+++ b/usr/src/lib/libndmp/common/libndmp.h
@@ -189,6 +189,8 @@ typedef struct ndmp_devinfo {
char *nd_vendor; /* Vendor name */
char *nd_product; /* Product name */
char *nd_revision; /* Revision */
+ char *nd_serial; /* Serial */
+ char *nd_wwn; /* World wide name */
} ndmp_devinfo_t;
/* Scsi device info sturcture */