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,28 **** --- 19,29 ---- * 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,722 **** } free(msg); devpath = sata_get_devicepath(ap_id); if (devpath == NULL) { ! (void) printf( "cfga_change_state: get device path failed\n"); rv = CFGA_SATA_DEV_UNCONFIGURE; break; } --- 713,723 ---- } free(msg); devpath = sata_get_devicepath(ap_id); if (devpath == NULL) { ! DPRINTF( "cfga_change_state: get device path failed\n"); rv = CFGA_SATA_DEV_UNCONFIGURE; break; }
*** 769,779 **** /* 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( "cfga_change_state: get path failed\n"); rv = CFGA_SATA_DEV_UNCONFIGURE; break; } --- 770,780 ---- /* 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) { ! DPRINTF( "cfga_change_state: get path failed\n"); rv = CFGA_SATA_DEV_UNCONFIGURE; break; }
*** 944,954 **** rv = CFGA_SATA_PRIV; goto bailout; } if (func == NULL) { ! (void) printf("No valid option specified\n"); rv = CFGA_SATA_OPTIONS; goto bailout; } if ((rv = setup_for_devctl_cmd(ap_id, &hdl, &list, 0)) != --- 945,955 ---- rv = CFGA_SATA_PRIV; goto bailout; } if (func == NULL) { ! DPRINTF("No valid option specified\n"); rv = CFGA_SATA_OPTIONS; goto bailout; } if ((rv = setup_for_devctl_cmd(ap_id, &hdl, &list, 0)) !=
*** 1255,1265 **** * Get target node path */ devpath = sata_get_devicepath(ap_id); if (devpath == NULL) { ! (void) printf("cfga_list_ext: cannot locate target device\n"); return (CFGA_SATA_DYNAMIC_AP); } else { cp = strrchr(devpath, *PATH_SEP); --- 1256,1266 ---- * Get target node path */ devpath = sata_get_devicepath(ap_id); if (devpath == NULL) { ! DPRINTF("cfga_list_ext: cannot locate target device\n"); return (CFGA_SATA_DYNAMIC_AP); } else { cp = strrchr(devpath, *PATH_SEP);
*** 1571,1581 **** * 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( "SATA_CFGA_GET_MODULE_INFO ioctl failed\n"); goto bailout; } /* drop leading and trailing spaces */ skip = strspn(str_p, " "); --- 1572,1582 ---- * 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) { ! DPRINTF( "SATA_CFGA_GET_MODULE_INFO ioctl failed\n"); goto bailout; } /* drop leading and trailing spaces */ skip = strspn(str_p, " ");
*** 1598,1608 **** * 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( "SATA_CFGA_GET_REVFIRMWARE_INFO ioctl failed\n"); goto bailout; } /* drop leading and trailing spaces */ skip = strspn(str_p, " "); --- 1599,1609 ---- * Firmware revision (FREV:) */ if ((rv = do_control_ioctl(ap_id, SATA_CFGA_GET_REVFIRMWARE_INFO, NULL, (void **)&str_p, &size)) != CFGA_SATA_OK) { ! DPRINTF( "SATA_CFGA_GET_REVFIRMWARE_INFO ioctl failed\n"); goto bailout; } /* drop leading and trailing spaces */ skip = strspn(str_p, " ");
*** 1625,1635 **** * 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( "SATA_CFGA_GET_SERIALNUMBER_INFO ioctl failed\n"); goto bailout; } /* drop leading and trailing spaces */ skip = strspn(str_p, " "); --- 1626,1636 ---- * Serial Number (SN:) */ if ((rv = do_control_ioctl(ap_id, SATA_CFGA_GET_SERIALNUMBER_INFO, NULL, (void **)&str_p, &size)) != CFGA_SATA_OK) { ! DPRINTF( "SATA_CFGA_GET_SERIALNUMBER_INFO ioctl failed\n"); goto bailout; } /* drop leading and trailing spaces */ skip = strspn(str_p, " ");
*** 1650,1660 **** /* 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( "SATA_CFGA_GET_AP_TYPE ioctl failed\n"); goto bailout; } (void) strlcpy((*ap_id_list)->ap_type, str_p, --- 1651,1661 ---- /* 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) { ! DPRINTF( "SATA_CFGA_GET_AP_TYPE ioctl failed\n"); goto bailout; } (void) strlcpy((*ap_id_list)->ap_type, str_p,
*** 1729,1749 **** { int len; char *q; if (msgp == NULL || msgp->message_routine == NULL) { ! (void) printf("cfga_msg: NULL msgp\n"); return; } if ((len = strlen(str)) == 0) { ! (void) printf("cfga_msg: null str\n"); return; } if ((q = (char *)calloc(len + 1, 1)) == NULL) { ! perror("cfga_msg"); return; } (void) strcpy(q, str); (*msgp->message_routine)(msgp->appdata_ptr, q); --- 1730,1750 ---- { int len; char *q; if (msgp == NULL || msgp->message_routine == NULL) { ! DPRINTF("cfga_msg: msg\n"); return; } if ((len = strlen(str)) == 0) { ! DPRINTF("cfga_msg: null str\n"); return; } if ((q = (char *)calloc(len + 1, 1)) == NULL) { ! DPRINTF("cfga_msg: null q\n"); return; } (void) strcpy(q, str); (*msgp->message_routine)(msgp->appdata_ptr, q);
*** 1822,1831 **** --- 1823,1834 ---- 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,1844 **** --- 1838,1848 ---- 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,1934 **** /* 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"); goto bailout; } /* * Get port id, for Port Multiplier port, things could be a little bit --- 1928,1938 ---- /* 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; ! DPRINTF("nvlist_alloc failed\n"); goto bailout; } /* * Get port id, for Port Multiplier port, things could be a little bit
*** 1936,1954 **** * 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( "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"); rv = CFGA_SATA_NVLIST; goto bailout; } free(lap_id); --- 1940,1958 ---- * 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) { ! 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) { ! DPRINTF("nvlist_add_int32 failed\n"); rv = CFGA_SATA_NVLIST; goto bailout; } free(lap_id);
*** 1967,1977 **** 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); return (CFGA_SATA_IOCTL); } *rstate = devctl_ap_state.ap_rstate; *ostate = devctl_ap_state.ap_ostate; return (CFGA_SATA_OK); --- 1971,1981 ---- 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) { ! 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,2013 **** 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", errno); rv = CFGA_SATA_OPEN; if (errno == EBUSY) { rv = CFGA_SATA_BUSY; } --- 2007,2017 ---- if ((rv = get_port_num(ap_id, &port)) != CFGA_SATA_OK) { goto bailout; } if ((fd = open(ap_id, O_RDONLY)) == -1) { ! DPRINTF("do_control_ioctl: open failed: errno:%d\n", errno); rv = CFGA_SATA_OPEN; if (errno == EBUSY) { rv = CFGA_SATA_BUSY; }
*** 2038,2053 **** goto bailout; } *sizep = local_size; if (local_size == 0) { ! (void) printf("zero length data\n"); rv = CFGA_SATA_ZEROLEN; goto bailout; } if ((*descrp = malloc(*sizep)) == NULL) { ! (void) printf("do_control_ioctl: malloc failed\n"); rv = CFGA_SATA_ALLOC_FAIL; goto bailout; } } else { *sizep = 0; --- 2042,2057 ---- goto bailout; } *sizep = local_size; if (local_size == 0) { ! DPRINTF("zero length data\n"); rv = CFGA_SATA_ZEROLEN; goto bailout; } if ((*descrp = malloc(*sizep)) == NULL) { ! DPRINTF("do_control_ioctl: malloc failed\n"); rv = CFGA_SATA_ALLOC_FAIL; goto bailout; } } else { *sizep = 0;