1*f6e214c7SGavin Maltby /* 2*f6e214c7SGavin Maltby * CDDL HEADER START 3*f6e214c7SGavin Maltby * 4*f6e214c7SGavin Maltby * The contents of this file are subject to the terms of the 5*f6e214c7SGavin Maltby * Common Development and Distribution License (the "License"). 6*f6e214c7SGavin Maltby * You may not use this file except in compliance with the License. 7*f6e214c7SGavin Maltby * 8*f6e214c7SGavin Maltby * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*f6e214c7SGavin Maltby * or http://www.opensolaris.org/os/licensing. 10*f6e214c7SGavin Maltby * See the License for the specific language governing permissions 11*f6e214c7SGavin Maltby * and limitations under the License. 12*f6e214c7SGavin Maltby * 13*f6e214c7SGavin Maltby * When distributing Covered Code, include this CDDL HEADER in each 14*f6e214c7SGavin Maltby * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*f6e214c7SGavin Maltby * If applicable, add the following below this CDDL HEADER, with the 16*f6e214c7SGavin Maltby * fields enclosed by brackets "[]" replaced with your own identifying 17*f6e214c7SGavin Maltby * information: Portions Copyright [yyyy] [name of copyright owner] 18*f6e214c7SGavin Maltby * 19*f6e214c7SGavin Maltby * CDDL HEADER END 20*f6e214c7SGavin Maltby */ 21*f6e214c7SGavin Maltby /* 22*f6e214c7SGavin Maltby * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 23*f6e214c7SGavin Maltby */ 24*f6e214c7SGavin Maltby 25*f6e214c7SGavin Maltby #include <fmdump.h> 26*f6e214c7SGavin Maltby #include <stdio.h> 27*f6e214c7SGavin Maltby #include <time.h> 28*f6e214c7SGavin Maltby 29*f6e214c7SGavin Maltby /*ARGSUSED*/ 30*f6e214c7SGavin Maltby static int 31*f6e214c7SGavin Maltby info_short(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp) 32*f6e214c7SGavin Maltby { 33*f6e214c7SGavin Maltby char buf[32]; 34*f6e214c7SGavin Maltby 35*f6e214c7SGavin Maltby fmdump_printf(fp, "%-20s %-32s\n", 36*f6e214c7SGavin Maltby fmdump_date(buf, sizeof (buf), rp), rp->rec_class); 37*f6e214c7SGavin Maltby 38*f6e214c7SGavin Maltby return (0); 39*f6e214c7SGavin Maltby } 40*f6e214c7SGavin Maltby 41*f6e214c7SGavin Maltby /*ARGSUSED*/ 42*f6e214c7SGavin Maltby static int 43*f6e214c7SGavin Maltby info_verb1(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp) 44*f6e214c7SGavin Maltby { 45*f6e214c7SGavin Maltby char *uuid = "(absent)"; 46*f6e214c7SGavin Maltby char buf[32]; 47*f6e214c7SGavin Maltby 48*f6e214c7SGavin Maltby (void) nvlist_lookup_string(rp->rec_nvl, FM_IREPORT_UUID, &uuid); 49*f6e214c7SGavin Maltby 50*f6e214c7SGavin Maltby fmdump_printf(fp, "%-20s %-36s %s\n", 51*f6e214c7SGavin Maltby fmdump_date(buf, sizeof (buf), rp), uuid, rp->rec_class); 52*f6e214c7SGavin Maltby 53*f6e214c7SGavin Maltby return (0); 54*f6e214c7SGavin Maltby } 55*f6e214c7SGavin Maltby 56*f6e214c7SGavin Maltby /*ARGSUSED*/ 57*f6e214c7SGavin Maltby static int 58*f6e214c7SGavin Maltby info_verb23_cmn(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp, 59*f6e214c7SGavin Maltby nvlist_prtctl_t pctl) 60*f6e214c7SGavin Maltby { 61*f6e214c7SGavin Maltby char buf[32]; 62*f6e214c7SGavin Maltby char *uuid = "(absent)"; 63*f6e214c7SGavin Maltby 64*f6e214c7SGavin Maltby (void) nvlist_lookup_string(rp->rec_nvl, FM_IREPORT_UUID, &uuid); 65*f6e214c7SGavin Maltby 66*f6e214c7SGavin Maltby fmdump_printf(fp, "%-20s.%9.9llu %s\n", 67*f6e214c7SGavin Maltby fmdump_year(buf, sizeof (buf), rp), rp->rec_nsec, uuid); 68*f6e214c7SGavin Maltby 69*f6e214c7SGavin Maltby if (pctl) 70*f6e214c7SGavin Maltby nvlist_prt(rp->rec_nvl, pctl); 71*f6e214c7SGavin Maltby else 72*f6e214c7SGavin Maltby nvlist_print(fp, rp->rec_nvl); 73*f6e214c7SGavin Maltby 74*f6e214c7SGavin Maltby fmdump_printf(fp, "\n"); 75*f6e214c7SGavin Maltby return (0); 76*f6e214c7SGavin Maltby } 77*f6e214c7SGavin Maltby 78*f6e214c7SGavin Maltby static int 79*f6e214c7SGavin Maltby info_verb2(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp) 80*f6e214c7SGavin Maltby { 81*f6e214c7SGavin Maltby return (info_verb23_cmn(lp, rp, fp, NULL)); 82*f6e214c7SGavin Maltby } 83*f6e214c7SGavin Maltby 84*f6e214c7SGavin Maltby static int 85*f6e214c7SGavin Maltby info_pretty(fmd_log_t *lp, const fmd_log_record_t *rp, FILE *fp) 86*f6e214c7SGavin Maltby { 87*f6e214c7SGavin Maltby nvlist_prtctl_t pctl; 88*f6e214c7SGavin Maltby int rc; 89*f6e214c7SGavin Maltby 90*f6e214c7SGavin Maltby if ((pctl = nvlist_prtctl_alloc()) != NULL) { 91*f6e214c7SGavin Maltby nvlist_prtctl_setdest(pctl, fp); 92*f6e214c7SGavin Maltby nvlist_prtctlop_nvlist(pctl, fmdump_render_nvlist, NULL); 93*f6e214c7SGavin Maltby } 94*f6e214c7SGavin Maltby 95*f6e214c7SGavin Maltby rc = info_verb23_cmn(lp, rp, fp, pctl); 96*f6e214c7SGavin Maltby 97*f6e214c7SGavin Maltby nvlist_prtctl_free(pctl); 98*f6e214c7SGavin Maltby return (rc); 99*f6e214c7SGavin Maltby } 100*f6e214c7SGavin Maltby 101*f6e214c7SGavin Maltby const fmdump_ops_t fmdump_info_ops = { 102*f6e214c7SGavin Maltby "info", { 103*f6e214c7SGavin Maltby { 104*f6e214c7SGavin Maltby "TIME CLASS", 105*f6e214c7SGavin Maltby (fmd_log_rec_f *)info_short 106*f6e214c7SGavin Maltby }, { 107*f6e214c7SGavin Maltby "TIME UUID CLASS", 108*f6e214c7SGavin Maltby (fmd_log_rec_f *)info_verb1 109*f6e214c7SGavin Maltby }, { 110*f6e214c7SGavin Maltby "TIME UUID", 111*f6e214c7SGavin Maltby (fmd_log_rec_f *)info_verb2 112*f6e214c7SGavin Maltby }, { 113*f6e214c7SGavin Maltby "TIME UUID", 114*f6e214c7SGavin Maltby (fmd_log_rec_f *)info_pretty 115*f6e214c7SGavin Maltby }, { 116*f6e214c7SGavin Maltby NULL, NULL 117*f6e214c7SGavin Maltby } } 118*f6e214c7SGavin Maltby }; 119