Print this page
OS-1840 fmdump shall emit JSON (newlines, fflush)


  61          * topo_fmri_nvl2str which should fail gracefully for invalid
  62          * schemes (ie an nvlist that just happens to have the expected
  63          * class and version members but that isn't an FMRI).
  64          */
  65         if (topo_fmri_nvl2str(thp, fmri, &fmristr, &err) != 0 ||
  66             fmristr == NULL)
  67                 return (0);
  68 
  69         nvlist_prtctl_doindent(pctl, 1);
  70         nvlist_prtctl_dofmt(pctl, NVLIST_FMT_MEMBER_NAME, name);
  71         (void) fprintf(fp, "%s", fmristr);
  72         topo_hdl_strfree(thp, fmristr);
  73 
  74         return (1);
  75 }
  76 
  77 /*
  78  * Thin wrapper around libnvpair's inbuilt JSON routine.  Simply dumps the
  79  * entire log record nvlist without any reformatting.
  80  */


  81 int
  82 fmdump_print_json(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
  83 {
  84         nvlist_print_json(fp, rp->rec_nvl);
  85         fprintf(fp, "\n");

  86 
  87         return (0);
  88 }


  61          * topo_fmri_nvl2str which should fail gracefully for invalid
  62          * schemes (ie an nvlist that just happens to have the expected
  63          * class and version members but that isn't an FMRI).
  64          */
  65         if (topo_fmri_nvl2str(thp, fmri, &fmristr, &err) != 0 ||
  66             fmristr == NULL)
  67                 return (0);
  68 
  69         nvlist_prtctl_doindent(pctl, 1);
  70         nvlist_prtctl_dofmt(pctl, NVLIST_FMT_MEMBER_NAME, name);
  71         (void) fprintf(fp, "%s", fmristr);
  72         topo_hdl_strfree(thp, fmristr);
  73 
  74         return (1);
  75 }
  76 
  77 /*
  78  * Thin wrapper around libnvpair's inbuilt JSON routine.  Simply dumps the
  79  * entire log record nvlist without any reformatting.
  80  */
  81 
  82 /*ARGSUSED*/
  83 int
  84 fmdump_print_json(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp)
  85 {
  86         if (nvlist_print_json(fp, rp->rec_nvl) || fprintf(fp, "\n") < 0 ||
  87             fflush(fp) != 0)
  88                 return (-1);
  89 
  90         return (0);
  91 }