Print this page
patch tsoome-feedback


  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #include <stdlib.h>
  28 #include <errno.h>
  29 #include <sys/types.h>
  30 #include <libnvpair.h>
  31 #include <sys/fcntl.h>
  32 #include <sys/devfm.h>
  33 #include <fmd_agent_impl.h>
  34 
  35 static int
  36 cleanup_set_errno(fmd_agent_hdl_t *hdl, nvlist_t *innvl, nvlist_t *outnvl,
  37     int err)
  38 {
  39         if (innvl != NULL)
  40                 nvlist_free(innvl);
  41         if (outnvl != NULL)
  42                 nvlist_free(outnvl);
  43         return (fmd_agent_seterrno(hdl, err));
  44 }
  45 
  46 static int
  47 fmd_agent_physcpu_info_v1(fmd_agent_hdl_t *hdl, nvlist_t ***cpusp,
  48     uint_t *ncpup)
  49 {
  50         int err;
  51         nvlist_t *nvl, **nvl_array, **cpus;
  52         uint_t i, n;
  53 
  54         if ((err = fmd_agent_nvl_ioctl(hdl, FM_IOC_PHYSCPU_INFO, 1,
  55             NULL, &nvl)) != 0)
  56                 return (cleanup_set_errno(hdl, NULL, NULL, err));
  57         if ((err = nvlist_lookup_nvlist_array(nvl, FM_PHYSCPU_INFO_CPUS,
  58             &cpus, &n)) != 0)
  59                 return (cleanup_set_errno(hdl, NULL, nvl, err));
  60 
  61         if ((nvl_array = umem_alloc(sizeof (nvlist_t *) * n, UMEM_DEFAULT))




  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #include <stdlib.h>
  28 #include <errno.h>
  29 #include <sys/types.h>
  30 #include <libnvpair.h>
  31 #include <sys/fcntl.h>
  32 #include <sys/devfm.h>
  33 #include <fmd_agent_impl.h>
  34 
  35 static int
  36 cleanup_set_errno(fmd_agent_hdl_t *hdl, nvlist_t *innvl, nvlist_t *outnvl,
  37     int err)
  38 {

  39         nvlist_free(innvl);

  40         nvlist_free(outnvl);
  41         return (fmd_agent_seterrno(hdl, err));
  42 }
  43 
  44 static int
  45 fmd_agent_physcpu_info_v1(fmd_agent_hdl_t *hdl, nvlist_t ***cpusp,
  46     uint_t *ncpup)
  47 {
  48         int err;
  49         nvlist_t *nvl, **nvl_array, **cpus;
  50         uint_t i, n;
  51 
  52         if ((err = fmd_agent_nvl_ioctl(hdl, FM_IOC_PHYSCPU_INFO, 1,
  53             NULL, &nvl)) != 0)
  54                 return (cleanup_set_errno(hdl, NULL, NULL, err));
  55         if ((err = nvlist_lookup_nvlist_array(nvl, FM_PHYSCPU_INFO_CPUS,
  56             &cpus, &n)) != 0)
  57                 return (cleanup_set_errno(hdl, NULL, nvl, err));
  58 
  59         if ((nvl_array = umem_alloc(sizeof (nvlist_t *) * n, UMEM_DEFAULT))