Print this page
NEX-14898 Null message (cfga_msg: NULL msgp) printed for sata devices with cfgadm
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Cynthia Eastham <cynthia.eastham@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
@@ -19,10 +19,11 @@
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/param.h>
#include <sys/stat.h>
@@ -712,11 +713,11 @@
}
free(msg);
devpath = sata_get_devicepath(ap_id);
if (devpath == NULL) {
- (void) printf(
+ DPRINTF(
"cfga_change_state: get device path failed\n");
rv = CFGA_SATA_DEV_UNCONFIGURE;
break;
}
@@ -769,11 +770,11 @@
/* only call rcm_offline if the state was CONFIGURED */
if (ostate == AP_OSTATE_CONFIGURED &&
pmult == B_FALSE) {
devpath = sata_get_devicepath(ap_id);
if (devpath == NULL) {
- (void) printf(
+ DPRINTF(
"cfga_change_state: get path failed\n");
rv = CFGA_SATA_DEV_UNCONFIGURE;
break;
}
@@ -944,11 +945,11 @@
rv = CFGA_SATA_PRIV;
goto bailout;
}
if (func == NULL) {
- (void) printf("No valid option specified\n");
+ DPRINTF("No valid option specified\n");
rv = CFGA_SATA_OPTIONS;
goto bailout;
}
if ((rv = setup_for_devctl_cmd(ap_id, &hdl, &list, 0)) !=
@@ -1255,11 +1256,11 @@
* Get target node path
*/
devpath = sata_get_devicepath(ap_id);
if (devpath == NULL) {
- (void) printf("cfga_list_ext: cannot locate target device\n");
+ DPRINTF("cfga_list_ext: cannot locate target device\n");
return (CFGA_SATA_DYNAMIC_AP);
} else {
cp = strrchr(devpath, *PATH_SEP);
@@ -1571,11 +1572,11 @@
* Fill in the 'Information' field for the -v option
* Model (MOD:)
*/
if ((rv = do_control_ioctl(ap_id, SATA_CFGA_GET_MODEL_INFO,
NULL, (void **)&str_p, &size)) != CFGA_SATA_OK) {
- (void) printf(
+ DPRINTF(
"SATA_CFGA_GET_MODULE_INFO ioctl failed\n");
goto bailout;
}
/* drop leading and trailing spaces */
skip = strspn(str_p, " ");
@@ -1598,11 +1599,11 @@
* Firmware revision (FREV:)
*/
if ((rv = do_control_ioctl(ap_id,
SATA_CFGA_GET_REVFIRMWARE_INFO,
NULL, (void **)&str_p, &size)) != CFGA_SATA_OK) {
- (void) printf(
+ DPRINTF(
"SATA_CFGA_GET_REVFIRMWARE_INFO ioctl failed\n");
goto bailout;
}
/* drop leading and trailing spaces */
skip = strspn(str_p, " ");
@@ -1625,11 +1626,11 @@
* Serial Number (SN:)
*/
if ((rv = do_control_ioctl(ap_id,
SATA_CFGA_GET_SERIALNUMBER_INFO,
NULL, (void **)&str_p, &size)) != CFGA_SATA_OK) {
- (void) printf(
+ DPRINTF(
"SATA_CFGA_GET_SERIALNUMBER_INFO ioctl failed\n");
goto bailout;
}
/* drop leading and trailing spaces */
skip = strspn(str_p, " ");
@@ -1650,11 +1651,11 @@
/* Fill in ap_type which is collected from HBA driver */
/* call do_control_ioctl TBD */
if ((rv = do_control_ioctl(ap_id, SATA_CFGA_GET_AP_TYPE, NULL,
(void **)&str_p, &size)) != CFGA_SATA_OK) {
- (void) printf(
+ DPRINTF(
"SATA_CFGA_GET_AP_TYPE ioctl failed\n");
goto bailout;
}
(void) strlcpy((*ap_id_list)->ap_type, str_p,
@@ -1729,21 +1730,21 @@
{
int len;
char *q;
if (msgp == NULL || msgp->message_routine == NULL) {
- (void) printf("cfga_msg: NULL msgp\n");
+ DPRINTF("cfga_msg: msg\n");
return;
}
if ((len = strlen(str)) == 0) {
- (void) printf("cfga_msg: null str\n");
+ DPRINTF("cfga_msg: null str\n");
return;
}
if ((q = (char *)calloc(len + 1, 1)) == NULL) {
- perror("cfga_msg");
+ DPRINTF("cfga_msg: null q\n");
return;
}
(void) strcpy(q, str);
(*msgp->message_routine)(msgp->appdata_ptr, q);
@@ -1822,10 +1823,12 @@
if (errstring != NULL) {
*errstring = NULL;
}
if (options != NULL) {
+ DPRINTF("verify_params: hardware-specific options not "
+ "supported.\n");
return (CFGA_SATA_OPTIONS);
}
/* Strip dynamic AP name component if it is present. */
lap_id = strdup(ap_id);
@@ -1835,10 +1838,11 @@
if ((pdyn = GET_DYN(lap_id)) != NULL) {
*pdyn = '\0';
}
if (verify_valid_apid(lap_id) != 0) {
+ DPRINTF("verify_params: not a SATA ap_id.\n");
rv = CFGA_SATA_AP;
} else {
rv = CFGA_SATA_OK;
}
free(lap_id);
@@ -1924,11 +1928,11 @@
/* Set up nvlist to pass the port number down to the driver */
if (nvlist_alloc(user_nvlistp, NV_UNIQUE_NAME_TYPE, NULL) != 0) {
*user_nvlistp = NULL;
rv = CFGA_SATA_NVLIST;
- (void) printf("nvlist_alloc failed\n");
+ DPRINTF("nvlist_alloc failed\n");
goto bailout;
}
/*
* Get port id, for Port Multiplier port, things could be a little bit
@@ -1936,19 +1940,19 @@
* port multiplier port, port number should be coded as 32bit int
* with the sig 16 bit as sata channel number, least 16 bit as
* the port number of sata port multiplier port.
*/
if ((rv = get_port_num(lap_id, &port)) != CFGA_SATA_OK) {
- (void) printf(
+ DPRINTF(
"setup_for_devctl_cmd: get_port_num, errno: %d\n",
errno);
goto bailout;
}
/* Creates an int32_t entry */
if (nvlist_add_int32(*user_nvlistp, PORT, port) == -1) {
- (void) printf("nvlist_add_int32 failed\n");
+ DPRINTF("nvlist_add_int32 failed\n");
rv = CFGA_SATA_NVLIST;
goto bailout;
}
free(lap_id);
@@ -1967,11 +1971,11 @@
ap_rstate_t *rstate, ap_ostate_t *ostate)
{
devctl_ap_state_t devctl_ap_state;
if (devctl_ap_getstate(hdl, list, &devctl_ap_state) == -1) {
- (void) printf("devctl_ap_getstate failed, errno: %d\n", errno);
+ DPRINTF("devctl_ap_getstate failed, errno: %d\n", errno);
return (CFGA_SATA_IOCTL);
}
*rstate = devctl_ap_state.ap_rstate;
*ostate = devctl_ap_state.ap_ostate;
return (CFGA_SATA_OK);
@@ -2003,11 +2007,11 @@
if ((rv = get_port_num(ap_id, &port)) != CFGA_SATA_OK) {
goto bailout;
}
if ((fd = open(ap_id, O_RDONLY)) == -1) {
- (void) printf("do_control_ioctl: open failed: errno:%d\n",
+ DPRINTF("do_control_ioctl: open failed: errno:%d\n",
errno);
rv = CFGA_SATA_OPEN;
if (errno == EBUSY) {
rv = CFGA_SATA_BUSY;
}
@@ -2038,16 +2042,16 @@
goto bailout;
}
*sizep = local_size;
if (local_size == 0) {
- (void) printf("zero length data\n");
+ DPRINTF("zero length data\n");
rv = CFGA_SATA_ZEROLEN;
goto bailout;
}
if ((*descrp = malloc(*sizep)) == NULL) {
- (void) printf("do_control_ioctl: malloc failed\n");
+ DPRINTF("do_control_ioctl: malloc failed\n");
rv = CFGA_SATA_ALLOC_FAIL;
goto bailout;
}
} else {
*sizep = 0;