1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate /* 30*0Sstevel@tonic-gate * nfs log - read buffer file and print structs in user-readable form 31*0Sstevel@tonic-gate */ 32*0Sstevel@tonic-gate 33*0Sstevel@tonic-gate #define _REENTRANT 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate #include <ctype.h> 36*0Sstevel@tonic-gate #include <stdio.h> 37*0Sstevel@tonic-gate #include <stdlib.h> 38*0Sstevel@tonic-gate #include <stddef.h> 39*0Sstevel@tonic-gate #include <string.h> 40*0Sstevel@tonic-gate #include <strings.h> 41*0Sstevel@tonic-gate #include <time.h> 42*0Sstevel@tonic-gate #include <fcntl.h> 43*0Sstevel@tonic-gate #include <unistd.h> 44*0Sstevel@tonic-gate #include <signal.h> 45*0Sstevel@tonic-gate #include <sys/types.h> 46*0Sstevel@tonic-gate #include <sys/stat.h> 47*0Sstevel@tonic-gate #include <sys/param.h> 48*0Sstevel@tonic-gate #include <sys/utsname.h> 49*0Sstevel@tonic-gate #include <errno.h> 50*0Sstevel@tonic-gate #include <time.h> 51*0Sstevel@tonic-gate #include <limits.h> 52*0Sstevel@tonic-gate #include <libintl.h> 53*0Sstevel@tonic-gate #include <pwd.h> 54*0Sstevel@tonic-gate #include <netdb.h> 55*0Sstevel@tonic-gate #include <syslog.h> 56*0Sstevel@tonic-gate #include <rpc/rpc.h> 57*0Sstevel@tonic-gate #include <netconfig.h> 58*0Sstevel@tonic-gate #include <netdir.h> 59*0Sstevel@tonic-gate #include <nfs/nfs_sec.h> 60*0Sstevel@tonic-gate #include <nfs/export.h> 61*0Sstevel@tonic-gate #include <rpc/auth.h> 62*0Sstevel@tonic-gate #include <rpc/svc.h> 63*0Sstevel@tonic-gate #include <rpc/xdr.h> 64*0Sstevel@tonic-gate #include <rpc/clnt.h> 65*0Sstevel@tonic-gate #include <nfs/nfs.h> 66*0Sstevel@tonic-gate #include <nfs/nfs_log.h> 67*0Sstevel@tonic-gate #include "fhtab.h" 68*0Sstevel@tonic-gate #include "nfslogd.h" 69*0Sstevel@tonic-gate 70*0Sstevel@tonic-gate static char empty_name[4] = "-"; 71*0Sstevel@tonic-gate 72*0Sstevel@tonic-gate static char ftype3_names[NF3FIFO + 1][20] = { 73*0Sstevel@tonic-gate "\"none\"", "\"file\"", "\"dir\"", "\"blk device\"", 74*0Sstevel@tonic-gate "\"chr device\"", "\"link\"", "\"socket\"", "\"fifo\"" 75*0Sstevel@tonic-gate }; 76*0Sstevel@tonic-gate 77*0Sstevel@tonic-gate #define NFSL_FTYPE3(ftype) \ 78*0Sstevel@tonic-gate ((((ftype) >= 0) && ((ftype) <= NF3FIFO)) ? \ 79*0Sstevel@tonic-gate ftype3_names[ftype] : empty_name) 80*0Sstevel@tonic-gate 81*0Sstevel@tonic-gate static char createmode3_names[EXCLUSIVE + 1][20] = { 82*0Sstevel@tonic-gate "\"unchecked", "\"guarded\"", "\"exclusive\"" 83*0Sstevel@tonic-gate }; 84*0Sstevel@tonic-gate 85*0Sstevel@tonic-gate #define NFSL_CREATEMODE3(createmode) \ 86*0Sstevel@tonic-gate ((((createmode) >= 0) && ((createmode) <= EXCLUSIVE)) ? \ 87*0Sstevel@tonic-gate createmode3_names[createmode] : empty_name) 88*0Sstevel@tonic-gate 89*0Sstevel@tonic-gate static char auth_flavor_name[RPCSEC_GSS + 1][20] = { 90*0Sstevel@tonic-gate "\"auth_null\"", "\"auth_unix\"", "\"auth_short\"", "\"auth_des\"", 91*0Sstevel@tonic-gate "\"auth_kerb\"", "\"none\"", "\"rpcsec_gss\"" 92*0Sstevel@tonic-gate }; 93*0Sstevel@tonic-gate 94*0Sstevel@tonic-gate #define NFSL_AUTH_FLAVOR_PRINT(auth_flavor) \ 95*0Sstevel@tonic-gate (((auth_flavor) <= RPCSEC_GSS) ? \ 96*0Sstevel@tonic-gate auth_flavor_name[auth_flavor] : empty_name) 97*0Sstevel@tonic-gate 98*0Sstevel@tonic-gate #define NFSL_ERR_CNT 31 /* Actual err numbers */ 99*0Sstevel@tonic-gate 100*0Sstevel@tonic-gate /* 101*0Sstevel@tonic-gate * Two arrays - one short ints containing err codes, the other the strings 102*0Sstevel@tonic-gate * (merged codes for both v2 and v3 103*0Sstevel@tonic-gate */ 104*0Sstevel@tonic-gate static char nfsl_status_name[NFSL_ERR_CNT][30] = { 105*0Sstevel@tonic-gate "\"ok\"", "\"perm\"", "\"noent\"", "\"io\"", 106*0Sstevel@tonic-gate "\"nxio\"", "\"access\"", "\"exist\"", "\"xdev\"", 107*0Sstevel@tonic-gate "\"nodev\"", "\"notdir\"", "\"isdir\"", "\"inval\"", 108*0Sstevel@tonic-gate "\"fbig\"", "\"nospc\"", "\"rofs\"", "\"mlink\"", 109*0Sstevel@tonic-gate "\"notsupp\"", "\"nametoolong\"", "\"notempty\"", "\"dquot\"", 110*0Sstevel@tonic-gate "\"stale\"", "\"remote\"", "\"wflush\"", "\"badhandle\"", 111*0Sstevel@tonic-gate "\"not_sync\"", "\"bad_cookie\"", "\"notsupp\"", "\"toosmall\"", 112*0Sstevel@tonic-gate "\"serverfault\"", "\"badtype\"", "\"jukebox\"", 113*0Sstevel@tonic-gate }; 114*0Sstevel@tonic-gate 115*0Sstevel@tonic-gate static short nfsl_status[NFSL_ERR_CNT] = { 116*0Sstevel@tonic-gate 0, 1, 2, 5, 6, 13, 17, 18, 117*0Sstevel@tonic-gate 19, 20, 21, 22, 27, 28, 30, 31, 118*0Sstevel@tonic-gate 45, 63, 66, 69, 70, 71, 99, 10001, 119*0Sstevel@tonic-gate 10002, 10003, 10004, 10005, 10006, 10007, 10008 120*0Sstevel@tonic-gate }; 121*0Sstevel@tonic-gate 122*0Sstevel@tonic-gate /* list of open elf files */ 123*0Sstevel@tonic-gate static struct nfsl_log_file *elf_file_list = NULL; 124*0Sstevel@tonic-gate 125*0Sstevel@tonic-gate /* Imported functions */ 126*0Sstevel@tonic-gate extern void bcopy(const void *s1, void *s2, size_t n); 127*0Sstevel@tonic-gate 128*0Sstevel@tonic-gate /* Static functions */ 129*0Sstevel@tonic-gate static void nfsl_log_file_free(struct nfsl_log_file *elfrec); 130*0Sstevel@tonic-gate static void nfsl_log_file_add(struct nfsl_log_file *elfrec, 131*0Sstevel@tonic-gate struct nfsl_log_file **elf_listp); 132*0Sstevel@tonic-gate static struct nfsl_log_file *nfsl_log_file_find(struct nfsl_log_file *elfrec, 133*0Sstevel@tonic-gate struct nfsl_log_file *elf_list); 134*0Sstevel@tonic-gate static struct nfsl_log_file *nfsl_log_file_del(struct nfsl_log_file *elfrec, 135*0Sstevel@tonic-gate struct nfsl_log_file **elf_listp); 136*0Sstevel@tonic-gate 137*0Sstevel@tonic-gate static char *nfsl_get_time(time_t tt); 138*0Sstevel@tonic-gate static char *nfsl_get_date(time_t tt); 139*0Sstevel@tonic-gate static char *nfsl_get_date_nq(time_t tt); 140*0Sstevel@tonic-gate static int nfsl_write_elfbuf(struct nfsl_log_file *elfrec); 141*0Sstevel@tonic-gate static void nfsl_ipaddr_print(struct nfsl_log_file *, struct netbuf *); 142*0Sstevel@tonic-gate static void nfsl_elf_record_header_print(struct nfsl_log_file *, 143*0Sstevel@tonic-gate nfslog_record_header *, char *, char *, 144*0Sstevel@tonic-gate struct nfsl_proc_disp *, char *); 145*0Sstevel@tonic-gate static void nfsl_elf_buffer_header_print(struct nfsl_log_file *, 146*0Sstevel@tonic-gate nfslog_buffer_header *); 147*0Sstevel@tonic-gate static struct nfsl_proc_disp *nfsl_find_elf_dispatch( 148*0Sstevel@tonic-gate nfslog_request_record *, char **); 149*0Sstevel@tonic-gate static void nfsl_elf_rpc_print(struct nfsl_log_file *, 150*0Sstevel@tonic-gate nfslog_request_record *, struct nfsl_proc_disp *, 151*0Sstevel@tonic-gate char *, char *, char *); 152*0Sstevel@tonic-gate static void nfslog_size3_print(struct nfsl_log_file *, set_size3 *); 153*0Sstevel@tonic-gate 154*0Sstevel@tonic-gate static void nfslog_null_args(struct nfsl_log_file *, caddr_t *); 155*0Sstevel@tonic-gate static void nfslog_null_res(struct nfsl_log_file *, caddr_t *); 156*0Sstevel@tonic-gate 157*0Sstevel@tonic-gate 158*0Sstevel@tonic-gate /* 159*0Sstevel@tonic-gate * NFS VERSION 2 160*0Sstevel@tonic-gate */ 161*0Sstevel@tonic-gate 162*0Sstevel@tonic-gate /* Functions for elf print of the arguments */ 163*0Sstevel@tonic-gate static void nfslog_fhandle_print(struct nfsl_log_file *, fhandle_t *); 164*0Sstevel@tonic-gate static void nfslog_diropargs_print(struct nfsl_log_file *, nfslog_diropargs *); 165*0Sstevel@tonic-gate static void nfslog_setattrargs_print(struct nfsl_log_file *, 166*0Sstevel@tonic-gate nfslog_setattrargs *); 167*0Sstevel@tonic-gate static void nfslog_sattr_print(struct nfsl_log_file *, 168*0Sstevel@tonic-gate nfslog_sattr *); 169*0Sstevel@tonic-gate static void nfslog_nfsreadargs_print(struct nfsl_log_file *, 170*0Sstevel@tonic-gate nfslog_nfsreadargs *); 171*0Sstevel@tonic-gate static void nfslog_writeargs_print(struct nfsl_log_file *, 172*0Sstevel@tonic-gate nfslog_writeargs *); 173*0Sstevel@tonic-gate static void nfslog_writeresult_print(struct nfsl_log_file *, 174*0Sstevel@tonic-gate nfslog_writeresult *, bool_t); 175*0Sstevel@tonic-gate static void nfslog_creatargs_print(struct nfsl_log_file *, 176*0Sstevel@tonic-gate nfslog_createargs *); 177*0Sstevel@tonic-gate static void nfslog_rddirargs_print(struct nfsl_log_file *, nfslog_rddirargs *); 178*0Sstevel@tonic-gate static void nfslog_linkargs_print(struct nfsl_log_file *, nfslog_linkargs *); 179*0Sstevel@tonic-gate static void nfslog_rnmargs_print(struct nfsl_log_file *, nfslog_rnmargs *); 180*0Sstevel@tonic-gate static void nfslog_symlinkargs_print(struct nfsl_log_file *, 181*0Sstevel@tonic-gate nfslog_symlinkargs *); 182*0Sstevel@tonic-gate 183*0Sstevel@tonic-gate static void nfslog_sharefsargs_print(struct nfsl_log_file *, 184*0Sstevel@tonic-gate nfslog_sharefsargs *); 185*0Sstevel@tonic-gate static void nfslog_getfhargs_print(struct nfsl_log_file *, 186*0Sstevel@tonic-gate nfslog_getfhargs *); 187*0Sstevel@tonic-gate 188*0Sstevel@tonic-gate /* Functions for elf print of the response */ 189*0Sstevel@tonic-gate static void nfslog_nfsstat_print(struct nfsl_log_file *, enum nfsstat *, 190*0Sstevel@tonic-gate bool_t); 191*0Sstevel@tonic-gate static void nfslog_diropres_print(struct nfsl_log_file *, nfslog_diropres *, 192*0Sstevel@tonic-gate bool_t); 193*0Sstevel@tonic-gate static void nfslog_rdlnres_print(struct nfsl_log_file *, nfslog_rdlnres *, 194*0Sstevel@tonic-gate bool_t); 195*0Sstevel@tonic-gate static void nfslog_rdresult_print(struct nfsl_log_file *, 196*0Sstevel@tonic-gate nfslog_rdresult *, bool_t); 197*0Sstevel@tonic-gate static void nfslog_rddirres_print(struct nfsl_log_file *, nfslog_rddirres *, 198*0Sstevel@tonic-gate bool_t); 199*0Sstevel@tonic-gate 200*0Sstevel@tonic-gate /* 201*0Sstevel@tonic-gate * NFS VERSION 3 202*0Sstevel@tonic-gate */ 203*0Sstevel@tonic-gate 204*0Sstevel@tonic-gate /* Functions for elf print of the arguments */ 205*0Sstevel@tonic-gate static void nfslog_fh3_print(struct nfsl_log_file *, nfs_fh3 *); 206*0Sstevel@tonic-gate static void nfslog_diropargs3_print(struct nfsl_log_file *, 207*0Sstevel@tonic-gate nfslog_diropargs3 *); 208*0Sstevel@tonic-gate static void nfslog_SETATTR3args_print(struct nfsl_log_file *, 209*0Sstevel@tonic-gate nfslog_SETATTR3args *); 210*0Sstevel@tonic-gate static void nfslog_READ3args_print(struct nfsl_log_file *, nfslog_READ3args *); 211*0Sstevel@tonic-gate static void nfslog_WRITE3args_print(struct nfsl_log_file *, 212*0Sstevel@tonic-gate nfslog_WRITE3args *); 213*0Sstevel@tonic-gate static void nfslog_CREATE3args_print(struct nfsl_log_file *, 214*0Sstevel@tonic-gate nfslog_CREATE3args *); 215*0Sstevel@tonic-gate static void nfslog_MKDIR3args_print(struct nfsl_log_file *, 216*0Sstevel@tonic-gate nfslog_MKDIR3args *); 217*0Sstevel@tonic-gate static void nfslog_SYMLINK3args_print(struct nfsl_log_file *, 218*0Sstevel@tonic-gate nfslog_SYMLINK3args *); 219*0Sstevel@tonic-gate static void nfslog_MKNOD3args_print(struct nfsl_log_file *, 220*0Sstevel@tonic-gate nfslog_MKNOD3args *); 221*0Sstevel@tonic-gate static void nfslog_REMOVE3args_print(struct nfsl_log_file *, 222*0Sstevel@tonic-gate nfslog_REMOVE3args *); 223*0Sstevel@tonic-gate static void nfslog_RMDIR3args_print(struct nfsl_log_file *, 224*0Sstevel@tonic-gate nfslog_RMDIR3args *); 225*0Sstevel@tonic-gate static void nfslog_RENAME3args_print(struct nfsl_log_file *, 226*0Sstevel@tonic-gate nfslog_RENAME3args *); 227*0Sstevel@tonic-gate static void nfslog_LINK3args_print(struct nfsl_log_file *, 228*0Sstevel@tonic-gate nfslog_LINK3args *); 229*0Sstevel@tonic-gate static void nfslog_COMMIT3args_print(struct nfsl_log_file *, 230*0Sstevel@tonic-gate nfslog_COMMIT3args *); 231*0Sstevel@tonic-gate static void nfslog_READDIRPLUS3args_print(struct nfsl_log_file *, 232*0Sstevel@tonic-gate nfslog_READDIRPLUS3args *); 233*0Sstevel@tonic-gate 234*0Sstevel@tonic-gate /* Functions for elf print of the response */ 235*0Sstevel@tonic-gate static void nfslog_nfsstat3_print(struct nfsl_log_file *, 236*0Sstevel@tonic-gate nfsstat3 *, bool_t); 237*0Sstevel@tonic-gate static void nfslog_LOOKUP3res_print(struct nfsl_log_file *, 238*0Sstevel@tonic-gate nfslog_LOOKUP3res *, bool_t); 239*0Sstevel@tonic-gate static void nfslog_READLINK3res_print(struct nfsl_log_file *, 240*0Sstevel@tonic-gate nfslog_READLINK3res *, bool_t); 241*0Sstevel@tonic-gate static void nfslog_READ3res_print(struct nfsl_log_file *, 242*0Sstevel@tonic-gate nfslog_READ3res *, bool_t); 243*0Sstevel@tonic-gate static void nfslog_WRITE3res_print(struct nfsl_log_file *, 244*0Sstevel@tonic-gate nfslog_WRITE3res *, bool_t); 245*0Sstevel@tonic-gate static void nfslog_CREATE3res_print(struct nfsl_log_file *, 246*0Sstevel@tonic-gate nfslog_CREATE3res *, bool_t); 247*0Sstevel@tonic-gate static void nfslog_MKDIR3res_print(struct nfsl_log_file *, 248*0Sstevel@tonic-gate nfslog_MKDIR3res *, bool_t); 249*0Sstevel@tonic-gate static void nfslog_SYMLINK3res_print(struct nfsl_log_file *, 250*0Sstevel@tonic-gate nfslog_SYMLINK3res *, bool_t); 251*0Sstevel@tonic-gate static void nfslog_MKNOD3res_print(struct nfsl_log_file *, 252*0Sstevel@tonic-gate nfslog_MKNOD3res *, bool_t); 253*0Sstevel@tonic-gate static void nfslog_READDIRPLUS3res_print(struct nfsl_log_file *, 254*0Sstevel@tonic-gate nfslog_READDIRPLUS3res *, bool_t); 255*0Sstevel@tonic-gate 256*0Sstevel@tonic-gate extern int debug; 257*0Sstevel@tonic-gate static bool_t nfsl_print_fh = FALSE; /* print file handles? */ 258*0Sstevel@tonic-gate 259*0Sstevel@tonic-gate #define DFLT_BUFFERSIZE 8192 260*0Sstevel@tonic-gate #define DFLT_OVFSIZE 3072 /* Maximum logged or buffered size */ 261*0Sstevel@tonic-gate 262*0Sstevel@tonic-gate static char hostname[MAXHOSTNAMELEN]; /* name of host */ 263*0Sstevel@tonic-gate 264*0Sstevel@tonic-gate 265*0Sstevel@tonic-gate /* 266*0Sstevel@tonic-gate * Define the actions taken per prog/vers/proc: 267*0Sstevel@tonic-gate * 268*0Sstevel@tonic-gate * In some cases, the nl types are the same as the nfs types and a simple 269*0Sstevel@tonic-gate * bcopy should suffice. Rather that define tens of identical procedures, 270*0Sstevel@tonic-gate * simply define these to bcopy. Similarly this takes care of different 271*0Sstevel@tonic-gate * procs that use same parameter struct. 272*0Sstevel@tonic-gate */ 273*0Sstevel@tonic-gate 274*0Sstevel@tonic-gate static struct nfsl_proc_disp nfsl_elf_proc_v2[] = { 275*0Sstevel@tonic-gate /* 276*0Sstevel@tonic-gate * NFS VERSION 2 277*0Sstevel@tonic-gate */ 278*0Sstevel@tonic-gate 279*0Sstevel@tonic-gate /* RFS_NULL = 0 */ 280*0Sstevel@tonic-gate {nfslog_null_args, nfslog_null_res, "\"null\""}, 281*0Sstevel@tonic-gate 282*0Sstevel@tonic-gate /* RFS_GETATTR = 1 */ 283*0Sstevel@tonic-gate {nfslog_fhandle_print, nfslog_nfsstat_print, "\"getattr\""}, 284*0Sstevel@tonic-gate 285*0Sstevel@tonic-gate /* RFS_SETATTR = 2 */ 286*0Sstevel@tonic-gate {nfslog_setattrargs_print, nfslog_nfsstat_print, "\"setattr\""}, 287*0Sstevel@tonic-gate 288*0Sstevel@tonic-gate /* RFS_ROOT = 3 *** NO LONGER SUPPORTED *** */ 289*0Sstevel@tonic-gate {nfslog_null_args, nfslog_null_res, "\"root\""}, 290*0Sstevel@tonic-gate 291*0Sstevel@tonic-gate /* RFS_LOOKUP = 4 */ 292*0Sstevel@tonic-gate {nfslog_diropargs_print, nfslog_diropres_print, "\"lookup\""}, 293*0Sstevel@tonic-gate 294*0Sstevel@tonic-gate /* RFS_READLINK = 5 */ 295*0Sstevel@tonic-gate {nfslog_fhandle_print, nfslog_rdlnres_print, "\"readlink\""}, 296*0Sstevel@tonic-gate 297*0Sstevel@tonic-gate /* RFS_READ = 6 */ 298*0Sstevel@tonic-gate {nfslog_nfsreadargs_print, nfslog_rdresult_print, "\"read\""}, 299*0Sstevel@tonic-gate 300*0Sstevel@tonic-gate /* RFS_WRITECACHE = 7 *** NO LONGER SUPPORTED *** */ 301*0Sstevel@tonic-gate {nfslog_null_args, nfslog_null_res, "\"writecache\""}, 302*0Sstevel@tonic-gate 303*0Sstevel@tonic-gate /* RFS_WRITE = 8 */ 304*0Sstevel@tonic-gate {nfslog_writeargs_print, nfslog_writeresult_print, "\"write\""}, 305*0Sstevel@tonic-gate 306*0Sstevel@tonic-gate /* RFS_CREATE = 9 */ 307*0Sstevel@tonic-gate {nfslog_creatargs_print, nfslog_diropres_print, "\"create\""}, 308*0Sstevel@tonic-gate 309*0Sstevel@tonic-gate /* RFS_REMOVE = 10 */ 310*0Sstevel@tonic-gate {nfslog_diropargs_print, nfslog_nfsstat_print, "\"remove\""}, 311*0Sstevel@tonic-gate 312*0Sstevel@tonic-gate /* RFS_RENAME = 11 */ 313*0Sstevel@tonic-gate {nfslog_rnmargs_print, nfslog_nfsstat_print, "\"rename\""}, 314*0Sstevel@tonic-gate 315*0Sstevel@tonic-gate /* RFS_LINK = 12 */ 316*0Sstevel@tonic-gate {nfslog_linkargs_print, nfslog_nfsstat_print, "\"link\""}, 317*0Sstevel@tonic-gate 318*0Sstevel@tonic-gate /* RFS_SYMLINK = 13 */ 319*0Sstevel@tonic-gate {nfslog_symlinkargs_print, nfslog_nfsstat_print, "\"symlink\""}, 320*0Sstevel@tonic-gate 321*0Sstevel@tonic-gate /* RFS_MKDIR = 14 */ 322*0Sstevel@tonic-gate {nfslog_creatargs_print, nfslog_diropres_print, "\"mkdir\""}, 323*0Sstevel@tonic-gate 324*0Sstevel@tonic-gate /* RFS_RMDIR = 15 */ 325*0Sstevel@tonic-gate {nfslog_diropargs_print, nfslog_nfsstat_print, "\"rmdir\""}, 326*0Sstevel@tonic-gate 327*0Sstevel@tonic-gate /* RFS_READDIR = 16 */ 328*0Sstevel@tonic-gate {nfslog_rddirargs_print, nfslog_rddirres_print, "\"readdir\""}, 329*0Sstevel@tonic-gate 330*0Sstevel@tonic-gate /* RFS_STATFS = 17 */ 331*0Sstevel@tonic-gate {nfslog_fhandle_print, nfslog_nfsstat_print, "\"statfs\""}, 332*0Sstevel@tonic-gate }; 333*0Sstevel@tonic-gate 334*0Sstevel@tonic-gate 335*0Sstevel@tonic-gate /* 336*0Sstevel@tonic-gate * NFS VERSION 3 337*0Sstevel@tonic-gate */ 338*0Sstevel@tonic-gate 339*0Sstevel@tonic-gate static struct nfsl_proc_disp nfsl_elf_proc_v3[] = { 340*0Sstevel@tonic-gate 341*0Sstevel@tonic-gate /* NFSPROC3_NULL = 0 */ 342*0Sstevel@tonic-gate {nfslog_null_args, nfslog_null_res, "\"null\""}, 343*0Sstevel@tonic-gate 344*0Sstevel@tonic-gate /* NFSPROC3_GETATTR = 1 */ 345*0Sstevel@tonic-gate {nfslog_fh3_print, nfslog_nfsstat3_print, "\"getattr\""}, 346*0Sstevel@tonic-gate 347*0Sstevel@tonic-gate /* NFSPROC3_SETATTR = 2 */ 348*0Sstevel@tonic-gate {nfslog_SETATTR3args_print, nfslog_nfsstat3_print, "\"setattr\""}, 349*0Sstevel@tonic-gate 350*0Sstevel@tonic-gate /* NFSPROC3_LOOKUP = 3 */ 351*0Sstevel@tonic-gate {nfslog_diropargs3_print, nfslog_LOOKUP3res_print, "\"lookup\""}, 352*0Sstevel@tonic-gate 353*0Sstevel@tonic-gate /* NFSPROC3_ACCESS = 4 */ 354*0Sstevel@tonic-gate {nfslog_fh3_print, nfslog_nfsstat3_print, "\"access\""}, 355*0Sstevel@tonic-gate 356*0Sstevel@tonic-gate /* NFSPROC3_READLINK = 5 */ 357*0Sstevel@tonic-gate {nfslog_fh3_print, nfslog_READLINK3res_print, "\"readlink\""}, 358*0Sstevel@tonic-gate 359*0Sstevel@tonic-gate /* NFSPROC3_READ = 6 */ 360*0Sstevel@tonic-gate {nfslog_READ3args_print, nfslog_READ3res_print, "\"read\""}, 361*0Sstevel@tonic-gate 362*0Sstevel@tonic-gate /* NFSPROC3_WRITE = 7 */ 363*0Sstevel@tonic-gate {nfslog_WRITE3args_print, nfslog_WRITE3res_print, "\"write\""}, 364*0Sstevel@tonic-gate 365*0Sstevel@tonic-gate /* NFSPROC3_CREATE = 8 */ 366*0Sstevel@tonic-gate {nfslog_CREATE3args_print, nfslog_CREATE3res_print, "\"create\""}, 367*0Sstevel@tonic-gate 368*0Sstevel@tonic-gate /* NFSPROC3_MKDIR = 9 */ 369*0Sstevel@tonic-gate {nfslog_MKDIR3args_print, nfslog_MKDIR3res_print, "\"mkdir\""}, 370*0Sstevel@tonic-gate 371*0Sstevel@tonic-gate /* NFSPROC3_SYMLINK = 10 */ 372*0Sstevel@tonic-gate {nfslog_SYMLINK3args_print, nfslog_SYMLINK3res_print, "\"symlink\""}, 373*0Sstevel@tonic-gate 374*0Sstevel@tonic-gate /* NFSPROC3_MKNOD = 11 */ 375*0Sstevel@tonic-gate {nfslog_MKNOD3args_print, nfslog_MKNOD3res_print, "\"mknod\""}, 376*0Sstevel@tonic-gate 377*0Sstevel@tonic-gate /* NFSPROC3_REMOVE = 12 */ 378*0Sstevel@tonic-gate {nfslog_REMOVE3args_print, nfslog_nfsstat3_print, "\"remove\""}, 379*0Sstevel@tonic-gate 380*0Sstevel@tonic-gate /* NFSPROC3_RMDIR = 13 */ 381*0Sstevel@tonic-gate {nfslog_RMDIR3args_print, nfslog_nfsstat3_print, "\"rmdir\""}, 382*0Sstevel@tonic-gate 383*0Sstevel@tonic-gate /* NFSPROC3_RENAME = 14 */ 384*0Sstevel@tonic-gate {nfslog_RENAME3args_print, nfslog_nfsstat3_print, "\"rename\""}, 385*0Sstevel@tonic-gate 386*0Sstevel@tonic-gate /* NFSPROC3_LINK = 15 */ 387*0Sstevel@tonic-gate {nfslog_LINK3args_print, nfslog_nfsstat3_print, "\"link\""}, 388*0Sstevel@tonic-gate 389*0Sstevel@tonic-gate /* NFSPROC3_READDIR = 16 */ 390*0Sstevel@tonic-gate {nfslog_fh3_print, nfslog_nfsstat3_print, "\"readdir\""}, 391*0Sstevel@tonic-gate 392*0Sstevel@tonic-gate /* NFSPROC3_READDIRPLUS = 17 */ 393*0Sstevel@tonic-gate {nfslog_READDIRPLUS3args_print, nfslog_READDIRPLUS3res_print, 394*0Sstevel@tonic-gate "\"readdirplus\""}, 395*0Sstevel@tonic-gate 396*0Sstevel@tonic-gate /* NFSPROC3_FSSTAT = 18 */ 397*0Sstevel@tonic-gate {nfslog_fh3_print, nfslog_nfsstat3_print, "\"fsstat\""}, 398*0Sstevel@tonic-gate 399*0Sstevel@tonic-gate /* NFSPROC3_FSINFO = 19 */ 400*0Sstevel@tonic-gate {nfslog_fh3_print, nfslog_nfsstat3_print, "\"fsinfo\""}, 401*0Sstevel@tonic-gate 402*0Sstevel@tonic-gate /* NFSPROC3_PATHCONF = 20 */ 403*0Sstevel@tonic-gate {nfslog_fh3_print, nfslog_nfsstat3_print, "\"pathconf\""}, 404*0Sstevel@tonic-gate 405*0Sstevel@tonic-gate /* NFSPROC3_COMMIT = 21 */ 406*0Sstevel@tonic-gate {nfslog_COMMIT3args_print, nfslog_nfsstat3_print, "\"commit\""}, 407*0Sstevel@tonic-gate }; 408*0Sstevel@tonic-gate 409*0Sstevel@tonic-gate /* 410*0Sstevel@tonic-gate * NFSLOG VERSION 1 411*0Sstevel@tonic-gate */ 412*0Sstevel@tonic-gate 413*0Sstevel@tonic-gate static struct nfsl_proc_disp nfsl_log_elf_proc_v1[] = { 414*0Sstevel@tonic-gate 415*0Sstevel@tonic-gate /* NFSLOG_NULL = 0 */ 416*0Sstevel@tonic-gate {nfslog_null_args, nfslog_null_res, "\"null\""}, 417*0Sstevel@tonic-gate 418*0Sstevel@tonic-gate /* NFSLOG_SHARE = 1 */ 419*0Sstevel@tonic-gate {nfslog_sharefsargs_print, nfslog_nfsstat_print, "\"log_share\""}, 420*0Sstevel@tonic-gate 421*0Sstevel@tonic-gate /* NFSLOG_UNSHARE = 2 */ 422*0Sstevel@tonic-gate {nfslog_sharefsargs_print, nfslog_nfsstat_print, "\"log_unshare\""}, 423*0Sstevel@tonic-gate 424*0Sstevel@tonic-gate /* NFSLOG_LOOKUP = 3 */ 425*0Sstevel@tonic-gate {nfslog_diropargs3_print, nfslog_LOOKUP3res_print, "\"lookup\""}, 426*0Sstevel@tonic-gate 427*0Sstevel@tonic-gate /* NFSLOG_GETFH = 4 */ 428*0Sstevel@tonic-gate {nfslog_getfhargs_print, nfslog_nfsstat_print, "\"log_getfh\""}, 429*0Sstevel@tonic-gate }; 430*0Sstevel@tonic-gate 431*0Sstevel@tonic-gate static struct nfsl_vers_disp nfsl_elf_vers_disptable[] = { 432*0Sstevel@tonic-gate {sizeof (nfsl_elf_proc_v2) / sizeof (nfsl_elf_proc_v2[0]), 433*0Sstevel@tonic-gate nfsl_elf_proc_v2}, 434*0Sstevel@tonic-gate {sizeof (nfsl_elf_proc_v3) / sizeof (nfsl_elf_proc_v3[0]), 435*0Sstevel@tonic-gate nfsl_elf_proc_v3}, 436*0Sstevel@tonic-gate }; 437*0Sstevel@tonic-gate 438*0Sstevel@tonic-gate static struct nfsl_vers_disp nfsl_log_elf_vers_disptable[] = { 439*0Sstevel@tonic-gate {sizeof (nfsl_log_elf_proc_v1) / sizeof (nfsl_log_elf_proc_v1[0]), 440*0Sstevel@tonic-gate nfsl_log_elf_proc_v1}, 441*0Sstevel@tonic-gate }; 442*0Sstevel@tonic-gate 443*0Sstevel@tonic-gate static struct nfsl_prog_disp nfsl_elf_dispatch_table[] = { 444*0Sstevel@tonic-gate {NFS_PROGRAM, 445*0Sstevel@tonic-gate NFS_VERSMIN, 446*0Sstevel@tonic-gate sizeof (nfsl_elf_vers_disptable) / 447*0Sstevel@tonic-gate sizeof (nfsl_elf_vers_disptable[0]), 448*0Sstevel@tonic-gate nfsl_elf_vers_disptable, "nfs"}, 449*0Sstevel@tonic-gate {NFSLOG_PROGRAM, 450*0Sstevel@tonic-gate NFSLOG_VERSMIN, 451*0Sstevel@tonic-gate sizeof (nfsl_log_elf_vers_disptable) / 452*0Sstevel@tonic-gate sizeof (nfsl_log_elf_vers_disptable[0]), 453*0Sstevel@tonic-gate nfsl_log_elf_vers_disptable, "nfslog"}, 454*0Sstevel@tonic-gate }; 455*0Sstevel@tonic-gate 456*0Sstevel@tonic-gate static int nfsl_elf_dispatch_table_arglen = 457*0Sstevel@tonic-gate sizeof (nfsl_elf_dispatch_table) / 458*0Sstevel@tonic-gate sizeof (nfsl_elf_dispatch_table[0]); 459*0Sstevel@tonic-gate 460*0Sstevel@tonic-gate static char * 461*0Sstevel@tonic-gate nfslog_get_status(short status) 462*0Sstevel@tonic-gate { 463*0Sstevel@tonic-gate int low, mid, high; 464*0Sstevel@tonic-gate short errstat; 465*0Sstevel@tonic-gate 466*0Sstevel@tonic-gate /* Usually status is 0... */ 467*0Sstevel@tonic-gate if (status == 0) 468*0Sstevel@tonic-gate return (nfsl_status_name[0]); 469*0Sstevel@tonic-gate 470*0Sstevel@tonic-gate low = 0; 471*0Sstevel@tonic-gate high = NFSL_ERR_CNT; 472*0Sstevel@tonic-gate mid = NFSL_ERR_CNT / 2; 473*0Sstevel@tonic-gate /* binary search for status string */ 474*0Sstevel@tonic-gate while (((errstat = nfsl_status[mid]) != status) && (low < mid) && 475*0Sstevel@tonic-gate (mid < high)) { 476*0Sstevel@tonic-gate if (errstat > status) { /* search bottom half */ 477*0Sstevel@tonic-gate high = mid; 478*0Sstevel@tonic-gate } else { /* search upper half */ 479*0Sstevel@tonic-gate low = mid; 480*0Sstevel@tonic-gate } 481*0Sstevel@tonic-gate mid = low + ((high - low) / 2); 482*0Sstevel@tonic-gate } 483*0Sstevel@tonic-gate if (errstat == status) { /* found it */ 484*0Sstevel@tonic-gate return (nfsl_status_name[mid]); 485*0Sstevel@tonic-gate } 486*0Sstevel@tonic-gate return (NULL); 487*0Sstevel@tonic-gate } 488*0Sstevel@tonic-gate 489*0Sstevel@tonic-gate /* nfsl_get_time - return string with time formatted as hh:mm:ss */ 490*0Sstevel@tonic-gate static char * 491*0Sstevel@tonic-gate nfsl_get_time(time_t tt) 492*0Sstevel@tonic-gate { 493*0Sstevel@tonic-gate static char timestr[20]; 494*0Sstevel@tonic-gate static time_t lasttime; 495*0Sstevel@tonic-gate struct tm tmst; 496*0Sstevel@tonic-gate 497*0Sstevel@tonic-gate if (tt == lasttime) 498*0Sstevel@tonic-gate return (timestr); 499*0Sstevel@tonic-gate if (localtime_r(&tt, &tmst) == NULL) { 500*0Sstevel@tonic-gate return (empty_name); 501*0Sstevel@tonic-gate } 502*0Sstevel@tonic-gate (void) sprintf(timestr, "%02d:%02d:%02d", 503*0Sstevel@tonic-gate tmst.tm_hour, tmst.tm_min, tmst.tm_sec); 504*0Sstevel@tonic-gate lasttime = tt; 505*0Sstevel@tonic-gate return (timestr); 506*0Sstevel@tonic-gate } 507*0Sstevel@tonic-gate 508*0Sstevel@tonic-gate /* nfsl_get_date - return date string formatted as "yyyy-mm-dd hh:mm:ss" */ 509*0Sstevel@tonic-gate static char * 510*0Sstevel@tonic-gate nfsl_get_date(time_t tt) 511*0Sstevel@tonic-gate { 512*0Sstevel@tonic-gate static char timestr[30]; 513*0Sstevel@tonic-gate static time_t lasttime; 514*0Sstevel@tonic-gate struct tm tmst; 515*0Sstevel@tonic-gate 516*0Sstevel@tonic-gate if (tt == lasttime) 517*0Sstevel@tonic-gate return (timestr); 518*0Sstevel@tonic-gate if (localtime_r(&tt, &tmst) == NULL) { 519*0Sstevel@tonic-gate return (empty_name); 520*0Sstevel@tonic-gate } 521*0Sstevel@tonic-gate (void) sprintf(timestr, "\"%04d-%02d-%02d %02d:%02d:%02d\"", 522*0Sstevel@tonic-gate tmst.tm_year + 1900, tmst.tm_mon + 1, tmst.tm_mday, 523*0Sstevel@tonic-gate tmst.tm_hour, tmst.tm_min, tmst.tm_sec); 524*0Sstevel@tonic-gate lasttime = tt; 525*0Sstevel@tonic-gate return (timestr); 526*0Sstevel@tonic-gate } 527*0Sstevel@tonic-gate 528*0Sstevel@tonic-gate /* 529*0Sstevel@tonic-gate * nfsl_get_date_nq - return date string formatted as yyyy-mm-dd hh:mm:ss 530*0Sstevel@tonic-gate * (no quotes) 531*0Sstevel@tonic-gate */ 532*0Sstevel@tonic-gate static char * 533*0Sstevel@tonic-gate nfsl_get_date_nq(time_t tt) 534*0Sstevel@tonic-gate { 535*0Sstevel@tonic-gate static char timestr[30]; 536*0Sstevel@tonic-gate static time_t lasttime; 537*0Sstevel@tonic-gate struct tm tmst; 538*0Sstevel@tonic-gate 539*0Sstevel@tonic-gate if (tt == lasttime) 540*0Sstevel@tonic-gate return (timestr); 541*0Sstevel@tonic-gate if (localtime_r(&tt, &tmst) == NULL) { 542*0Sstevel@tonic-gate return (empty_name); 543*0Sstevel@tonic-gate } 544*0Sstevel@tonic-gate (void) sprintf(timestr, "%04d-%02d-%02d %02d:%02d:%02d", 545*0Sstevel@tonic-gate tmst.tm_year + 1900, tmst.tm_mon + 1, tmst.tm_mday, 546*0Sstevel@tonic-gate tmst.tm_hour, tmst.tm_min, tmst.tm_sec); 547*0Sstevel@tonic-gate return (timestr); 548*0Sstevel@tonic-gate } 549*0Sstevel@tonic-gate 550*0Sstevel@tonic-gate /* write log buffer out to file */ 551*0Sstevel@tonic-gate static int 552*0Sstevel@tonic-gate nfsl_write_elfbuf(struct nfsl_log_file *elfrec) 553*0Sstevel@tonic-gate { 554*0Sstevel@tonic-gate int rc; 555*0Sstevel@tonic-gate char *elfbuf = elfrec->buf; 556*0Sstevel@tonic-gate int elfbufoffset = elfrec->bufoffset; 557*0Sstevel@tonic-gate 558*0Sstevel@tonic-gate if (debug > 1) 559*0Sstevel@tonic-gate (void) printf("nfsl_write_elfbuf: bufoffset %d\n", 560*0Sstevel@tonic-gate elfbufoffset); 561*0Sstevel@tonic-gate if (elfbufoffset <= 0) 562*0Sstevel@tonic-gate return (0); 563*0Sstevel@tonic-gate elfbuf[elfbufoffset] = '\0'; 564*0Sstevel@tonic-gate if ((rc = fputs(elfbuf, elfrec->fp)) < 0) { 565*0Sstevel@tonic-gate syslog(LOG_ERR, gettext("Write to %s failed: %s\n"), 566*0Sstevel@tonic-gate elfrec->path, strerror(errno)); 567*0Sstevel@tonic-gate return (-1); 568*0Sstevel@tonic-gate } 569*0Sstevel@tonic-gate if (rc != elfbufoffset) { 570*0Sstevel@tonic-gate syslog(LOG_ERR, gettext("Write %d bytes to %s returned %d\n"), 571*0Sstevel@tonic-gate elfbufoffset, elfrec->path, rc); 572*0Sstevel@tonic-gate return (-1); 573*0Sstevel@tonic-gate } 574*0Sstevel@tonic-gate elfrec->bufoffset = 0; 575*0Sstevel@tonic-gate return (0); 576*0Sstevel@tonic-gate } 577*0Sstevel@tonic-gate 578*0Sstevel@tonic-gate /*ARGSUSED*/ 579*0Sstevel@tonic-gate static void 580*0Sstevel@tonic-gate nfslog_null_args(struct nfsl_log_file *elfrec, caddr_t *nfsl_args) 581*0Sstevel@tonic-gate { 582*0Sstevel@tonic-gate } 583*0Sstevel@tonic-gate 584*0Sstevel@tonic-gate /*ARGSUSED*/ 585*0Sstevel@tonic-gate static void 586*0Sstevel@tonic-gate nfslog_null_res(struct nfsl_log_file *elfrec, caddr_t *nfsl_res) 587*0Sstevel@tonic-gate { 588*0Sstevel@tonic-gate } 589*0Sstevel@tonic-gate 590*0Sstevel@tonic-gate static void 591*0Sstevel@tonic-gate nfslog_fh3_print(struct nfsl_log_file *elfrec, nfs_fh3 *fh3) 592*0Sstevel@tonic-gate { 593*0Sstevel@tonic-gate if (!nfsl_print_fh) 594*0Sstevel@tonic-gate return; 595*0Sstevel@tonic-gate if (fh3->fh3_length == sizeof (fh3->fh3_u.nfs_fh3_i.fh3_i)) { 596*0Sstevel@tonic-gate nfslog_fhandle_print(elfrec, &fh3->fh3_u.nfs_fh3_i.fh3_i); 597*0Sstevel@tonic-gate } else { 598*0Sstevel@tonic-gate nfslog_opaque_print_buf(fh3->fh3_u.data, fh3->fh3_length, 599*0Sstevel@tonic-gate elfrec->buf, &elfrec->bufoffset, 600*0Sstevel@tonic-gate DFLT_BUFFERSIZE + DFLT_OVFSIZE); 601*0Sstevel@tonic-gate } 602*0Sstevel@tonic-gate } 603*0Sstevel@tonic-gate 604*0Sstevel@tonic-gate /* 605*0Sstevel@tonic-gate * NFS VERSION 2 606*0Sstevel@tonic-gate */ 607*0Sstevel@tonic-gate 608*0Sstevel@tonic-gate 609*0Sstevel@tonic-gate /* Functions that elf print the arguments */ 610*0Sstevel@tonic-gate 611*0Sstevel@tonic-gate static void 612*0Sstevel@tonic-gate nfslog_fhandle_print(struct nfsl_log_file *elfrec, fhandle_t *args) 613*0Sstevel@tonic-gate { 614*0Sstevel@tonic-gate if (!nfsl_print_fh) 615*0Sstevel@tonic-gate return; 616*0Sstevel@tonic-gate nfslog_opaque_print_buf(args, sizeof (*args), 617*0Sstevel@tonic-gate elfrec->buf, &elfrec->bufoffset, 618*0Sstevel@tonic-gate DFLT_BUFFERSIZE + DFLT_OVFSIZE); 619*0Sstevel@tonic-gate } 620*0Sstevel@tonic-gate 621*0Sstevel@tonic-gate static void 622*0Sstevel@tonic-gate nfslog_diropargs_print(struct nfsl_log_file *elfrec, nfslog_diropargs *args) 623*0Sstevel@tonic-gate { 624*0Sstevel@tonic-gate char *elfbuf = elfrec->buf; 625*0Sstevel@tonic-gate int elfbufoffset = elfrec->bufoffset; 626*0Sstevel@tonic-gate 627*0Sstevel@tonic-gate if (nfsl_print_fh) { 628*0Sstevel@tonic-gate nfslog_fhandle_print(elfrec, &args->da_fhandle); 629*0Sstevel@tonic-gate elfbufoffset = elfrec->bufoffset; 630*0Sstevel@tonic-gate if (args->da_name != NULL) { 631*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], 632*0Sstevel@tonic-gate " \"%s\"", args->da_name); 633*0Sstevel@tonic-gate } else { 634*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " %s", 635*0Sstevel@tonic-gate empty_name); 636*0Sstevel@tonic-gate } 637*0Sstevel@tonic-gate } 638*0Sstevel@tonic-gate elfrec->bufoffset = elfbufoffset; 639*0Sstevel@tonic-gate } 640*0Sstevel@tonic-gate 641*0Sstevel@tonic-gate static void 642*0Sstevel@tonic-gate nfslog_sattr_print(struct nfsl_log_file *elfrec, nfslog_sattr *args) 643*0Sstevel@tonic-gate { 644*0Sstevel@tonic-gate char *elfbuf = elfrec->buf; 645*0Sstevel@tonic-gate int elfbufoffset = elfrec->bufoffset; 646*0Sstevel@tonic-gate 647*0Sstevel@tonic-gate /* BEGIN CSTYLED */ 648*0Sstevel@tonic-gate if (args->sa_mode != (uint32_t)-1) { 649*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], 650*0Sstevel@tonic-gate " \"mode=0%o\"", args->sa_mode); 651*0Sstevel@tonic-gate } 652*0Sstevel@tonic-gate if (args->sa_uid != (uint32_t)-1) { 653*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], 654*0Sstevel@tonic-gate " \"uid=0x%x\"", args->sa_uid); 655*0Sstevel@tonic-gate } 656*0Sstevel@tonic-gate if (args->sa_gid != (uint32_t)-1) { 657*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], 658*0Sstevel@tonic-gate " \"gid=0x%x\"", args->sa_gid); 659*0Sstevel@tonic-gate } 660*0Sstevel@tonic-gate if (args->sa_size != (uint32_t)-1) { 661*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], 662*0Sstevel@tonic-gate " \"size=0x%x\"", args->sa_size); 663*0Sstevel@tonic-gate } 664*0Sstevel@tonic-gate if (args->sa_atime.tv_sec != (uint32_t)-1) { 665*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], 666*0Sstevel@tonic-gate " \"atime=%s\"", 667*0Sstevel@tonic-gate nfsl_get_date_nq((time_t)args->sa_atime.tv_sec)); 668*0Sstevel@tonic-gate } 669*0Sstevel@tonic-gate if (args->sa_mtime.tv_sec != (uint32_t)-1) { 670*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], 671*0Sstevel@tonic-gate " \"mtime=%s\"", 672*0Sstevel@tonic-gate nfsl_get_date_nq((time_t)args->sa_mtime.tv_sec)); 673*0Sstevel@tonic-gate } 674*0Sstevel@tonic-gate /* END CSTYLED */ 675*0Sstevel@tonic-gate elfrec->bufoffset = elfbufoffset; 676*0Sstevel@tonic-gate } 677*0Sstevel@tonic-gate 678*0Sstevel@tonic-gate static void 679*0Sstevel@tonic-gate nfslog_setattrargs_print(struct nfsl_log_file *elfrec, nfslog_setattrargs *args) 680*0Sstevel@tonic-gate { 681*0Sstevel@tonic-gate nfslog_fhandle_print(elfrec, &args->saa_fh); 682*0Sstevel@tonic-gate nfslog_sattr_print(elfrec, &args->saa_sa); 683*0Sstevel@tonic-gate } 684*0Sstevel@tonic-gate 685*0Sstevel@tonic-gate static void 686*0Sstevel@tonic-gate nfslog_nfsreadargs_print(struct nfsl_log_file *elfrec, 687*0Sstevel@tonic-gate nfslog_nfsreadargs *args) 688*0Sstevel@tonic-gate { 689*0Sstevel@tonic-gate char *elfbuf = elfrec->buf; 690*0Sstevel@tonic-gate int elfbufoffset; 691*0Sstevel@tonic-gate 692*0Sstevel@tonic-gate nfslog_fhandle_print(elfrec, &args->ra_fhandle); 693*0Sstevel@tonic-gate elfbufoffset = elfrec->bufoffset; 694*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%x", 695*0Sstevel@tonic-gate args->ra_offset); 696*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%x", 697*0Sstevel@tonic-gate args->ra_count); 698*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%x", 699*0Sstevel@tonic-gate args->ra_totcount); 700*0Sstevel@tonic-gate elfrec->bufoffset = elfbufoffset; 701*0Sstevel@tonic-gate } 702*0Sstevel@tonic-gate 703*0Sstevel@tonic-gate static void 704*0Sstevel@tonic-gate nfslog_writeargs_print(struct nfsl_log_file *elfrec, nfslog_writeargs *args) 705*0Sstevel@tonic-gate { 706*0Sstevel@tonic-gate char *elfbuf = elfrec->buf; 707*0Sstevel@tonic-gate int elfbufoffset = elfrec->bufoffset; 708*0Sstevel@tonic-gate 709*0Sstevel@tonic-gate nfslog_fhandle_print(elfrec, &args->waargs_fhandle); 710*0Sstevel@tonic-gate elfbufoffset = elfrec->bufoffset; 711*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%x", 712*0Sstevel@tonic-gate args->waargs_begoff); 713*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%x", 714*0Sstevel@tonic-gate args->waargs_offset); 715*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%x", 716*0Sstevel@tonic-gate args->waargs_totcount); 717*0Sstevel@tonic-gate elfrec->bufoffset += sprintf(&elfrec->buf[elfrec->bufoffset], " 0x%x", 718*0Sstevel@tonic-gate args->waargs_count); 719*0Sstevel@tonic-gate } 720*0Sstevel@tonic-gate 721*0Sstevel@tonic-gate static void 722*0Sstevel@tonic-gate nfslog_writeresult_print(struct nfsl_log_file *elfrec, nfslog_writeresult *res, 723*0Sstevel@tonic-gate bool_t print_status) 724*0Sstevel@tonic-gate { 725*0Sstevel@tonic-gate char *elfbuf = elfrec->buf; 726*0Sstevel@tonic-gate int elfbufoffset = elfrec->bufoffset; 727*0Sstevel@tonic-gate 728*0Sstevel@tonic-gate if (print_status) { 729*0Sstevel@tonic-gate nfslog_nfsstat_print(elfrec, &res->wr_status, print_status); 730*0Sstevel@tonic-gate } else if (res->wr_status == NFS_OK) { 731*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%x", 732*0Sstevel@tonic-gate res->nfslog_writeresult_u.wr_size); 733*0Sstevel@tonic-gate elfrec->bufoffset = elfbufoffset; 734*0Sstevel@tonic-gate } 735*0Sstevel@tonic-gate } 736*0Sstevel@tonic-gate 737*0Sstevel@tonic-gate static void 738*0Sstevel@tonic-gate nfslog_creatargs_print(struct nfsl_log_file *elfrec, nfslog_createargs *args) 739*0Sstevel@tonic-gate { 740*0Sstevel@tonic-gate nfslog_diropargs_print(elfrec, &args->ca_da); 741*0Sstevel@tonic-gate nfslog_sattr_print(elfrec, &args->ca_sa); 742*0Sstevel@tonic-gate } 743*0Sstevel@tonic-gate 744*0Sstevel@tonic-gate 745*0Sstevel@tonic-gate static void 746*0Sstevel@tonic-gate nfslog_rddirargs_print(struct nfsl_log_file *elfrec, nfslog_rddirargs *args) 747*0Sstevel@tonic-gate { 748*0Sstevel@tonic-gate char *elfbuf = elfrec->buf; 749*0Sstevel@tonic-gate int elfbufoffset; 750*0Sstevel@tonic-gate 751*0Sstevel@tonic-gate nfslog_fhandle_print(elfrec, &args->rda_fh); 752*0Sstevel@tonic-gate elfbufoffset = elfrec->bufoffset; 753*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%x", 754*0Sstevel@tonic-gate args->rda_offset); 755*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%x", 756*0Sstevel@tonic-gate args->rda_count); 757*0Sstevel@tonic-gate elfrec->bufoffset = elfbufoffset; 758*0Sstevel@tonic-gate } 759*0Sstevel@tonic-gate 760*0Sstevel@tonic-gate static void 761*0Sstevel@tonic-gate nfslog_rnmargs_print(struct nfsl_log_file *elfrec, nfslog_rnmargs *args) 762*0Sstevel@tonic-gate { 763*0Sstevel@tonic-gate nfslog_diropargs_print(elfrec, &args->rna_from); 764*0Sstevel@tonic-gate nfslog_diropargs_print(elfrec, &args->rna_to); 765*0Sstevel@tonic-gate } 766*0Sstevel@tonic-gate 767*0Sstevel@tonic-gate static void 768*0Sstevel@tonic-gate nfslog_linkargs_print(struct nfsl_log_file *elfrec, nfslog_linkargs *args) 769*0Sstevel@tonic-gate { 770*0Sstevel@tonic-gate nfslog_fhandle_print(elfrec, &args->la_from); 771*0Sstevel@tonic-gate nfslog_diropargs_print(elfrec, &args->la_to); 772*0Sstevel@tonic-gate } 773*0Sstevel@tonic-gate 774*0Sstevel@tonic-gate static void 775*0Sstevel@tonic-gate nfslog_symlinkargs_print(struct nfsl_log_file *elfrec, nfslog_symlinkargs *args) 776*0Sstevel@tonic-gate { 777*0Sstevel@tonic-gate char *elfbuf = elfrec->buf; 778*0Sstevel@tonic-gate int elfbufoffset; 779*0Sstevel@tonic-gate 780*0Sstevel@tonic-gate nfslog_diropargs_print(elfrec, &args->sla_from); 781*0Sstevel@tonic-gate elfbufoffset = elfrec->bufoffset; 782*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " \"%s\"", 783*0Sstevel@tonic-gate args->sla_tnm); 784*0Sstevel@tonic-gate elfrec->bufoffset = elfbufoffset; 785*0Sstevel@tonic-gate nfslog_sattr_print(elfrec, &args->sla_sa); 786*0Sstevel@tonic-gate } 787*0Sstevel@tonic-gate 788*0Sstevel@tonic-gate /* 789*0Sstevel@tonic-gate * SHARE/UNSHARE fs log args copy 790*0Sstevel@tonic-gate */ 791*0Sstevel@tonic-gate static void 792*0Sstevel@tonic-gate nfslog_sharefsargs_print(struct nfsl_log_file *elfrec, 793*0Sstevel@tonic-gate nfslog_sharefsargs *args) 794*0Sstevel@tonic-gate { 795*0Sstevel@tonic-gate unsigned int elfbufoffset; 796*0Sstevel@tonic-gate char *elfbuf = elfrec->buf; 797*0Sstevel@tonic-gate 798*0Sstevel@tonic-gate nfslog_fhandle_print(elfrec, &args->sh_fh_buf); 799*0Sstevel@tonic-gate 800*0Sstevel@tonic-gate elfbufoffset = elfrec->bufoffset; 801*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%x", 802*0Sstevel@tonic-gate args->sh_flags); 803*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%x", 804*0Sstevel@tonic-gate args->sh_anon); 805*0Sstevel@tonic-gate if (nfsl_print_fh) { 806*0Sstevel@tonic-gate if (args->sh_path != NULL) { 807*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], 808*0Sstevel@tonic-gate " \"%s\"", args->sh_path); 809*0Sstevel@tonic-gate } else { 810*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " %s", 811*0Sstevel@tonic-gate empty_name); 812*0Sstevel@tonic-gate } 813*0Sstevel@tonic-gate } 814*0Sstevel@tonic-gate elfrec->bufoffset = elfbufoffset; 815*0Sstevel@tonic-gate } 816*0Sstevel@tonic-gate 817*0Sstevel@tonic-gate static void 818*0Sstevel@tonic-gate nfslog_getfhargs_print(struct nfsl_log_file *elfrec, 819*0Sstevel@tonic-gate nfslog_getfhargs *args) 820*0Sstevel@tonic-gate { 821*0Sstevel@tonic-gate unsigned int elfbufoffset; 822*0Sstevel@tonic-gate char *elfbuf = elfrec->buf; 823*0Sstevel@tonic-gate 824*0Sstevel@tonic-gate nfslog_fhandle_print(elfrec, &args->gfh_fh_buf); 825*0Sstevel@tonic-gate 826*0Sstevel@tonic-gate elfbufoffset = elfrec->bufoffset; 827*0Sstevel@tonic-gate if (nfsl_print_fh) { 828*0Sstevel@tonic-gate if (args->gfh_path != NULL) { 829*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], 830*0Sstevel@tonic-gate " \"%s\"", args->gfh_path); 831*0Sstevel@tonic-gate } else { 832*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " %s", 833*0Sstevel@tonic-gate empty_name); 834*0Sstevel@tonic-gate } 835*0Sstevel@tonic-gate } 836*0Sstevel@tonic-gate elfrec->bufoffset = elfbufoffset; 837*0Sstevel@tonic-gate } 838*0Sstevel@tonic-gate 839*0Sstevel@tonic-gate static void 840*0Sstevel@tonic-gate nfslog_nfsstat_print(struct nfsl_log_file *elfrec, enum nfsstat *res, 841*0Sstevel@tonic-gate bool_t print_status) 842*0Sstevel@tonic-gate { 843*0Sstevel@tonic-gate if (print_status) { 844*0Sstevel@tonic-gate char *statp = nfslog_get_status((short)(*res)); 845*0Sstevel@tonic-gate 846*0Sstevel@tonic-gate if (statp != NULL) 847*0Sstevel@tonic-gate elfrec->bufoffset += 848*0Sstevel@tonic-gate sprintf(&elfrec->buf[elfrec->bufoffset], " %s", 849*0Sstevel@tonic-gate statp); 850*0Sstevel@tonic-gate else 851*0Sstevel@tonic-gate elfrec->bufoffset += 852*0Sstevel@tonic-gate sprintf(&elfrec->buf[elfrec->bufoffset], " %5d", 853*0Sstevel@tonic-gate *res); 854*0Sstevel@tonic-gate } 855*0Sstevel@tonic-gate } 856*0Sstevel@tonic-gate 857*0Sstevel@tonic-gate static void 858*0Sstevel@tonic-gate nfslog_diropres_print(struct nfsl_log_file *elfrec, nfslog_diropres *res, 859*0Sstevel@tonic-gate bool_t print_status) 860*0Sstevel@tonic-gate { 861*0Sstevel@tonic-gate if (print_status) { 862*0Sstevel@tonic-gate nfslog_nfsstat_print(elfrec, &res->dr_status, print_status); 863*0Sstevel@tonic-gate } else if (res->dr_status == NFS_OK) { 864*0Sstevel@tonic-gate nfslog_fhandle_print(elfrec, 865*0Sstevel@tonic-gate &res->nfslog_diropres_u.dr_ok.drok_fhandle); 866*0Sstevel@tonic-gate } 867*0Sstevel@tonic-gate } 868*0Sstevel@tonic-gate 869*0Sstevel@tonic-gate static void 870*0Sstevel@tonic-gate nfslog_rdlnres_print(struct nfsl_log_file *elfrec, nfslog_rdlnres *res, 871*0Sstevel@tonic-gate bool_t print_status) 872*0Sstevel@tonic-gate { 873*0Sstevel@tonic-gate if (print_status) { 874*0Sstevel@tonic-gate nfslog_nfsstat_print(elfrec, &res->rl_status, print_status); 875*0Sstevel@tonic-gate } else if (res->rl_status == NFS_OK) { 876*0Sstevel@tonic-gate elfrec->bufoffset += sprintf(&elfrec->buf[elfrec->bufoffset], 877*0Sstevel@tonic-gate " \"%s\"", res->nfslog_rdlnres_u.rl_ok); 878*0Sstevel@tonic-gate } 879*0Sstevel@tonic-gate } 880*0Sstevel@tonic-gate 881*0Sstevel@tonic-gate static void 882*0Sstevel@tonic-gate nfslog_rdresult_print(struct nfsl_log_file *elfrec, nfslog_rdresult *res, 883*0Sstevel@tonic-gate bool_t print_status) 884*0Sstevel@tonic-gate { 885*0Sstevel@tonic-gate if (print_status) { 886*0Sstevel@tonic-gate nfslog_nfsstat_print(elfrec, &res->r_status, print_status); 887*0Sstevel@tonic-gate } else if (res->r_status == NFS_OK) { 888*0Sstevel@tonic-gate elfrec->bufoffset += sprintf(&elfrec->buf[elfrec->bufoffset], 889*0Sstevel@tonic-gate " 0x%x", res->nfslog_rdresult_u.r_ok.filesize); 890*0Sstevel@tonic-gate elfrec->bufoffset += sprintf(&elfrec->buf[elfrec->bufoffset], 891*0Sstevel@tonic-gate " 0x%x", res->nfslog_rdresult_u.r_ok.rrok_count); 892*0Sstevel@tonic-gate } 893*0Sstevel@tonic-gate } 894*0Sstevel@tonic-gate 895*0Sstevel@tonic-gate static void 896*0Sstevel@tonic-gate nfslog_rddirres_print(struct nfsl_log_file *elfrec, nfslog_rddirres *res, 897*0Sstevel@tonic-gate bool_t print_status) 898*0Sstevel@tonic-gate { 899*0Sstevel@tonic-gate if (print_status) { 900*0Sstevel@tonic-gate nfslog_nfsstat_print(elfrec, &res->rd_status, print_status); 901*0Sstevel@tonic-gate } else if (res->rd_status == NFS_OK) { 902*0Sstevel@tonic-gate char *elfbuf = elfrec->buf; 903*0Sstevel@tonic-gate int elfbufoffset = elfrec->bufoffset; 904*0Sstevel@tonic-gate 905*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%x", 906*0Sstevel@tonic-gate res->nfslog_rddirres_u.rd_ok.rdok_offset); 907*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%x", 908*0Sstevel@tonic-gate res->nfslog_rddirres_u.rd_ok.rdok_size); 909*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%x", 910*0Sstevel@tonic-gate res->nfslog_rddirres_u.rd_ok.rdok_eof); 911*0Sstevel@tonic-gate elfrec->bufoffset = elfbufoffset; 912*0Sstevel@tonic-gate } 913*0Sstevel@tonic-gate } 914*0Sstevel@tonic-gate 915*0Sstevel@tonic-gate /* 916*0Sstevel@tonic-gate * NFS VERSION 3 917*0Sstevel@tonic-gate */ 918*0Sstevel@tonic-gate 919*0Sstevel@tonic-gate static void 920*0Sstevel@tonic-gate nfslog_diropargs3_print(struct nfsl_log_file *elfrec, 921*0Sstevel@tonic-gate nfslog_diropargs3 *args) 922*0Sstevel@tonic-gate { 923*0Sstevel@tonic-gate if (nfsl_print_fh) { 924*0Sstevel@tonic-gate nfslog_fh3_print(elfrec, &args->dir); 925*0Sstevel@tonic-gate elfrec->bufoffset += sprintf(&elfrec->buf[elfrec->bufoffset], 926*0Sstevel@tonic-gate " \"%s\"", args->name); 927*0Sstevel@tonic-gate } 928*0Sstevel@tonic-gate } 929*0Sstevel@tonic-gate 930*0Sstevel@tonic-gate static void 931*0Sstevel@tonic-gate nfslog_size3_print(struct nfsl_log_file *elfrec, set_size3 *args) 932*0Sstevel@tonic-gate { 933*0Sstevel@tonic-gate char *elfbuf = elfrec->buf; 934*0Sstevel@tonic-gate int elfbufoffset = elfrec->bufoffset; 935*0Sstevel@tonic-gate 936*0Sstevel@tonic-gate if (args->set_it) { 937*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], 938*0Sstevel@tonic-gate /* CSTYLED */ 939*0Sstevel@tonic-gate " \"size=0x%llx\"", args->size); 940*0Sstevel@tonic-gate } 941*0Sstevel@tonic-gate elfrec->bufoffset = elfbufoffset; 942*0Sstevel@tonic-gate } 943*0Sstevel@tonic-gate 944*0Sstevel@tonic-gate static void 945*0Sstevel@tonic-gate nfslog_SETATTR3args_print(struct nfsl_log_file *elfrec, 946*0Sstevel@tonic-gate nfslog_SETATTR3args *args) 947*0Sstevel@tonic-gate { 948*0Sstevel@tonic-gate nfslog_fh3_print(elfrec, &args->object); 949*0Sstevel@tonic-gate nfslog_size3_print(elfrec, &args->size); 950*0Sstevel@tonic-gate } 951*0Sstevel@tonic-gate 952*0Sstevel@tonic-gate static void 953*0Sstevel@tonic-gate nfslog_READ3args_print(struct nfsl_log_file *elfrec, nfslog_READ3args *args) 954*0Sstevel@tonic-gate { 955*0Sstevel@tonic-gate nfslog_fh3_print(elfrec, &args->file); 956*0Sstevel@tonic-gate elfrec->bufoffset += sprintf(&elfrec->buf[elfrec->bufoffset], " 0x%llx", 957*0Sstevel@tonic-gate args->offset); 958*0Sstevel@tonic-gate elfrec->bufoffset += sprintf(&elfrec->buf[elfrec->bufoffset], " 0x%x", 959*0Sstevel@tonic-gate args->count); 960*0Sstevel@tonic-gate } 961*0Sstevel@tonic-gate 962*0Sstevel@tonic-gate static void 963*0Sstevel@tonic-gate nfslog_WRITE3args_print(struct nfsl_log_file *elfrec, 964*0Sstevel@tonic-gate nfslog_WRITE3args *args) 965*0Sstevel@tonic-gate { 966*0Sstevel@tonic-gate char *elfbuf = elfrec->buf; 967*0Sstevel@tonic-gate int elfbufoffset; 968*0Sstevel@tonic-gate 969*0Sstevel@tonic-gate nfslog_fh3_print(elfrec, &args->file); 970*0Sstevel@tonic-gate elfbufoffset = elfrec->bufoffset; 971*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%llx", 972*0Sstevel@tonic-gate args->offset); 973*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%x", 974*0Sstevel@tonic-gate args->count); 975*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%x", 976*0Sstevel@tonic-gate args->stable); 977*0Sstevel@tonic-gate elfrec->bufoffset = elfbufoffset; 978*0Sstevel@tonic-gate } 979*0Sstevel@tonic-gate 980*0Sstevel@tonic-gate static void 981*0Sstevel@tonic-gate nfslog_CREATE3args_print(struct nfsl_log_file *elfrec, 982*0Sstevel@tonic-gate nfslog_CREATE3args *args) 983*0Sstevel@tonic-gate { 984*0Sstevel@tonic-gate nfslog_diropargs3_print(elfrec, &args->where); 985*0Sstevel@tonic-gate elfrec->bufoffset += sprintf(&elfrec->buf[elfrec->bufoffset], " %s", 986*0Sstevel@tonic-gate NFSL_CREATEMODE3(args->how.mode)); 987*0Sstevel@tonic-gate if (args->how.mode != EXCLUSIVE) { 988*0Sstevel@tonic-gate nfslog_size3_print(elfrec, 989*0Sstevel@tonic-gate &args->how.nfslog_createhow3_u.size); 990*0Sstevel@tonic-gate } 991*0Sstevel@tonic-gate } 992*0Sstevel@tonic-gate 993*0Sstevel@tonic-gate static void 994*0Sstevel@tonic-gate nfslog_MKDIR3args_print(struct nfsl_log_file *elfrec, 995*0Sstevel@tonic-gate nfslog_MKDIR3args *args) 996*0Sstevel@tonic-gate { 997*0Sstevel@tonic-gate nfslog_diropargs3_print(elfrec, &args->where); 998*0Sstevel@tonic-gate } 999*0Sstevel@tonic-gate 1000*0Sstevel@tonic-gate static void 1001*0Sstevel@tonic-gate nfslog_SYMLINK3args_print(struct nfsl_log_file *elfrec, 1002*0Sstevel@tonic-gate nfslog_SYMLINK3args *args) 1003*0Sstevel@tonic-gate { 1004*0Sstevel@tonic-gate nfslog_diropargs3_print(elfrec, &args->where); 1005*0Sstevel@tonic-gate elfrec->bufoffset += sprintf(&elfrec->buf[elfrec->bufoffset], 1006*0Sstevel@tonic-gate " \"%s\"", args->symlink_data); 1007*0Sstevel@tonic-gate } 1008*0Sstevel@tonic-gate 1009*0Sstevel@tonic-gate static void 1010*0Sstevel@tonic-gate nfslog_MKNOD3args_print(struct nfsl_log_file *elfrec, 1011*0Sstevel@tonic-gate nfslog_MKNOD3args *args) 1012*0Sstevel@tonic-gate { 1013*0Sstevel@tonic-gate nfslog_diropargs3_print(elfrec, &args->where); 1014*0Sstevel@tonic-gate elfrec->bufoffset += sprintf(&elfrec->buf[elfrec->bufoffset], " %s", 1015*0Sstevel@tonic-gate NFSL_FTYPE3(args->type)); 1016*0Sstevel@tonic-gate } 1017*0Sstevel@tonic-gate 1018*0Sstevel@tonic-gate static void 1019*0Sstevel@tonic-gate nfslog_REMOVE3args_print(struct nfsl_log_file *elfrec, 1020*0Sstevel@tonic-gate nfslog_REMOVE3args *args) 1021*0Sstevel@tonic-gate { 1022*0Sstevel@tonic-gate nfslog_diropargs3_print(elfrec, &args->object); 1023*0Sstevel@tonic-gate } 1024*0Sstevel@tonic-gate 1025*0Sstevel@tonic-gate static void 1026*0Sstevel@tonic-gate nfslog_RMDIR3args_print(struct nfsl_log_file *elfrec, 1027*0Sstevel@tonic-gate nfslog_RMDIR3args *args) 1028*0Sstevel@tonic-gate { 1029*0Sstevel@tonic-gate nfslog_diropargs3_print(elfrec, &args->object); 1030*0Sstevel@tonic-gate } 1031*0Sstevel@tonic-gate 1032*0Sstevel@tonic-gate static void 1033*0Sstevel@tonic-gate nfslog_RENAME3args_print(struct nfsl_log_file *elfrec, 1034*0Sstevel@tonic-gate nfslog_RENAME3args *args) 1035*0Sstevel@tonic-gate { 1036*0Sstevel@tonic-gate nfslog_diropargs3_print(elfrec, &args->from); 1037*0Sstevel@tonic-gate nfslog_diropargs3_print(elfrec, &args->to); 1038*0Sstevel@tonic-gate } 1039*0Sstevel@tonic-gate 1040*0Sstevel@tonic-gate static void 1041*0Sstevel@tonic-gate nfslog_LINK3args_print(struct nfsl_log_file *elfrec, nfslog_LINK3args *args) 1042*0Sstevel@tonic-gate { 1043*0Sstevel@tonic-gate nfslog_fh3_print(elfrec, &args->file); 1044*0Sstevel@tonic-gate nfslog_diropargs3_print(elfrec, &args->link); 1045*0Sstevel@tonic-gate } 1046*0Sstevel@tonic-gate 1047*0Sstevel@tonic-gate static void 1048*0Sstevel@tonic-gate nfslog_READDIRPLUS3args_print(struct nfsl_log_file *elfrec, 1049*0Sstevel@tonic-gate nfslog_READDIRPLUS3args *args) 1050*0Sstevel@tonic-gate { 1051*0Sstevel@tonic-gate nfslog_fh3_print(elfrec, &args->dir); 1052*0Sstevel@tonic-gate elfrec->bufoffset += sprintf(&elfrec->buf[elfrec->bufoffset], " 0x%x", 1053*0Sstevel@tonic-gate args->dircount); 1054*0Sstevel@tonic-gate elfrec->bufoffset += sprintf(&elfrec->buf[elfrec->bufoffset], " 0x%x", 1055*0Sstevel@tonic-gate args->maxcount); 1056*0Sstevel@tonic-gate } 1057*0Sstevel@tonic-gate 1058*0Sstevel@tonic-gate static void 1059*0Sstevel@tonic-gate nfslog_COMMIT3args_print(struct nfsl_log_file *elfrec, 1060*0Sstevel@tonic-gate nfslog_COMMIT3args *args) 1061*0Sstevel@tonic-gate { 1062*0Sstevel@tonic-gate nfslog_fh3_print(elfrec, &args->file); 1063*0Sstevel@tonic-gate elfrec->bufoffset += sprintf(&elfrec->buf[elfrec->bufoffset], " 0x%llx", 1064*0Sstevel@tonic-gate args->offset); 1065*0Sstevel@tonic-gate elfrec->bufoffset += sprintf(&elfrec->buf[elfrec->bufoffset], " 0x%x", 1066*0Sstevel@tonic-gate args->count); 1067*0Sstevel@tonic-gate } 1068*0Sstevel@tonic-gate 1069*0Sstevel@tonic-gate static void 1070*0Sstevel@tonic-gate nfslog_nfsstat3_print(struct nfsl_log_file *elfrec, enum nfsstat3 *res, 1071*0Sstevel@tonic-gate bool_t print_status) 1072*0Sstevel@tonic-gate { 1073*0Sstevel@tonic-gate if (print_status) { 1074*0Sstevel@tonic-gate char *statp = nfslog_get_status((short)(*res)); 1075*0Sstevel@tonic-gate 1076*0Sstevel@tonic-gate if (statp != NULL) 1077*0Sstevel@tonic-gate elfrec->bufoffset += 1078*0Sstevel@tonic-gate sprintf(&elfrec->buf[elfrec->bufoffset], " %s", 1079*0Sstevel@tonic-gate statp); 1080*0Sstevel@tonic-gate else 1081*0Sstevel@tonic-gate elfrec->bufoffset += 1082*0Sstevel@tonic-gate sprintf(&elfrec->buf[elfrec->bufoffset], " %5d", 1083*0Sstevel@tonic-gate *res); 1084*0Sstevel@tonic-gate } 1085*0Sstevel@tonic-gate } 1086*0Sstevel@tonic-gate 1087*0Sstevel@tonic-gate static void 1088*0Sstevel@tonic-gate nfslog_LOOKUP3res_print(struct nfsl_log_file *elfrec, 1089*0Sstevel@tonic-gate nfslog_LOOKUP3res *res, bool_t print_status) 1090*0Sstevel@tonic-gate { 1091*0Sstevel@tonic-gate if (print_status) { 1092*0Sstevel@tonic-gate nfslog_nfsstat3_print(elfrec, &res->status, print_status); 1093*0Sstevel@tonic-gate } else if (res->status == NFS3_OK) { 1094*0Sstevel@tonic-gate nfslog_fh3_print(elfrec, &res->nfslog_LOOKUP3res_u.object); 1095*0Sstevel@tonic-gate } 1096*0Sstevel@tonic-gate } 1097*0Sstevel@tonic-gate 1098*0Sstevel@tonic-gate static void 1099*0Sstevel@tonic-gate nfslog_READLINK3res_print(struct nfsl_log_file *elfrec, 1100*0Sstevel@tonic-gate nfslog_READLINK3res *res, bool_t print_status) 1101*0Sstevel@tonic-gate { 1102*0Sstevel@tonic-gate if (print_status) { 1103*0Sstevel@tonic-gate nfslog_nfsstat3_print(elfrec, &res->status, print_status); 1104*0Sstevel@tonic-gate } else if (res->status == NFS3_OK) { 1105*0Sstevel@tonic-gate elfrec->bufoffset += sprintf(&elfrec->buf[elfrec->bufoffset], 1106*0Sstevel@tonic-gate " %s", res->nfslog_READLINK3res_u.data); 1107*0Sstevel@tonic-gate } 1108*0Sstevel@tonic-gate } 1109*0Sstevel@tonic-gate 1110*0Sstevel@tonic-gate static void 1111*0Sstevel@tonic-gate nfslog_READ3res_print(struct nfsl_log_file *elfrec, nfslog_READ3res *res, 1112*0Sstevel@tonic-gate bool_t print_status) 1113*0Sstevel@tonic-gate { 1114*0Sstevel@tonic-gate if (print_status) { 1115*0Sstevel@tonic-gate nfslog_nfsstat3_print(elfrec, &res->status, print_status); 1116*0Sstevel@tonic-gate } else if (res->status == NFS3_OK) { 1117*0Sstevel@tonic-gate char *elfbuf = elfrec->buf; 1118*0Sstevel@tonic-gate int elfbufoffset = elfrec->bufoffset; 1119*0Sstevel@tonic-gate 1120*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%llx", 1121*0Sstevel@tonic-gate res->nfslog_READ3res_u.ok.filesize); 1122*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%x", 1123*0Sstevel@tonic-gate res->nfslog_READ3res_u.ok.count); 1124*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%x", 1125*0Sstevel@tonic-gate res->nfslog_READ3res_u.ok.eof); 1126*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%x", 1127*0Sstevel@tonic-gate res->nfslog_READ3res_u.ok.size); 1128*0Sstevel@tonic-gate elfrec->bufoffset = elfbufoffset; 1129*0Sstevel@tonic-gate } 1130*0Sstevel@tonic-gate } 1131*0Sstevel@tonic-gate 1132*0Sstevel@tonic-gate static void 1133*0Sstevel@tonic-gate nfslog_WRITE3res_print(struct nfsl_log_file *elfrec, nfslog_WRITE3res *res, 1134*0Sstevel@tonic-gate bool_t print_status) 1135*0Sstevel@tonic-gate { 1136*0Sstevel@tonic-gate if (print_status) { 1137*0Sstevel@tonic-gate nfslog_nfsstat3_print(elfrec, &res->status, print_status); 1138*0Sstevel@tonic-gate } else if (res->status == NFS3_OK) { 1139*0Sstevel@tonic-gate char *elfbuf = elfrec->buf; 1140*0Sstevel@tonic-gate int elfbufoffset = elfrec->bufoffset; 1141*0Sstevel@tonic-gate 1142*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%llx", 1143*0Sstevel@tonic-gate res->nfslog_WRITE3res_u.ok.filesize); 1144*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], 1145*0Sstevel@tonic-gate " 0x%x", res->nfslog_WRITE3res_u.ok.count); 1146*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfrec->buf[elfbufoffset], 1147*0Sstevel@tonic-gate " 0x%x", res->nfslog_WRITE3res_u.ok.committed); 1148*0Sstevel@tonic-gate elfrec->bufoffset = elfbufoffset; 1149*0Sstevel@tonic-gate } 1150*0Sstevel@tonic-gate } 1151*0Sstevel@tonic-gate 1152*0Sstevel@tonic-gate static void 1153*0Sstevel@tonic-gate nfslog_CREATE3res_print(struct nfsl_log_file *elfrec, nfslog_CREATE3res *res, 1154*0Sstevel@tonic-gate bool_t print_status) 1155*0Sstevel@tonic-gate { 1156*0Sstevel@tonic-gate if (print_status) { 1157*0Sstevel@tonic-gate nfslog_nfsstat3_print(elfrec, &res->status, print_status); 1158*0Sstevel@tonic-gate } else if (res->status == NFS3_OK) { 1159*0Sstevel@tonic-gate if (res->nfslog_CREATE3res_u.ok.obj.handle_follows) { 1160*0Sstevel@tonic-gate nfslog_fh3_print(elfrec, 1161*0Sstevel@tonic-gate &res->nfslog_CREATE3res_u.ok.obj.handle); 1162*0Sstevel@tonic-gate } 1163*0Sstevel@tonic-gate } 1164*0Sstevel@tonic-gate } 1165*0Sstevel@tonic-gate 1166*0Sstevel@tonic-gate static void 1167*0Sstevel@tonic-gate nfslog_MKDIR3res_print(struct nfsl_log_file *elfrec, nfslog_MKDIR3res *res, 1168*0Sstevel@tonic-gate bool_t print_status) 1169*0Sstevel@tonic-gate { 1170*0Sstevel@tonic-gate if (print_status) { 1171*0Sstevel@tonic-gate nfslog_nfsstat3_print(elfrec, &res->status, print_status); 1172*0Sstevel@tonic-gate } else if (res->status == NFS3_OK) { 1173*0Sstevel@tonic-gate if (res->nfslog_MKDIR3res_u.obj.handle_follows) { 1174*0Sstevel@tonic-gate nfslog_fh3_print(elfrec, 1175*0Sstevel@tonic-gate &res->nfslog_MKDIR3res_u.obj.handle); 1176*0Sstevel@tonic-gate } 1177*0Sstevel@tonic-gate } 1178*0Sstevel@tonic-gate } 1179*0Sstevel@tonic-gate 1180*0Sstevel@tonic-gate static void 1181*0Sstevel@tonic-gate nfslog_SYMLINK3res_print(struct nfsl_log_file *elfrec, nfslog_SYMLINK3res *res, 1182*0Sstevel@tonic-gate bool_t print_status) 1183*0Sstevel@tonic-gate { 1184*0Sstevel@tonic-gate if (print_status) { 1185*0Sstevel@tonic-gate nfslog_nfsstat3_print(elfrec, &res->status, print_status); 1186*0Sstevel@tonic-gate } else if (res->status == NFS3_OK) { 1187*0Sstevel@tonic-gate if (res->nfslog_SYMLINK3res_u.obj.handle_follows) { 1188*0Sstevel@tonic-gate nfslog_fh3_print(elfrec, 1189*0Sstevel@tonic-gate &res->nfslog_SYMLINK3res_u.obj.handle); 1190*0Sstevel@tonic-gate } 1191*0Sstevel@tonic-gate } 1192*0Sstevel@tonic-gate } 1193*0Sstevel@tonic-gate 1194*0Sstevel@tonic-gate static void 1195*0Sstevel@tonic-gate nfslog_MKNOD3res_print(struct nfsl_log_file *elfrec, nfslog_MKNOD3res *res, 1196*0Sstevel@tonic-gate bool_t print_status) 1197*0Sstevel@tonic-gate { 1198*0Sstevel@tonic-gate if (print_status) { 1199*0Sstevel@tonic-gate nfslog_nfsstat3_print(elfrec, &res->status, print_status); 1200*0Sstevel@tonic-gate } else if (res->status == NFS3_OK) { 1201*0Sstevel@tonic-gate if (res->nfslog_MKNOD3res_u.obj.handle_follows) { 1202*0Sstevel@tonic-gate nfslog_fh3_print(elfrec, 1203*0Sstevel@tonic-gate &res->nfslog_MKNOD3res_u.obj.handle); 1204*0Sstevel@tonic-gate } 1205*0Sstevel@tonic-gate } 1206*0Sstevel@tonic-gate } 1207*0Sstevel@tonic-gate 1208*0Sstevel@tonic-gate static void 1209*0Sstevel@tonic-gate nfslog_READDIRPLUS3res_print(struct nfsl_log_file *elfrec, 1210*0Sstevel@tonic-gate nfslog_READDIRPLUS3res *res, bool_t print_status) 1211*0Sstevel@tonic-gate { 1212*0Sstevel@tonic-gate if (print_status) { 1213*0Sstevel@tonic-gate nfslog_nfsstat3_print(elfrec, &res->status, print_status); 1214*0Sstevel@tonic-gate } 1215*0Sstevel@tonic-gate } 1216*0Sstevel@tonic-gate 1217*0Sstevel@tonic-gate /* 1218*0Sstevel@tonic-gate * **** End of table functions for logging specific procs **** 1219*0Sstevel@tonic-gate * 1220*0Sstevel@tonic-gate * Hereafter are the general logging management and dispatcher. 1221*0Sstevel@tonic-gate */ 1222*0Sstevel@tonic-gate 1223*0Sstevel@tonic-gate 1224*0Sstevel@tonic-gate /* 1225*0Sstevel@tonic-gate * nfsl_ipaddr_print - extracts sender ip address from transport struct 1226*0Sstevel@tonic-gate * and prints it in legible form. 1227*0Sstevel@tonic-gate */ 1228*0Sstevel@tonic-gate static void 1229*0Sstevel@tonic-gate nfsl_ipaddr_print(struct nfsl_log_file *elfrec, struct netbuf *ptr) 1230*0Sstevel@tonic-gate { 1231*0Sstevel@tonic-gate struct hostent *hp; 1232*0Sstevel@tonic-gate extern char *inet_ntop(); 1233*0Sstevel@tonic-gate int size, sin_family, error; 1234*0Sstevel@tonic-gate char *elfbuf = elfrec->buf; 1235*0Sstevel@tonic-gate char *addrp; 1236*0Sstevel@tonic-gate int elfbufoffset = elfrec->bufoffset; 1237*0Sstevel@tonic-gate 1238*0Sstevel@tonic-gate if (ptr->len == 0) { 1239*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " %s", 1240*0Sstevel@tonic-gate empty_name); 1241*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " %s", 1242*0Sstevel@tonic-gate empty_name); 1243*0Sstevel@tonic-gate elfrec->bufoffset = elfbufoffset; 1244*0Sstevel@tonic-gate return; 1245*0Sstevel@tonic-gate } 1246*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " "); 1247*0Sstevel@tonic-gate /* LINTED */ 1248*0Sstevel@tonic-gate sin_family = ((struct sockaddr_in *)ptr->buf)->sin_family; 1249*0Sstevel@tonic-gate switch (sin_family) { 1250*0Sstevel@tonic-gate case (AF_INET): 1251*0Sstevel@tonic-gate /* LINTED */ 1252*0Sstevel@tonic-gate addrp = (char *)&((struct sockaddr_in *)ptr->buf)->sin_addr; 1253*0Sstevel@tonic-gate size = sizeof (struct in_addr); 1254*0Sstevel@tonic-gate break; 1255*0Sstevel@tonic-gate case (AF_INET6): 1256*0Sstevel@tonic-gate /* LINTED */ 1257*0Sstevel@tonic-gate addrp = (char *)&((struct sockaddr_in6 *)ptr->buf)->sin6_addr; 1258*0Sstevel@tonic-gate size = sizeof (struct in6_addr); 1259*0Sstevel@tonic-gate break; 1260*0Sstevel@tonic-gate default: 1261*0Sstevel@tonic-gate /* unknown protocol: print address in hex form */ 1262*0Sstevel@tonic-gate for (size = ptr->len, addrp = ptr->buf; size > 0; size--) { 1263*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], "%02x", 1264*0Sstevel@tonic-gate *addrp); 1265*0Sstevel@tonic-gate } 1266*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " %s", 1267*0Sstevel@tonic-gate empty_name); 1268*0Sstevel@tonic-gate elfrec->bufoffset = elfbufoffset; 1269*0Sstevel@tonic-gate return; 1270*0Sstevel@tonic-gate } 1271*0Sstevel@tonic-gate if (inet_ntop(sin_family, addrp, &elfbuf[elfbufoffset], 1272*0Sstevel@tonic-gate (size_t)(DFLT_BUFFERSIZE + DFLT_OVFSIZE - elfbufoffset)) 1273*0Sstevel@tonic-gate == NULL) { 1274*0Sstevel@tonic-gate /* Not enough space to print - should never happen */ 1275*0Sstevel@tonic-gate elfbuf[elfrec->bufoffset] = '\0'; /* just in case */ 1276*0Sstevel@tonic-gate return; 1277*0Sstevel@tonic-gate } 1278*0Sstevel@tonic-gate /* inet_ntop copied address into elfbuf, so update offset */ 1279*0Sstevel@tonic-gate elfbufoffset += strlen(&elfbuf[elfbufoffset]); 1280*0Sstevel@tonic-gate /* get host name and log it as well */ 1281*0Sstevel@tonic-gate hp = getipnodebyaddr(addrp, size, sin_family, &error); 1282*0Sstevel@tonic-gate if (hp != NULL) { 1283*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " \"%s\"", 1284*0Sstevel@tonic-gate hp->h_name); 1285*0Sstevel@tonic-gate } else { 1286*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " %s", 1287*0Sstevel@tonic-gate empty_name); 1288*0Sstevel@tonic-gate } 1289*0Sstevel@tonic-gate elfrec->bufoffset = elfbufoffset; 1290*0Sstevel@tonic-gate } 1291*0Sstevel@tonic-gate 1292*0Sstevel@tonic-gate static void 1293*0Sstevel@tonic-gate nfsl_elf_record_header_print(struct nfsl_log_file *elfrec, 1294*0Sstevel@tonic-gate nfslog_record_header *lhp, char *principal_name, char *tag, 1295*0Sstevel@tonic-gate struct nfsl_proc_disp *disp, char *progname) 1296*0Sstevel@tonic-gate { 1297*0Sstevel@tonic-gate struct passwd *pwp = NULL; 1298*0Sstevel@tonic-gate char *elfbuf = elfrec->buf; 1299*0Sstevel@tonic-gate int elfbufoffset = elfrec->bufoffset; 1300*0Sstevel@tonic-gate 1301*0Sstevel@tonic-gate /* 1302*0Sstevel@tonic-gate * Fields: time bytes tag rpc-program rpc-version rpc-procedure 1303*0Sstevel@tonic-gate * auth-flavor s-user-name s-uid uid u-name gid net-id 1304*0Sstevel@tonic-gate * c-ip c-dns s-dns status rpcarg-path <arguments> <response> 1305*0Sstevel@tonic-gate */ 1306*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], "%s", 1307*0Sstevel@tonic-gate nfsl_get_time((time_t)lhp->rh_timestamp.tv_sec)); 1308*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%x", 1309*0Sstevel@tonic-gate lhp->rh_reclen); 1310*0Sstevel@tonic-gate if ((tag != NULL) && (tag[0] != '\0')) { 1311*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " \"%s\"", tag); 1312*0Sstevel@tonic-gate } else { 1313*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " %s", 1314*0Sstevel@tonic-gate empty_name); 1315*0Sstevel@tonic-gate } 1316*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " %s 0x%x %s", 1317*0Sstevel@tonic-gate progname, lhp->rh_version, disp->procname); 1318*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " %s", 1319*0Sstevel@tonic-gate NFSL_AUTH_FLAVOR_PRINT(lhp->rh_auth_flavor)); 1320*0Sstevel@tonic-gate if ((principal_name != NULL) && (principal_name[0] != '\0')) { 1321*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " \"%s\"", 1322*0Sstevel@tonic-gate principal_name); 1323*0Sstevel@tonic-gate if ((pwp = getpwnam(principal_name)) != NULL) { 1324*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], 1325*0Sstevel@tonic-gate " 0x%lx", pwp->pw_uid); 1326*0Sstevel@tonic-gate } else { 1327*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], 1328*0Sstevel@tonic-gate " %s", empty_name); 1329*0Sstevel@tonic-gate } 1330*0Sstevel@tonic-gate } else { 1331*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " %s", 1332*0Sstevel@tonic-gate empty_name); 1333*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " %s", 1334*0Sstevel@tonic-gate empty_name); 1335*0Sstevel@tonic-gate } 1336*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%lx", lhp->rh_uid); 1337*0Sstevel@tonic-gate if (((pwp = getpwuid(lhp->rh_uid)) != NULL) && (pwp->pw_name != NULL)) { 1338*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " \"%s\"", 1339*0Sstevel@tonic-gate pwp->pw_name); 1340*0Sstevel@tonic-gate } else { 1341*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " %s", 1342*0Sstevel@tonic-gate empty_name); 1343*0Sstevel@tonic-gate } 1344*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], " 0x%lx", lhp->rh_gid); 1345*0Sstevel@tonic-gate elfrec->bufoffset = elfbufoffset; 1346*0Sstevel@tonic-gate } 1347*0Sstevel@tonic-gate 1348*0Sstevel@tonic-gate static void 1349*0Sstevel@tonic-gate nfsl_elf_buffer_header_print(struct nfsl_log_file *elfrec, 1350*0Sstevel@tonic-gate nfslog_buffer_header *bufhdr) 1351*0Sstevel@tonic-gate { 1352*0Sstevel@tonic-gate int rc; 1353*0Sstevel@tonic-gate struct utsname name; 1354*0Sstevel@tonic-gate char *elfbuf = elfrec->buf; 1355*0Sstevel@tonic-gate int elfbufoffset = elfrec->bufoffset; 1356*0Sstevel@tonic-gate 1357*0Sstevel@tonic-gate rc = uname(&name); 1358*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], 1359*0Sstevel@tonic-gate "#Version %d.0\n#Software \"%s\"\n", 1360*0Sstevel@tonic-gate bufhdr->bh_version, ((rc >= 0) ? name.sysname : empty_name)); 1361*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], "#Date %s\n", 1362*0Sstevel@tonic-gate nfsl_get_date((time_t)bufhdr->bh_timestamp.tv_sec)); 1363*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], "#Remark %s\n", 1364*0Sstevel@tonic-gate empty_name); 1365*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], 1366*0Sstevel@tonic-gate "#Fields: time bytes tag"); 1367*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], 1368*0Sstevel@tonic-gate " rpc-program rpc-version rpc-procedure"); 1369*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], 1370*0Sstevel@tonic-gate " auth-flavor s-user-name s-uid uid u-name gid net-id c-ip"); 1371*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], 1372*0Sstevel@tonic-gate " c-dns s-dns status rpcarg-path"); 1373*0Sstevel@tonic-gate elfbufoffset += sprintf(&elfbuf[elfbufoffset], 1374*0Sstevel@tonic-gate " rpc-arguments... rpc-response...\n"); 1375*0Sstevel@tonic-gate elfrec->bufoffset = elfbufoffset; 1376*0Sstevel@tonic-gate } 1377*0Sstevel@tonic-gate 1378*0Sstevel@tonic-gate /* 1379*0Sstevel@tonic-gate * nfsl_find_elf_dispatch - get the dispatch struct for this request 1380*0Sstevel@tonic-gate */ 1381*0Sstevel@tonic-gate static struct nfsl_proc_disp * 1382*0Sstevel@tonic-gate nfsl_find_elf_dispatch(nfslog_request_record *logrec, char **prognamep) 1383*0Sstevel@tonic-gate { 1384*0Sstevel@tonic-gate nfslog_record_header *logrechdr = &logrec->re_header; 1385*0Sstevel@tonic-gate struct nfsl_prog_disp *progtable; /* prog struct */ 1386*0Sstevel@tonic-gate struct nfsl_vers_disp *verstable; /* version struct */ 1387*0Sstevel@tonic-gate int i, vers; 1388*0Sstevel@tonic-gate 1389*0Sstevel@tonic-gate /* Find prog element - search because can't use prog as array index */ 1390*0Sstevel@tonic-gate for (i = 0; (i < nfsl_elf_dispatch_table_arglen) && 1391*0Sstevel@tonic-gate (logrechdr->rh_prognum != nfsl_elf_dispatch_table[i].nfsl_dis_prog); 1392*0Sstevel@tonic-gate i++); 1393*0Sstevel@tonic-gate if (i >= nfsl_elf_dispatch_table_arglen) { /* program not logged */ 1394*0Sstevel@tonic-gate /* not an error */ 1395*0Sstevel@tonic-gate return (NULL); 1396*0Sstevel@tonic-gate } 1397*0Sstevel@tonic-gate progtable = &nfsl_elf_dispatch_table[i]; 1398*0Sstevel@tonic-gate /* Find vers element - no validity check - if here it's valid vers */ 1399*0Sstevel@tonic-gate vers = logrechdr->rh_version - progtable->nfsl_dis_versmin; 1400*0Sstevel@tonic-gate verstable = &progtable->nfsl_dis_vers_table[vers]; 1401*0Sstevel@tonic-gate /* Find proc element - no validity check - if here it's valid proc */ 1402*0Sstevel@tonic-gate *prognamep = progtable->progname; 1403*0Sstevel@tonic-gate return (&verstable->nfsl_dis_proc_table[logrechdr->rh_procnum]); 1404*0Sstevel@tonic-gate } 1405*0Sstevel@tonic-gate 1406*0Sstevel@tonic-gate /* 1407*0Sstevel@tonic-gate * nfsl_elf_rpc_print - Print the record buffer. 1408*0Sstevel@tonic-gate */ 1409*0Sstevel@tonic-gate static void 1410*0Sstevel@tonic-gate nfsl_elf_rpc_print(struct nfsl_log_file *elfrec, 1411*0Sstevel@tonic-gate nfslog_request_record *logrec, struct nfsl_proc_disp *disp, 1412*0Sstevel@tonic-gate char *progname, char *path1, char *path2) 1413*0Sstevel@tonic-gate { 1414*0Sstevel@tonic-gate if (debug > 1) { 1415*0Sstevel@tonic-gate (void) printf("%s %d %s", progname, 1416*0Sstevel@tonic-gate logrec->re_header.rh_version, disp->procname); 1417*0Sstevel@tonic-gate (void) printf(": '%s', '%s'\n", 1418*0Sstevel@tonic-gate ((path1 != NULL) ? path1 : empty_name), 1419*0Sstevel@tonic-gate ((path2 != NULL) ? path2 : empty_name)); 1420*0Sstevel@tonic-gate } 1421*0Sstevel@tonic-gate /* 1422*0Sstevel@tonic-gate * XXXX programs using this file to get a usable record should 1423*0Sstevel@tonic-gate * take "record" struct. 1424*0Sstevel@tonic-gate */ 1425*0Sstevel@tonic-gate /* 1426*0Sstevel@tonic-gate * Print the variable fields: 1427*0Sstevel@tonic-gate * principal name 1428*0Sstevel@tonic-gate * netid 1429*0Sstevel@tonic-gate * ip address 1430*0Sstevel@tonic-gate * rpc args 1431*0Sstevel@tonic-gate * rpc res 1432*0Sstevel@tonic-gate * Use the displacements calculated earlier... 1433*0Sstevel@tonic-gate */ 1434*0Sstevel@tonic-gate 1435*0Sstevel@tonic-gate /* 1436*0Sstevel@tonic-gate * Fields: time bytes tag rpc-program rpc-version rpc-procedure 1437*0Sstevel@tonic-gate * auth-flavor s-user-name s-uid uid u-name gid net-id c-ip 1438*0Sstevel@tonic-gate * c-dns s-dns status rpcarg-path <arguments> <response> 1439*0Sstevel@tonic-gate */ 1440*0Sstevel@tonic-gate nfsl_elf_record_header_print(elfrec, &logrec->re_header, 1441*0Sstevel@tonic-gate logrec->re_principal_name, logrec->re_tag, 1442*0Sstevel@tonic-gate disp, progname); 1443*0Sstevel@tonic-gate if ((logrec->re_netid != NULL) && (logrec->re_netid[0] != '\0')) { 1444*0Sstevel@tonic-gate elfrec->bufoffset += sprintf(&elfrec->buf[elfrec->bufoffset], 1445*0Sstevel@tonic-gate " \"%s\"", logrec->re_netid); 1446*0Sstevel@tonic-gate } else { 1447*0Sstevel@tonic-gate elfrec->bufoffset += sprintf(&elfrec->buf[elfrec->bufoffset], 1448*0Sstevel@tonic-gate " %s", empty_name); 1449*0Sstevel@tonic-gate } 1450*0Sstevel@tonic-gate nfsl_ipaddr_print(elfrec, &logrec->re_ipaddr); 1451*0Sstevel@tonic-gate elfrec->bufoffset += sprintf(&elfrec->buf[elfrec->bufoffset], 1452*0Sstevel@tonic-gate " \"%s\"", hostname); 1453*0Sstevel@tonic-gate /* Next is return status */ 1454*0Sstevel@tonic-gate (*disp->nfsl_dis_res)(elfrec, logrec->re_rpc_res, TRUE); 1455*0Sstevel@tonic-gate /* Next is argpath */ 1456*0Sstevel@tonic-gate if (path1 != NULL) { 1457*0Sstevel@tonic-gate elfrec->bufoffset += sprintf(&elfrec->buf[elfrec->bufoffset], 1458*0Sstevel@tonic-gate " \"%s\"", path1); 1459*0Sstevel@tonic-gate } else { 1460*0Sstevel@tonic-gate elfrec->bufoffset += sprintf(&elfrec->buf[elfrec->bufoffset], 1461*0Sstevel@tonic-gate " %s", empty_name); 1462*0Sstevel@tonic-gate } 1463*0Sstevel@tonic-gate /* 1464*0Sstevel@tonic-gate * path2 is non-empty for rename/link type operations. If it is non- 1465*0Sstevel@tonic-gate * empty print it here as it's a part of the args 1466*0Sstevel@tonic-gate */ 1467*0Sstevel@tonic-gate if (path2 != NULL) { 1468*0Sstevel@tonic-gate elfrec->bufoffset += sprintf(&elfrec->buf[elfrec->bufoffset], 1469*0Sstevel@tonic-gate " \"%s\"", path2); 1470*0Sstevel@tonic-gate } 1471*0Sstevel@tonic-gate /* Next print formatted rpc args */ 1472*0Sstevel@tonic-gate (*disp->nfsl_dis_args)(elfrec, logrec->re_rpc_arg); 1473*0Sstevel@tonic-gate /* Next print formatted rpc res (minus status) */ 1474*0Sstevel@tonic-gate (*disp->nfsl_dis_res)(elfrec, logrec->re_rpc_res, FALSE); 1475*0Sstevel@tonic-gate elfrec->bufoffset += sprintf(&elfrec->buf[elfrec->bufoffset], "\n"); 1476*0Sstevel@tonic-gate } 1477*0Sstevel@tonic-gate 1478*0Sstevel@tonic-gate /* 1479*0Sstevel@tonic-gate * nfsl_log_file_add - add a new record to the list 1480*0Sstevel@tonic-gate */ 1481*0Sstevel@tonic-gate static void 1482*0Sstevel@tonic-gate nfsl_log_file_add(struct nfsl_log_file *elfrec, 1483*0Sstevel@tonic-gate struct nfsl_log_file **elf_listp) 1484*0Sstevel@tonic-gate { 1485*0Sstevel@tonic-gate elfrec->next = *elf_listp; 1486*0Sstevel@tonic-gate elfrec->prev = NULL; 1487*0Sstevel@tonic-gate if (*elf_listp != NULL) { 1488*0Sstevel@tonic-gate (*elf_listp)->prev = elfrec; 1489*0Sstevel@tonic-gate } 1490*0Sstevel@tonic-gate *elf_listp = elfrec; 1491*0Sstevel@tonic-gate } 1492*0Sstevel@tonic-gate 1493*0Sstevel@tonic-gate /* 1494*0Sstevel@tonic-gate * nfsl_log_file_find - finds a record in the list, given a cookie (== elfrec) 1495*0Sstevel@tonic-gate * Returns the record. 1496*0Sstevel@tonic-gate */ 1497*0Sstevel@tonic-gate static struct nfsl_log_file * 1498*0Sstevel@tonic-gate nfsl_log_file_find(struct nfsl_log_file *elfrec, 1499*0Sstevel@tonic-gate struct nfsl_log_file *elf_list) 1500*0Sstevel@tonic-gate { 1501*0Sstevel@tonic-gate struct nfsl_log_file *rec; 1502*0Sstevel@tonic-gate 1503*0Sstevel@tonic-gate for (rec = elf_list; (rec != NULL) && (rec != elfrec); 1504*0Sstevel@tonic-gate rec = rec->next); 1505*0Sstevel@tonic-gate return (rec); 1506*0Sstevel@tonic-gate } 1507*0Sstevel@tonic-gate 1508*0Sstevel@tonic-gate /* 1509*0Sstevel@tonic-gate * nfsl_log_file_del - delete a record from the list, does not free rec. 1510*0Sstevel@tonic-gate * Returns the deleted record. 1511*0Sstevel@tonic-gate */ 1512*0Sstevel@tonic-gate static struct nfsl_log_file * 1513*0Sstevel@tonic-gate nfsl_log_file_del(struct nfsl_log_file *elfrec, 1514*0Sstevel@tonic-gate struct nfsl_log_file **elf_listp) 1515*0Sstevel@tonic-gate { 1516*0Sstevel@tonic-gate struct nfsl_log_file *rec; 1517*0Sstevel@tonic-gate 1518*0Sstevel@tonic-gate if ((rec = nfsl_log_file_find(elfrec, *elf_listp)) == NULL) { 1519*0Sstevel@tonic-gate return (NULL); 1520*0Sstevel@tonic-gate } 1521*0Sstevel@tonic-gate if (rec->prev != NULL) { 1522*0Sstevel@tonic-gate rec->prev->next = rec->next; 1523*0Sstevel@tonic-gate } else { 1524*0Sstevel@tonic-gate *elf_listp = rec->next; 1525*0Sstevel@tonic-gate } 1526*0Sstevel@tonic-gate if (rec->next != NULL) { 1527*0Sstevel@tonic-gate rec->next->prev = rec->prev; 1528*0Sstevel@tonic-gate } 1529*0Sstevel@tonic-gate return (rec); 1530*0Sstevel@tonic-gate } 1531*0Sstevel@tonic-gate 1532*0Sstevel@tonic-gate /* 1533*0Sstevel@tonic-gate * nfsl_log_file_free - frees a record 1534*0Sstevel@tonic-gate */ 1535*0Sstevel@tonic-gate static void 1536*0Sstevel@tonic-gate nfsl_log_file_free(struct nfsl_log_file *elfrec) 1537*0Sstevel@tonic-gate { 1538*0Sstevel@tonic-gate if (elfrec == NULL) 1539*0Sstevel@tonic-gate return; 1540*0Sstevel@tonic-gate if (elfrec->path != NULL) 1541*0Sstevel@tonic-gate free(elfrec->path); 1542*0Sstevel@tonic-gate if (elfrec->buf != NULL) 1543*0Sstevel@tonic-gate free(elfrec->buf); 1544*0Sstevel@tonic-gate free(elfrec); 1545*0Sstevel@tonic-gate } 1546*0Sstevel@tonic-gate 1547*0Sstevel@tonic-gate /* 1548*0Sstevel@tonic-gate * Exported Functions 1549*0Sstevel@tonic-gate */ 1550*0Sstevel@tonic-gate 1551*0Sstevel@tonic-gate /* 1552*0Sstevel@tonic-gate * nfslog_open_elf_file - open the output elf file and mallocs needed buffers 1553*0Sstevel@tonic-gate * Returns a pointer to the nfsl_log_file on success, NULL on error. 1554*0Sstevel@tonic-gate * 1555*0Sstevel@tonic-gate * *error contains the last error encountered on this object, It can 1556*0Sstevel@tonic-gate * be used to avoid reporting the same error endlessly, by comparing 1557*0Sstevel@tonic-gate * the current error to the last error. It is reset to the current error 1558*0Sstevel@tonic-gate * code on return. 1559*0Sstevel@tonic-gate */ 1560*0Sstevel@tonic-gate void * 1561*0Sstevel@tonic-gate nfslog_open_elf_file(char *elfpath, nfslog_buffer_header *bufhdr, int *error) 1562*0Sstevel@tonic-gate { 1563*0Sstevel@tonic-gate struct nfsl_log_file *elfrec; 1564*0Sstevel@tonic-gate struct stat stat_buf; 1565*0Sstevel@tonic-gate int preverror = *error; 1566*0Sstevel@tonic-gate 1567*0Sstevel@tonic-gate if ((elfrec = malloc(sizeof (*elfrec))) == NULL) { 1568*0Sstevel@tonic-gate *error = errno; 1569*0Sstevel@tonic-gate if (*error != preverror) { 1570*0Sstevel@tonic-gate syslog(LOG_ERR, gettext("nfslog_open_elf_file: %s"), 1571*0Sstevel@tonic-gate strerror(*error)); 1572*0Sstevel@tonic-gate } 1573*0Sstevel@tonic-gate return (NULL); 1574*0Sstevel@tonic-gate } 1575*0Sstevel@tonic-gate bzero(elfrec, sizeof (*elfrec)); 1576*0Sstevel@tonic-gate 1577*0Sstevel@tonic-gate elfrec->buf = (char *)malloc(DFLT_BUFFERSIZE + DFLT_OVFSIZE); 1578*0Sstevel@tonic-gate if (elfrec->buf == NULL) { 1579*0Sstevel@tonic-gate *error = errno; 1580*0Sstevel@tonic-gate if (*error != preverror) { 1581*0Sstevel@tonic-gate syslog(LOG_ERR, gettext("nfslog_open_elf_file: %s"), 1582*0Sstevel@tonic-gate strerror(*error)); 1583*0Sstevel@tonic-gate } 1584*0Sstevel@tonic-gate nfsl_log_file_free(elfrec); 1585*0Sstevel@tonic-gate return (NULL); 1586*0Sstevel@tonic-gate } 1587*0Sstevel@tonic-gate 1588*0Sstevel@tonic-gate if ((elfrec->path = strdup(elfpath)) == NULL) { 1589*0Sstevel@tonic-gate *error = errno; 1590*0Sstevel@tonic-gate if (*error != preverror) { 1591*0Sstevel@tonic-gate syslog(LOG_ERR, gettext("nfslog_open_elf_file: %s"), 1592*0Sstevel@tonic-gate strerror(*error)); 1593*0Sstevel@tonic-gate } 1594*0Sstevel@tonic-gate nfsl_log_file_free(elfrec); 1595*0Sstevel@tonic-gate return (NULL); 1596*0Sstevel@tonic-gate } 1597*0Sstevel@tonic-gate 1598*0Sstevel@tonic-gate if ((elfrec->fp = fopen(elfpath, "a")) == NULL) { 1599*0Sstevel@tonic-gate *error = errno; 1600*0Sstevel@tonic-gate if (*error != preverror) { 1601*0Sstevel@tonic-gate syslog(LOG_ERR, gettext("Cannot open '%s': %s"), 1602*0Sstevel@tonic-gate elfpath, strerror(*error)); 1603*0Sstevel@tonic-gate } 1604*0Sstevel@tonic-gate nfsl_log_file_free(elfrec); 1605*0Sstevel@tonic-gate return (NULL); 1606*0Sstevel@tonic-gate } 1607*0Sstevel@tonic-gate 1608*0Sstevel@tonic-gate if (stat(elfpath, &stat_buf) == -1) { 1609*0Sstevel@tonic-gate *error = errno; 1610*0Sstevel@tonic-gate if (*error != preverror) { 1611*0Sstevel@tonic-gate syslog(LOG_ERR, gettext("Cannot stat '%s': %s"), 1612*0Sstevel@tonic-gate elfpath, strerror(*error)); 1613*0Sstevel@tonic-gate } 1614*0Sstevel@tonic-gate (void) fclose(elfrec->fp); 1615*0Sstevel@tonic-gate nfsl_log_file_free(elfrec); 1616*0Sstevel@tonic-gate return (NULL); 1617*0Sstevel@tonic-gate } 1618*0Sstevel@tonic-gate 1619*0Sstevel@tonic-gate nfsl_log_file_add(elfrec, &elf_file_list); 1620*0Sstevel@tonic-gate 1621*0Sstevel@tonic-gate if (stat_buf.st_size == 0) { 1622*0Sstevel@tonic-gate /* 1623*0Sstevel@tonic-gate * Print header unto logfile 1624*0Sstevel@tonic-gate */ 1625*0Sstevel@tonic-gate nfsl_elf_buffer_header_print(elfrec, bufhdr); 1626*0Sstevel@tonic-gate } 1627*0Sstevel@tonic-gate 1628*0Sstevel@tonic-gate if (hostname[0] == '\0') { 1629*0Sstevel@tonic-gate (void) gethostname(hostname, MAXHOSTNAMELEN); 1630*0Sstevel@tonic-gate } 1631*0Sstevel@tonic-gate 1632*0Sstevel@tonic-gate return (elfrec); 1633*0Sstevel@tonic-gate } 1634*0Sstevel@tonic-gate 1635*0Sstevel@tonic-gate /* 1636*0Sstevel@tonic-gate * nfslog_close_elf_file - close elffile and write out last buffer 1637*0Sstevel@tonic-gate */ 1638*0Sstevel@tonic-gate void 1639*0Sstevel@tonic-gate nfslog_close_elf_file(void **elfcookie) 1640*0Sstevel@tonic-gate { 1641*0Sstevel@tonic-gate struct nfsl_log_file *elfrec; 1642*0Sstevel@tonic-gate 1643*0Sstevel@tonic-gate if ((*elfcookie == NULL) || ((elfrec = nfsl_log_file_del( 1644*0Sstevel@tonic-gate *elfcookie, &elf_file_list)) == NULL)) { 1645*0Sstevel@tonic-gate *elfcookie = NULL; 1646*0Sstevel@tonic-gate return; 1647*0Sstevel@tonic-gate } 1648*0Sstevel@tonic-gate if (elfrec->fp != NULL) { 1649*0Sstevel@tonic-gate /* Write the last output buffer to disk */ 1650*0Sstevel@tonic-gate (void) nfsl_write_elfbuf(elfrec); 1651*0Sstevel@tonic-gate (void) fclose(elfrec->fp); 1652*0Sstevel@tonic-gate } 1653*0Sstevel@tonic-gate nfsl_log_file_free(elfrec); 1654*0Sstevel@tonic-gate *elfcookie = NULL; 1655*0Sstevel@tonic-gate } 1656*0Sstevel@tonic-gate 1657*0Sstevel@tonic-gate /* 1658*0Sstevel@tonic-gate * nfslog_process_elf_rec - processes the record in the buffer and outputs 1659*0Sstevel@tonic-gate * to the elf log. 1660*0Sstevel@tonic-gate * Return 0 for success, errno else. 1661*0Sstevel@tonic-gate */ 1662*0Sstevel@tonic-gate int 1663*0Sstevel@tonic-gate nfslog_process_elf_rec(void *elfcookie, nfslog_request_record *logrec, 1664*0Sstevel@tonic-gate char *path1, char *path2) 1665*0Sstevel@tonic-gate { 1666*0Sstevel@tonic-gate struct nfsl_log_file *elfrec; 1667*0Sstevel@tonic-gate struct nfsl_proc_disp *disp; 1668*0Sstevel@tonic-gate char *progname; 1669*0Sstevel@tonic-gate 1670*0Sstevel@tonic-gate if ((elfrec = nfsl_log_file_find(elfcookie, elf_file_list)) == NULL) { 1671*0Sstevel@tonic-gate return (EINVAL); 1672*0Sstevel@tonic-gate } 1673*0Sstevel@tonic-gate /* Make sure there is room */ 1674*0Sstevel@tonic-gate if (elfrec->bufoffset > DFLT_BUFFERSIZE) { 1675*0Sstevel@tonic-gate if (nfsl_write_elfbuf(elfrec) < 0) { 1676*0Sstevel@tonic-gate return (errno); 1677*0Sstevel@tonic-gate } 1678*0Sstevel@tonic-gate } 1679*0Sstevel@tonic-gate if ((disp = nfsl_find_elf_dispatch(logrec, &progname)) != NULL) { 1680*0Sstevel@tonic-gate nfsl_elf_rpc_print(elfrec, logrec, disp, progname, 1681*0Sstevel@tonic-gate path1, path2); 1682*0Sstevel@tonic-gate } 1683*0Sstevel@tonic-gate return (0); 1684*0Sstevel@tonic-gate } 1685