1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright (c) 1999 by Sun Microsystems, Inc. 24*7c478bd9Sstevel@tonic-gate * All rights reserved. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate /* 30*7c478bd9Sstevel@tonic-gate * Code to maintain the runtime and on-disk filehandle mapping table for 31*7c478bd9Sstevel@tonic-gate * nfslog. 32*7c478bd9Sstevel@tonic-gate */ 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate #include <assert.h> 35*7c478bd9Sstevel@tonic-gate #include <errno.h> 36*7c478bd9Sstevel@tonic-gate #include <nfs/nfs.h> 37*7c478bd9Sstevel@tonic-gate #include <stdlib.h> 38*7c478bd9Sstevel@tonic-gate #include <string.h> 39*7c478bd9Sstevel@tonic-gate #include <strings.h> 40*7c478bd9Sstevel@tonic-gate #include <syslog.h> 41*7c478bd9Sstevel@tonic-gate #include <libintl.h> 42*7c478bd9Sstevel@tonic-gate #include <unistd.h> 43*7c478bd9Sstevel@tonic-gate #include <nfs/nfs.h> 44*7c478bd9Sstevel@tonic-gate #include <nfs/nfs_log.h> 45*7c478bd9Sstevel@tonic-gate #include "fhtab.h" 46*7c478bd9Sstevel@tonic-gate #include "nfslogd.h" 47*7c478bd9Sstevel@tonic-gate 48*7c478bd9Sstevel@tonic-gate #define ROUNDUP32(val) (((val) + 3) & ~3) 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gate #define IS_DOT_FILENAME(name) \ 51*7c478bd9Sstevel@tonic-gate ((strcmp(name, ".") == 0) || (strcmp(name, "..") == 0)) 52*7c478bd9Sstevel@tonic-gate 53*7c478bd9Sstevel@tonic-gate #define PRINT_LINK_DATA(fp, func, dfh, name, str) \ 54*7c478bd9Sstevel@tonic-gate (void) fprintf(fp, "%s: name '%s', dfh ", \ 55*7c478bd9Sstevel@tonic-gate func, (((name) != NULL) ? name : "")); \ 56*7c478bd9Sstevel@tonic-gate debug_opaque_print(fp, dfh, sizeof (*(dfh))); \ 57*7c478bd9Sstevel@tonic-gate (void) fprintf(fp, "%s\n", str); 58*7c478bd9Sstevel@tonic-gate 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate #define PRINT_FULL_DATA(fp, func, dfh, fh, name, str) \ 61*7c478bd9Sstevel@tonic-gate (void) fprintf(fp, "%s: name '%s', dfh ", \ 62*7c478bd9Sstevel@tonic-gate func, (((name) != NULL) ? name : "")); \ 63*7c478bd9Sstevel@tonic-gate debug_opaque_print(fp, dfh, sizeof (*(dfh))); \ 64*7c478bd9Sstevel@tonic-gate if ((fh) != NULL) { \ 65*7c478bd9Sstevel@tonic-gate (void) fprintf(fp, ", fh "); \ 66*7c478bd9Sstevel@tonic-gate debug_opaque_print(fp, fh, sizeof (*(fh))); \ 67*7c478bd9Sstevel@tonic-gate } \ 68*7c478bd9Sstevel@tonic-gate (void) fprintf(fp, "%s\n", str); 69*7c478bd9Sstevel@tonic-gate 70*7c478bd9Sstevel@tonic-gate /* 71*7c478bd9Sstevel@tonic-gate * export handle cache 72*7c478bd9Sstevel@tonic-gate */ 73*7c478bd9Sstevel@tonic-gate struct export_handle_cache { 74*7c478bd9Sstevel@tonic-gate fhandle_t fh; 75*7c478bd9Sstevel@tonic-gate char *name; 76*7c478bd9Sstevel@tonic-gate struct export_handle_cache *next; 77*7c478bd9Sstevel@tonic-gate }; 78*7c478bd9Sstevel@tonic-gate 79*7c478bd9Sstevel@tonic-gate static struct export_handle_cache *exp_handle_cache = NULL; 80*7c478bd9Sstevel@tonic-gate 81*7c478bd9Sstevel@tonic-gate extern bool_t nfsl_prin_fh; 82*7c478bd9Sstevel@tonic-gate 83*7c478bd9Sstevel@tonic-gate static int fh_add(char *, fhandle_t *, fhandle_t *, char *); 84*7c478bd9Sstevel@tonic-gate 85*7c478bd9Sstevel@tonic-gate static char *get_export_path(fhandle_t *, char *); 86*7c478bd9Sstevel@tonic-gate static void sprint_fid(char *, uint_t, const fhandle_t *); 87*7c478bd9Sstevel@tonic-gate static void fh_print_all_keys(char *fhpath, fhandle_t *fh); 88*7c478bd9Sstevel@tonic-gate static int fh_compare(fhandle_t *fh1, fhandle_t *fh2); 89*7c478bd9Sstevel@tonic-gate static fhlist_ent *fh_lookup(char *fhpath, fhandle_t *fh, fhlist_ent *fhrecp, 90*7c478bd9Sstevel@tonic-gate int *errorp); 91*7c478bd9Sstevel@tonic-gate static int fh_remove_mc_link(char *fhpath, fhandle_t *dfh, char *name, 92*7c478bd9Sstevel@tonic-gate char **pathp); 93*7c478bd9Sstevel@tonic-gate static int fh_remove(char *fhpath, fhandle_t *dfh, char *name, char **pathp); 94*7c478bd9Sstevel@tonic-gate static int fh_rename(char *fhpath, fhandle_t *from_dfh, char *from_name, 95*7c478bd9Sstevel@tonic-gate char **from_pathp, fhandle_t *to_dfh, char *to_name); 96*7c478bd9Sstevel@tonic-gate 97*7c478bd9Sstevel@tonic-gate static fhlist_ent *fh_lookup_link(char *fhpath, fhandle_t *dfh, fhandle_t *fh, 98*7c478bd9Sstevel@tonic-gate char *name, fhlist_ent *fhrecp, int *errorp); 99*7c478bd9Sstevel@tonic-gate static struct nfsl_fh_proc_disp *nfslog_find_fh_dispatch( 100*7c478bd9Sstevel@tonic-gate nfslog_request_record *); 101*7c478bd9Sstevel@tonic-gate static struct export_handle_cache *find_fh_in_export_cache(fhandle_t *fh); 102*7c478bd9Sstevel@tonic-gate static void add_fh_to_export_cache(fhandle_t *fh, char *path); 103*7c478bd9Sstevel@tonic-gate static char *update_export_point(char *fhpath, fhandle_t *fh, char *path); 104*7c478bd9Sstevel@tonic-gate static char *fh_print_absolute(char *fhpath, fhandle_t *fh, char *name); 105*7c478bd9Sstevel@tonic-gate static void nfslog_null_fhargs(caddr_t *nfsl_args, caddr_t *nfsl_res, 106*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2); 107*7c478bd9Sstevel@tonic-gate static void nfslog_LOOKUP_calc(fhandle_t *dfh, char *name, fhandle_t *fh, 108*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2, char *str); 109*7c478bd9Sstevel@tonic-gate 110*7c478bd9Sstevel@tonic-gate /* 111*7c478bd9Sstevel@tonic-gate * NFS VERSION 2 112*7c478bd9Sstevel@tonic-gate */ 113*7c478bd9Sstevel@tonic-gate 114*7c478bd9Sstevel@tonic-gate /* 115*7c478bd9Sstevel@tonic-gate * Functions for updating the fhtable for fhtoppath and for returning 116*7c478bd9Sstevel@tonic-gate * the absolute pathname 117*7c478bd9Sstevel@tonic-gate */ 118*7c478bd9Sstevel@tonic-gate static void nfslog_GETATTR2_fhargs(fhandle_t *, 119*7c478bd9Sstevel@tonic-gate nfsstat *, char *fhpath, char **, char **); 120*7c478bd9Sstevel@tonic-gate static void nfslog_SETATTR2_fhargs(nfslog_setattrargs *, nfsstat *, 121*7c478bd9Sstevel@tonic-gate char *, char **, char **); 122*7c478bd9Sstevel@tonic-gate static void nfslog_LOOKUP2_fhargs(nfslog_diropargs *, nfslog_diropres *, 123*7c478bd9Sstevel@tonic-gate char *, char **, char **); 124*7c478bd9Sstevel@tonic-gate static void nfslog_READLINK2_fhargs(fhandle_t *, nfslog_rdlnres *, 125*7c478bd9Sstevel@tonic-gate char *, char **, char **); 126*7c478bd9Sstevel@tonic-gate static void nfslog_READ2_fhargs(nfslog_nfsreadargs *, nfslog_rdresult *, 127*7c478bd9Sstevel@tonic-gate char *, char **, char **); 128*7c478bd9Sstevel@tonic-gate static void nfslog_WRITE2_fhargs(nfslog_writeargs *, nfslog_writeresult *, 129*7c478bd9Sstevel@tonic-gate char *, char **, char **); 130*7c478bd9Sstevel@tonic-gate static void nfslog_CREATE2_fhargs(nfslog_createargs *, nfslog_diropres*, 131*7c478bd9Sstevel@tonic-gate char *, char **, char **); 132*7c478bd9Sstevel@tonic-gate static void nfslog_REMOVE2_fhargs(nfslog_diropargs *, nfsstat *, 133*7c478bd9Sstevel@tonic-gate char *, char **, char **); 134*7c478bd9Sstevel@tonic-gate static void nfslog_RENAME2_fhargs(nfslog_rnmargs *, nfsstat *, 135*7c478bd9Sstevel@tonic-gate char *, char **, char **); 136*7c478bd9Sstevel@tonic-gate static void nfslog_LINK2_fhargs(nfslog_linkargs *, nfsstat *, 137*7c478bd9Sstevel@tonic-gate char *, char **, char **); 138*7c478bd9Sstevel@tonic-gate static void nfslog_SYMLINK2_fhargs(nfslog_symlinkargs *, nfsstat *, 139*7c478bd9Sstevel@tonic-gate char *, char **, char **); 140*7c478bd9Sstevel@tonic-gate static void nfslog_READDIR2_fhargs(nfslog_rddirargs *, nfslog_rddirres *, 141*7c478bd9Sstevel@tonic-gate char *, char **, char **); 142*7c478bd9Sstevel@tonic-gate static void nfslog_STATFS2_fhargs(fhandle_t *, nfsstat *, 143*7c478bd9Sstevel@tonic-gate char *, char **, char **); 144*7c478bd9Sstevel@tonic-gate 145*7c478bd9Sstevel@tonic-gate /* 146*7c478bd9Sstevel@tonic-gate * NFS VERSION 3 147*7c478bd9Sstevel@tonic-gate * 148*7c478bd9Sstevel@tonic-gate * Functions for updating the fhtable for fhtoppath 149*7c478bd9Sstevel@tonic-gate */ 150*7c478bd9Sstevel@tonic-gate static void nfslog_GETATTR3_fhargs(nfs_fh3 *, nfsstat3 *, 151*7c478bd9Sstevel@tonic-gate char *, char **, char **); 152*7c478bd9Sstevel@tonic-gate static void nfslog_SETATTR3_fhargs(nfslog_SETATTR3args *, nfsstat3 *, 153*7c478bd9Sstevel@tonic-gate char *, char **, char **); 154*7c478bd9Sstevel@tonic-gate static void nfslog_LOOKUP3_fhargs(nfslog_diropargs3 *, nfslog_LOOKUP3res *, 155*7c478bd9Sstevel@tonic-gate char *, char **, char **); 156*7c478bd9Sstevel@tonic-gate static void nfslog_ACCESS3_fhargs(nfs_fh3 *, nfsstat3 *, 157*7c478bd9Sstevel@tonic-gate char *, char **, char **); 158*7c478bd9Sstevel@tonic-gate static void nfslog_READLINK3_fhargs(nfs_fh3 *, nfslog_READLINK3res *, 159*7c478bd9Sstevel@tonic-gate char *, char **, char **); 160*7c478bd9Sstevel@tonic-gate static void nfslog_READ3_fhargs(nfslog_READ3args *, nfslog_READ3res *, 161*7c478bd9Sstevel@tonic-gate char *, char **, char **); 162*7c478bd9Sstevel@tonic-gate static void nfslog_WRITE3_fhargs(nfslog_WRITE3args *, nfslog_WRITE3res *, 163*7c478bd9Sstevel@tonic-gate char *, char **, char **); 164*7c478bd9Sstevel@tonic-gate static void nfslog_CREATE3_fhargs(nfslog_CREATE3args *, nfslog_CREATE3res *, 165*7c478bd9Sstevel@tonic-gate char *, char **, char **); 166*7c478bd9Sstevel@tonic-gate static void nfslog_MKDIR3_fhargs(nfslog_MKDIR3args *, nfslog_MKDIR3res *, 167*7c478bd9Sstevel@tonic-gate char *, char **, char **); 168*7c478bd9Sstevel@tonic-gate static void nfslog_SYMLINK3_fhargs(nfslog_SYMLINK3args *, nfslog_SYMLINK3res *, 169*7c478bd9Sstevel@tonic-gate char *, char **, char **); 170*7c478bd9Sstevel@tonic-gate static void nfslog_MKNOD3_fhargs(nfslog_MKNOD3args *, nfslog_MKNOD3res *, 171*7c478bd9Sstevel@tonic-gate char *, char **, char **); 172*7c478bd9Sstevel@tonic-gate static void nfslog_REMOVE3_fhargs(nfslog_REMOVE3args *, nfsstat3 *, 173*7c478bd9Sstevel@tonic-gate char *, char **, char **); 174*7c478bd9Sstevel@tonic-gate static void nfslog_RMDIR3_fhargs(nfslog_RMDIR3args *, nfsstat3 *, 175*7c478bd9Sstevel@tonic-gate char *, char **, char **); 176*7c478bd9Sstevel@tonic-gate static void nfslog_RENAME3_fhargs(nfslog_RENAME3args *, nfsstat3 *, 177*7c478bd9Sstevel@tonic-gate char *, char **, char **); 178*7c478bd9Sstevel@tonic-gate static void nfslog_LINK3_fhargs(nfslog_LINK3args *, nfsstat3 *, 179*7c478bd9Sstevel@tonic-gate char *, char **, char **); 180*7c478bd9Sstevel@tonic-gate static void nfslog_READDIR3_fhargs(nfs_fh3 *, nfsstat3 *, 181*7c478bd9Sstevel@tonic-gate char *, char **, char **); 182*7c478bd9Sstevel@tonic-gate static void nfslog_READDIRPLUS3_fhargs(nfslog_READDIRPLUS3args *, 183*7c478bd9Sstevel@tonic-gate nfslog_READDIRPLUS3res *, 184*7c478bd9Sstevel@tonic-gate char *, char **, char **); 185*7c478bd9Sstevel@tonic-gate static void nfslog_FSSTAT3_fhargs(nfs_fh3 *, nfsstat3 *, 186*7c478bd9Sstevel@tonic-gate char *, char **, char **); 187*7c478bd9Sstevel@tonic-gate static void nfslog_FSINFO3_fhargs(nfs_fh3 *, nfsstat3 *, 188*7c478bd9Sstevel@tonic-gate char *, char **, char **); 189*7c478bd9Sstevel@tonic-gate static void nfslog_PATHCONF3_fhargs(nfs_fh3 *, nfsstat3 *, 190*7c478bd9Sstevel@tonic-gate char *, char **, char **); 191*7c478bd9Sstevel@tonic-gate static void nfslog_COMMIT3_fhargs(nfslog_COMMIT3args *, nfsstat3 *, 192*7c478bd9Sstevel@tonic-gate char *, char **, char **); 193*7c478bd9Sstevel@tonic-gate 194*7c478bd9Sstevel@tonic-gate /* 195*7c478bd9Sstevel@tonic-gate * NFSLOG VERSION 1 196*7c478bd9Sstevel@tonic-gate * 197*7c478bd9Sstevel@tonic-gate * Functions for updating the fhtable for fhtoppath 198*7c478bd9Sstevel@tonic-gate */ 199*7c478bd9Sstevel@tonic-gate static void nfslog_SHARE_fhargs(nfslog_sharefsargs *, nfslog_sharefsres *, 200*7c478bd9Sstevel@tonic-gate char *, char **, char **); 201*7c478bd9Sstevel@tonic-gate static void nfslog_UNSHARE_fhargs(nfslog_sharefsargs *, nfslog_sharefsres *, 202*7c478bd9Sstevel@tonic-gate char *, char **, char **); 203*7c478bd9Sstevel@tonic-gate static void nfslog_GETFH_fhargs(nfslog_getfhargs *, nfsstat *, 204*7c478bd9Sstevel@tonic-gate char *, char **, char **); 205*7c478bd9Sstevel@tonic-gate 206*7c478bd9Sstevel@tonic-gate /* 207*7c478bd9Sstevel@tonic-gate * Define the actions taken per prog/vers/proc: 208*7c478bd9Sstevel@tonic-gate * 209*7c478bd9Sstevel@tonic-gate * In some cases, the nl types are the same as the nfs types and a simple 210*7c478bd9Sstevel@tonic-gate * bcopy should suffice. Rather that define tens of identical procedures, 211*7c478bd9Sstevel@tonic-gate * simply define these to bcopy. Similarly this takes care of different 212*7c478bd9Sstevel@tonic-gate * procs that use same parameter struct. 213*7c478bd9Sstevel@tonic-gate */ 214*7c478bd9Sstevel@tonic-gate 215*7c478bd9Sstevel@tonic-gate static struct nfsl_fh_proc_disp nfsl_fh_proc_v2[] = { 216*7c478bd9Sstevel@tonic-gate /* 217*7c478bd9Sstevel@tonic-gate * NFS VERSION 2 218*7c478bd9Sstevel@tonic-gate */ 219*7c478bd9Sstevel@tonic-gate 220*7c478bd9Sstevel@tonic-gate /* RFS_NULL = 0 */ 221*7c478bd9Sstevel@tonic-gate {nfslog_null_fhargs, xdr_void, xdr_void, 0, 0}, 222*7c478bd9Sstevel@tonic-gate 223*7c478bd9Sstevel@tonic-gate /* RFS_GETATTR = 1 */ 224*7c478bd9Sstevel@tonic-gate {nfslog_GETATTR2_fhargs, xdr_fhandle, xdr_nfsstat, 225*7c478bd9Sstevel@tonic-gate sizeof (fhandle_t), sizeof (nfsstat)}, 226*7c478bd9Sstevel@tonic-gate 227*7c478bd9Sstevel@tonic-gate /* RFS_SETATTR = 2 */ 228*7c478bd9Sstevel@tonic-gate {nfslog_SETATTR2_fhargs, xdr_nfslog_setattrargs, xdr_nfsstat, 229*7c478bd9Sstevel@tonic-gate sizeof (nfslog_setattrargs), sizeof (nfsstat)}, 230*7c478bd9Sstevel@tonic-gate 231*7c478bd9Sstevel@tonic-gate /* RFS_ROOT = 3 *** NO LONGER SUPPORTED *** */ 232*7c478bd9Sstevel@tonic-gate {nfslog_null_fhargs, xdr_void, xdr_void, 0, 0}, 233*7c478bd9Sstevel@tonic-gate 234*7c478bd9Sstevel@tonic-gate /* RFS_LOOKUP = 4 */ 235*7c478bd9Sstevel@tonic-gate {nfslog_LOOKUP2_fhargs, xdr_nfslog_diropargs, xdr_nfslog_diropres, 236*7c478bd9Sstevel@tonic-gate sizeof (nfslog_diropargs), sizeof (nfslog_diropres)}, 237*7c478bd9Sstevel@tonic-gate 238*7c478bd9Sstevel@tonic-gate /* RFS_READLINK = 5 */ 239*7c478bd9Sstevel@tonic-gate {nfslog_READLINK2_fhargs, xdr_fhandle, xdr_nfslog_rdlnres, 240*7c478bd9Sstevel@tonic-gate sizeof (fhandle_t), sizeof (nfslog_rdlnres)}, 241*7c478bd9Sstevel@tonic-gate 242*7c478bd9Sstevel@tonic-gate /* RFS_READ = 6 */ 243*7c478bd9Sstevel@tonic-gate {nfslog_READ2_fhargs, xdr_nfslog_nfsreadargs, xdr_nfslog_rdresult, 244*7c478bd9Sstevel@tonic-gate sizeof (nfslog_nfsreadargs), sizeof (nfslog_rdresult)}, 245*7c478bd9Sstevel@tonic-gate 246*7c478bd9Sstevel@tonic-gate /* RFS_WRITECACHE = 7 *** NO LONGER SUPPORTED *** */ 247*7c478bd9Sstevel@tonic-gate {nfslog_null_fhargs, xdr_void, xdr_void, 0, 0}, 248*7c478bd9Sstevel@tonic-gate 249*7c478bd9Sstevel@tonic-gate /* RFS_WRITE = 8 */ 250*7c478bd9Sstevel@tonic-gate {nfslog_WRITE2_fhargs, xdr_nfslog_writeargs, xdr_nfslog_writeresult, 251*7c478bd9Sstevel@tonic-gate sizeof (nfslog_writeargs), sizeof (nfslog_writeresult)}, 252*7c478bd9Sstevel@tonic-gate 253*7c478bd9Sstevel@tonic-gate /* RFS_CREATE = 9 */ 254*7c478bd9Sstevel@tonic-gate {nfslog_CREATE2_fhargs, xdr_nfslog_createargs, xdr_nfslog_diropres, 255*7c478bd9Sstevel@tonic-gate sizeof (nfslog_createargs), sizeof (nfslog_diropres)}, 256*7c478bd9Sstevel@tonic-gate 257*7c478bd9Sstevel@tonic-gate /* RFS_REMOVE = 10 */ 258*7c478bd9Sstevel@tonic-gate {nfslog_REMOVE2_fhargs, xdr_nfslog_diropargs, xdr_nfsstat, 259*7c478bd9Sstevel@tonic-gate sizeof (nfslog_diropargs), sizeof (nfsstat)}, 260*7c478bd9Sstevel@tonic-gate 261*7c478bd9Sstevel@tonic-gate /* RFS_RENAME = 11 */ 262*7c478bd9Sstevel@tonic-gate {nfslog_RENAME2_fhargs, xdr_nfslog_rnmargs, xdr_nfsstat, 263*7c478bd9Sstevel@tonic-gate sizeof (nfslog_rnmargs), sizeof (nfsstat)}, 264*7c478bd9Sstevel@tonic-gate 265*7c478bd9Sstevel@tonic-gate /* RFS_LINK = 12 */ 266*7c478bd9Sstevel@tonic-gate {nfslog_LINK2_fhargs, xdr_nfslog_linkargs, xdr_nfsstat, 267*7c478bd9Sstevel@tonic-gate sizeof (nfslog_linkargs), sizeof (nfsstat)}, 268*7c478bd9Sstevel@tonic-gate 269*7c478bd9Sstevel@tonic-gate /* RFS_SYMLINK = 13 */ 270*7c478bd9Sstevel@tonic-gate {nfslog_SYMLINK2_fhargs, xdr_nfslog_symlinkargs, xdr_nfsstat, 271*7c478bd9Sstevel@tonic-gate sizeof (nfslog_symlinkargs), sizeof (nfsstat)}, 272*7c478bd9Sstevel@tonic-gate 273*7c478bd9Sstevel@tonic-gate /* RFS_MKDIR = 14 */ 274*7c478bd9Sstevel@tonic-gate {nfslog_CREATE2_fhargs, xdr_nfslog_createargs, xdr_nfslog_diropres, 275*7c478bd9Sstevel@tonic-gate sizeof (nfslog_createargs), sizeof (nfslog_diropres)}, 276*7c478bd9Sstevel@tonic-gate 277*7c478bd9Sstevel@tonic-gate /* RFS_RMDIR = 15 */ 278*7c478bd9Sstevel@tonic-gate {nfslog_REMOVE2_fhargs, xdr_nfslog_diropargs, xdr_nfsstat, 279*7c478bd9Sstevel@tonic-gate sizeof (nfslog_diropargs), sizeof (nfsstat)}, 280*7c478bd9Sstevel@tonic-gate 281*7c478bd9Sstevel@tonic-gate /* RFS_READDIR = 16 */ 282*7c478bd9Sstevel@tonic-gate {nfslog_READDIR2_fhargs, xdr_nfslog_rddirargs, xdr_nfslog_rddirres, 283*7c478bd9Sstevel@tonic-gate sizeof (nfslog_rddirargs), sizeof (nfslog_rddirres)}, 284*7c478bd9Sstevel@tonic-gate 285*7c478bd9Sstevel@tonic-gate /* RFS_STATFS = 17 */ 286*7c478bd9Sstevel@tonic-gate {nfslog_STATFS2_fhargs, xdr_fhandle, xdr_nfsstat, 287*7c478bd9Sstevel@tonic-gate sizeof (fhandle_t), sizeof (nfsstat)}, 288*7c478bd9Sstevel@tonic-gate }; 289*7c478bd9Sstevel@tonic-gate 290*7c478bd9Sstevel@tonic-gate 291*7c478bd9Sstevel@tonic-gate /* 292*7c478bd9Sstevel@tonic-gate * NFS VERSION 3 293*7c478bd9Sstevel@tonic-gate */ 294*7c478bd9Sstevel@tonic-gate 295*7c478bd9Sstevel@tonic-gate static struct nfsl_fh_proc_disp nfsl_fh_proc_v3[] = { 296*7c478bd9Sstevel@tonic-gate 297*7c478bd9Sstevel@tonic-gate /* RFS_NULL = 0 */ 298*7c478bd9Sstevel@tonic-gate {nfslog_null_fhargs, xdr_void, xdr_void, 0, 0}, 299*7c478bd9Sstevel@tonic-gate 300*7c478bd9Sstevel@tonic-gate /* RFS3_GETATTR = 1 */ 301*7c478bd9Sstevel@tonic-gate {nfslog_GETATTR3_fhargs, xdr_nfs_fh3, xdr_nfsstat3, 302*7c478bd9Sstevel@tonic-gate sizeof (nfs_fh3), sizeof (nfsstat3)}, 303*7c478bd9Sstevel@tonic-gate 304*7c478bd9Sstevel@tonic-gate /* RFS3_SETATTR = 2 */ 305*7c478bd9Sstevel@tonic-gate {nfslog_SETATTR3_fhargs, xdr_nfslog_SETATTR3args, xdr_nfsstat3, 306*7c478bd9Sstevel@tonic-gate sizeof (nfslog_SETATTR3args), sizeof (nfsstat3)}, 307*7c478bd9Sstevel@tonic-gate 308*7c478bd9Sstevel@tonic-gate /* RFS3_LOOKUP = 3 */ 309*7c478bd9Sstevel@tonic-gate {nfslog_LOOKUP3_fhargs, xdr_nfslog_diropargs3, xdr_nfslog_LOOKUP3res, 310*7c478bd9Sstevel@tonic-gate sizeof (nfslog_diropargs3), sizeof (nfslog_LOOKUP3res)}, 311*7c478bd9Sstevel@tonic-gate 312*7c478bd9Sstevel@tonic-gate /* RFS3_ACCESS = 4 */ 313*7c478bd9Sstevel@tonic-gate {nfslog_ACCESS3_fhargs, xdr_nfs_fh3, xdr_nfsstat3, 314*7c478bd9Sstevel@tonic-gate sizeof (nfs_fh3), sizeof (nfsstat3)}, 315*7c478bd9Sstevel@tonic-gate 316*7c478bd9Sstevel@tonic-gate /* RFS3_READLINK = 5 */ 317*7c478bd9Sstevel@tonic-gate {nfslog_READLINK3_fhargs, xdr_nfs_fh3, xdr_nfslog_READLINK3res, 318*7c478bd9Sstevel@tonic-gate sizeof (nfs_fh3), sizeof (nfslog_READLINK3res)}, 319*7c478bd9Sstevel@tonic-gate 320*7c478bd9Sstevel@tonic-gate /* RFS3_READ = 6 */ 321*7c478bd9Sstevel@tonic-gate {nfslog_READ3_fhargs, xdr_nfslog_READ3args, xdr_nfslog_READ3res, 322*7c478bd9Sstevel@tonic-gate sizeof (nfslog_READ3args), sizeof (nfslog_READ3res)}, 323*7c478bd9Sstevel@tonic-gate 324*7c478bd9Sstevel@tonic-gate /* RFS3_WRITE = 7 */ 325*7c478bd9Sstevel@tonic-gate {nfslog_WRITE3_fhargs, xdr_nfslog_WRITE3args, xdr_nfslog_WRITE3res, 326*7c478bd9Sstevel@tonic-gate sizeof (nfslog_WRITE3args), sizeof (nfslog_WRITE3res)}, 327*7c478bd9Sstevel@tonic-gate 328*7c478bd9Sstevel@tonic-gate /* RFS3_CREATE = 8 */ 329*7c478bd9Sstevel@tonic-gate {nfslog_CREATE3_fhargs, xdr_nfslog_CREATE3args, xdr_nfslog_CREATE3res, 330*7c478bd9Sstevel@tonic-gate sizeof (nfslog_CREATE3args), sizeof (nfslog_CREATE3res)}, 331*7c478bd9Sstevel@tonic-gate 332*7c478bd9Sstevel@tonic-gate /* RFS3_MKDIR = 9 */ 333*7c478bd9Sstevel@tonic-gate {nfslog_MKDIR3_fhargs, xdr_nfslog_MKDIR3args, xdr_nfslog_MKDIR3res, 334*7c478bd9Sstevel@tonic-gate sizeof (nfslog_MKDIR3args), sizeof (nfslog_MKDIR3res)}, 335*7c478bd9Sstevel@tonic-gate 336*7c478bd9Sstevel@tonic-gate /* RFS3_SYMLINK = 10 */ 337*7c478bd9Sstevel@tonic-gate {nfslog_SYMLINK3_fhargs, xdr_nfslog_SYMLINK3args, 338*7c478bd9Sstevel@tonic-gate xdr_nfslog_SYMLINK3res, 339*7c478bd9Sstevel@tonic-gate sizeof (nfslog_SYMLINK3args), sizeof (nfslog_SYMLINK3res)}, 340*7c478bd9Sstevel@tonic-gate 341*7c478bd9Sstevel@tonic-gate /* RFS3_MKNOD = 11 */ 342*7c478bd9Sstevel@tonic-gate {nfslog_MKNOD3_fhargs, xdr_nfslog_MKNOD3args, xdr_nfslog_MKNOD3res, 343*7c478bd9Sstevel@tonic-gate sizeof (nfslog_MKNOD3args), sizeof (nfslog_MKNOD3res)}, 344*7c478bd9Sstevel@tonic-gate 345*7c478bd9Sstevel@tonic-gate /* RFS3_REMOVE = 12 */ 346*7c478bd9Sstevel@tonic-gate {nfslog_REMOVE3_fhargs, xdr_nfslog_REMOVE3args, xdr_nfsstat3, 347*7c478bd9Sstevel@tonic-gate sizeof (nfslog_REMOVE3args), sizeof (nfsstat3)}, 348*7c478bd9Sstevel@tonic-gate 349*7c478bd9Sstevel@tonic-gate /* RFS3_RMDIR = 13 */ 350*7c478bd9Sstevel@tonic-gate {nfslog_RMDIR3_fhargs, xdr_nfslog_RMDIR3args, xdr_nfsstat3, 351*7c478bd9Sstevel@tonic-gate sizeof (nfslog_RMDIR3args), sizeof (nfsstat3)}, 352*7c478bd9Sstevel@tonic-gate 353*7c478bd9Sstevel@tonic-gate /* RFS3_RENAME = 14 */ 354*7c478bd9Sstevel@tonic-gate {nfslog_RENAME3_fhargs, xdr_nfslog_RENAME3args, xdr_nfsstat3, 355*7c478bd9Sstevel@tonic-gate sizeof (nfslog_RENAME3args), sizeof (nfsstat3)}, 356*7c478bd9Sstevel@tonic-gate 357*7c478bd9Sstevel@tonic-gate /* RFS3_LINK = 15 */ 358*7c478bd9Sstevel@tonic-gate {nfslog_LINK3_fhargs, xdr_nfslog_LINK3args, xdr_nfsstat3, 359*7c478bd9Sstevel@tonic-gate sizeof (nfslog_LINK3args), sizeof (nfsstat3)}, 360*7c478bd9Sstevel@tonic-gate 361*7c478bd9Sstevel@tonic-gate /* RFS3_READDIR = 16 */ 362*7c478bd9Sstevel@tonic-gate {nfslog_READDIR3_fhargs, xdr_nfs_fh3, xdr_nfsstat3, 363*7c478bd9Sstevel@tonic-gate sizeof (nfs_fh3), sizeof (nfsstat3)}, 364*7c478bd9Sstevel@tonic-gate 365*7c478bd9Sstevel@tonic-gate /* RFS3_READDIRPLUS = 17 */ 366*7c478bd9Sstevel@tonic-gate {nfslog_READDIRPLUS3_fhargs, 367*7c478bd9Sstevel@tonic-gate xdr_nfslog_READDIRPLUS3args, xdr_nfslog_READDIRPLUS3res, 368*7c478bd9Sstevel@tonic-gate sizeof (nfslog_READDIRPLUS3args), 369*7c478bd9Sstevel@tonic-gate sizeof (nfslog_READDIRPLUS3res)}, 370*7c478bd9Sstevel@tonic-gate 371*7c478bd9Sstevel@tonic-gate /* RFS3_FSSTAT = 18 */ 372*7c478bd9Sstevel@tonic-gate {nfslog_FSSTAT3_fhargs, xdr_nfs_fh3, xdr_nfsstat3, 373*7c478bd9Sstevel@tonic-gate sizeof (nfs_fh3), sizeof (nfsstat3)}, 374*7c478bd9Sstevel@tonic-gate 375*7c478bd9Sstevel@tonic-gate /* RFS3_FSINFO = 19 */ 376*7c478bd9Sstevel@tonic-gate {nfslog_FSINFO3_fhargs, xdr_nfs_fh3, xdr_nfsstat3, 377*7c478bd9Sstevel@tonic-gate sizeof (nfs_fh3), sizeof (nfsstat3)}, 378*7c478bd9Sstevel@tonic-gate 379*7c478bd9Sstevel@tonic-gate /* RFS3_PATHCONF = 20 */ 380*7c478bd9Sstevel@tonic-gate {nfslog_PATHCONF3_fhargs, xdr_nfs_fh3, xdr_nfsstat3, 381*7c478bd9Sstevel@tonic-gate sizeof (nfs_fh3), sizeof (nfsstat3)}, 382*7c478bd9Sstevel@tonic-gate 383*7c478bd9Sstevel@tonic-gate /* RFS3_COMMIT = 21 */ 384*7c478bd9Sstevel@tonic-gate {nfslog_COMMIT3_fhargs, xdr_nfslog_COMMIT3args, xdr_nfsstat3, 385*7c478bd9Sstevel@tonic-gate sizeof (nfslog_COMMIT3args), sizeof (nfsstat3)}, 386*7c478bd9Sstevel@tonic-gate }; 387*7c478bd9Sstevel@tonic-gate 388*7c478bd9Sstevel@tonic-gate /* 389*7c478bd9Sstevel@tonic-gate * NFSLOG VERSION 1 390*7c478bd9Sstevel@tonic-gate */ 391*7c478bd9Sstevel@tonic-gate 392*7c478bd9Sstevel@tonic-gate static struct nfsl_fh_proc_disp nfsl_log_fh_proc_v1[] = { 393*7c478bd9Sstevel@tonic-gate 394*7c478bd9Sstevel@tonic-gate /* NFSLOG_NULL = 0 */ 395*7c478bd9Sstevel@tonic-gate {nfslog_null_fhargs, xdr_void, xdr_void, 0, 0}, 396*7c478bd9Sstevel@tonic-gate 397*7c478bd9Sstevel@tonic-gate /* NFSLOG_SHARE = 1 */ 398*7c478bd9Sstevel@tonic-gate {nfslog_SHARE_fhargs, xdr_nfslog_sharefsargs, xdr_nfslog_sharefsres, 399*7c478bd9Sstevel@tonic-gate sizeof (nfslog_sharefsargs), sizeof (nfslog_sharefsres)}, 400*7c478bd9Sstevel@tonic-gate 401*7c478bd9Sstevel@tonic-gate /* NFSLOG_UNSHARE = 2 */ 402*7c478bd9Sstevel@tonic-gate {nfslog_UNSHARE_fhargs, xdr_nfslog_sharefsargs, xdr_nfslog_sharefsres, 403*7c478bd9Sstevel@tonic-gate sizeof (nfslog_sharefsargs), sizeof (nfslog_sharefsres)}, 404*7c478bd9Sstevel@tonic-gate 405*7c478bd9Sstevel@tonic-gate /* NFSLOG_LOOKUP3 = 3 */ 406*7c478bd9Sstevel@tonic-gate {nfslog_LOOKUP3_fhargs, xdr_nfslog_diropargs3, xdr_nfslog_LOOKUP3res, 407*7c478bd9Sstevel@tonic-gate sizeof (nfslog_diropargs3), sizeof (nfslog_LOOKUP3res)}, 408*7c478bd9Sstevel@tonic-gate 409*7c478bd9Sstevel@tonic-gate /* NFSLOG_GETFH = 4 */ 410*7c478bd9Sstevel@tonic-gate {nfslog_GETFH_fhargs, xdr_nfslog_getfhargs, xdr_nfsstat, 411*7c478bd9Sstevel@tonic-gate sizeof (nfslog_getfhargs), sizeof (nfsstat)}, 412*7c478bd9Sstevel@tonic-gate }; 413*7c478bd9Sstevel@tonic-gate 414*7c478bd9Sstevel@tonic-gate static struct nfsl_fh_vers_disp nfsl_fh_vers_disptable[] = { 415*7c478bd9Sstevel@tonic-gate {sizeof (nfsl_fh_proc_v2) / sizeof (nfsl_fh_proc_v2[0]), 416*7c478bd9Sstevel@tonic-gate nfsl_fh_proc_v2}, 417*7c478bd9Sstevel@tonic-gate {sizeof (nfsl_fh_proc_v3) / sizeof (nfsl_fh_proc_v3[0]), 418*7c478bd9Sstevel@tonic-gate nfsl_fh_proc_v3}, 419*7c478bd9Sstevel@tonic-gate }; 420*7c478bd9Sstevel@tonic-gate 421*7c478bd9Sstevel@tonic-gate static struct nfsl_fh_vers_disp nfsl_log_fh_vers_disptable[] = { 422*7c478bd9Sstevel@tonic-gate {sizeof (nfsl_log_fh_proc_v1) / sizeof (nfsl_log_fh_proc_v1[0]), 423*7c478bd9Sstevel@tonic-gate nfsl_log_fh_proc_v1}, 424*7c478bd9Sstevel@tonic-gate }; 425*7c478bd9Sstevel@tonic-gate 426*7c478bd9Sstevel@tonic-gate static struct nfsl_fh_prog_disp nfsl_fh_dispatch_table[] = { 427*7c478bd9Sstevel@tonic-gate {NFS_PROGRAM, 428*7c478bd9Sstevel@tonic-gate NFS_VERSMIN, 429*7c478bd9Sstevel@tonic-gate sizeof (nfsl_fh_vers_disptable) / 430*7c478bd9Sstevel@tonic-gate sizeof (nfsl_fh_vers_disptable[0]), 431*7c478bd9Sstevel@tonic-gate nfsl_fh_vers_disptable}, 432*7c478bd9Sstevel@tonic-gate {NFSLOG_PROGRAM, 433*7c478bd9Sstevel@tonic-gate NFSLOG_VERSMIN, 434*7c478bd9Sstevel@tonic-gate sizeof (nfsl_log_fh_vers_disptable) / 435*7c478bd9Sstevel@tonic-gate sizeof (nfsl_log_fh_vers_disptable[0]), 436*7c478bd9Sstevel@tonic-gate nfsl_log_fh_vers_disptable}, 437*7c478bd9Sstevel@tonic-gate }; 438*7c478bd9Sstevel@tonic-gate 439*7c478bd9Sstevel@tonic-gate static int nfsl_fh_dispatch_table_arglen = 440*7c478bd9Sstevel@tonic-gate sizeof (nfsl_fh_dispatch_table) / 441*7c478bd9Sstevel@tonic-gate sizeof (nfsl_fh_dispatch_table[0]); 442*7c478bd9Sstevel@tonic-gate 443*7c478bd9Sstevel@tonic-gate extern int debug; 444*7c478bd9Sstevel@tonic-gate 445*7c478bd9Sstevel@tonic-gate /* 446*7c478bd9Sstevel@tonic-gate * print the fid into the given string as a series of hex digits. 447*7c478bd9Sstevel@tonic-gate * XXX Ideally, we'd like to just convert the filehandle into an i-number, 448*7c478bd9Sstevel@tonic-gate * but the fid encoding is a little tricky (see nfs_fhtovp() and 449*7c478bd9Sstevel@tonic-gate * ufs_vget()) and may be private to UFS. 450*7c478bd9Sstevel@tonic-gate */ 451*7c478bd9Sstevel@tonic-gate 452*7c478bd9Sstevel@tonic-gate static void 453*7c478bd9Sstevel@tonic-gate sprint_fid(char *buf, uint_t buflen, const fhandle_t *fh) 454*7c478bd9Sstevel@tonic-gate { 455*7c478bd9Sstevel@tonic-gate int i; 456*7c478bd9Sstevel@tonic-gate uchar_t byte; 457*7c478bd9Sstevel@tonic-gate uint_t fhlen; 458*7c478bd9Sstevel@tonic-gate 459*7c478bd9Sstevel@tonic-gate /* 460*7c478bd9Sstevel@tonic-gate * If the filehandle somehow got corrupted, only print the part 461*7c478bd9Sstevel@tonic-gate * that makes sense. 462*7c478bd9Sstevel@tonic-gate */ 463*7c478bd9Sstevel@tonic-gate if (fh->fh_len > NFS_FHMAXDATA) 464*7c478bd9Sstevel@tonic-gate fhlen = NFS_FHMAXDATA; 465*7c478bd9Sstevel@tonic-gate else 466*7c478bd9Sstevel@tonic-gate fhlen = fh->fh_len; 467*7c478bd9Sstevel@tonic-gate assert(2 * fhlen < buflen); 468*7c478bd9Sstevel@tonic-gate 469*7c478bd9Sstevel@tonic-gate for (i = 0; i < fhlen; i++) { 470*7c478bd9Sstevel@tonic-gate byte = fh->fh_data[i]; 471*7c478bd9Sstevel@tonic-gate (void) sprintf(buf + 2 * i, "%02x", byte); 472*7c478bd9Sstevel@tonic-gate } 473*7c478bd9Sstevel@tonic-gate } 474*7c478bd9Sstevel@tonic-gate 475*7c478bd9Sstevel@tonic-gate static void 476*7c478bd9Sstevel@tonic-gate fh_print_all_keys(char *fhpath, fhandle_t *fh) 477*7c478bd9Sstevel@tonic-gate { 478*7c478bd9Sstevel@tonic-gate if ((fhpath == NULL) || (fh == NULL) || (debug <= 1)) 479*7c478bd9Sstevel@tonic-gate return; 480*7c478bd9Sstevel@tonic-gate (void) printf("\nBegin all database keys\n"); 481*7c478bd9Sstevel@tonic-gate db_print_all_keys(fhpath, &fh->fh_fsid, stdout); 482*7c478bd9Sstevel@tonic-gate (void) printf("\nEnd all database keys\n"); 483*7c478bd9Sstevel@tonic-gate } 484*7c478bd9Sstevel@tonic-gate 485*7c478bd9Sstevel@tonic-gate #define FH_ADD(path, dfh, fh, name) \ 486*7c478bd9Sstevel@tonic-gate fh_add(path, dfh, fh, name) 487*7c478bd9Sstevel@tonic-gate 488*7c478bd9Sstevel@tonic-gate /* 489*7c478bd9Sstevel@tonic-gate * Add the filehandle "fh", which has the name "name" and lives in 490*7c478bd9Sstevel@tonic-gate * directory "dfh", to the table "fhlist". "fhlist" will be updated if the 491*7c478bd9Sstevel@tonic-gate * entry is added to the front of the list. 492*7c478bd9Sstevel@tonic-gate * Return 0 for success, error code otherwise. 493*7c478bd9Sstevel@tonic-gate */ 494*7c478bd9Sstevel@tonic-gate static int 495*7c478bd9Sstevel@tonic-gate fh_add(char *fhpath, fhandle_t *dfh, fhandle_t *fh, char *name) 496*7c478bd9Sstevel@tonic-gate { 497*7c478bd9Sstevel@tonic-gate uint_t flags = 0; 498*7c478bd9Sstevel@tonic-gate int error; 499*7c478bd9Sstevel@tonic-gate 500*7c478bd9Sstevel@tonic-gate if (IS_DOT_FILENAME(name)) { 501*7c478bd9Sstevel@tonic-gate /* we don't insert these to the database but not an error */ 502*7c478bd9Sstevel@tonic-gate if (debug > 3) { 503*7c478bd9Sstevel@tonic-gate PRINT_FULL_DATA(stdout, "fh_add", dfh, fh, name, 504*7c478bd9Sstevel@tonic-gate " - no dot files") 505*7c478bd9Sstevel@tonic-gate } 506*7c478bd9Sstevel@tonic-gate return (0); 507*7c478bd9Sstevel@tonic-gate } 508*7c478bd9Sstevel@tonic-gate if (dfh && (memcmp(fh, dfh, NFS_FHSIZE) == 0)) { 509*7c478bd9Sstevel@tonic-gate flags |= EXPORT_POINT; 510*7c478bd9Sstevel@tonic-gate } 511*7c478bd9Sstevel@tonic-gate 512*7c478bd9Sstevel@tonic-gate /* Add to database */ 513*7c478bd9Sstevel@tonic-gate error = db_add(fhpath, dfh, name, fh, flags); 514*7c478bd9Sstevel@tonic-gate if (debug > 1) { 515*7c478bd9Sstevel@tonic-gate if (error != 0) { 516*7c478bd9Sstevel@tonic-gate (void) printf("db_add error %s:\n", 517*7c478bd9Sstevel@tonic-gate ((error >= 0) ? strerror(error) : "Unknown")); 518*7c478bd9Sstevel@tonic-gate PRINT_FULL_DATA(stdout, "fh_add", dfh, fh, name, "") 519*7c478bd9Sstevel@tonic-gate } else if (debug > 2) { 520*7c478bd9Sstevel@tonic-gate PRINT_FULL_DATA(stdout, "fh_add", dfh, fh, name, "") 521*7c478bd9Sstevel@tonic-gate } 522*7c478bd9Sstevel@tonic-gate } 523*7c478bd9Sstevel@tonic-gate return (error); 524*7c478bd9Sstevel@tonic-gate } 525*7c478bd9Sstevel@tonic-gate 526*7c478bd9Sstevel@tonic-gate /* 527*7c478bd9Sstevel@tonic-gate * fh_compare returns 0 if the file handles match, error code otherwise 528*7c478bd9Sstevel@tonic-gate */ 529*7c478bd9Sstevel@tonic-gate static int 530*7c478bd9Sstevel@tonic-gate fh_compare(fhandle_t *fh1, fhandle_t *fh2) 531*7c478bd9Sstevel@tonic-gate { 532*7c478bd9Sstevel@tonic-gate if (memcmp(fh1, fh2, NFS_FHSIZE)) 533*7c478bd9Sstevel@tonic-gate return (errno); 534*7c478bd9Sstevel@tonic-gate else 535*7c478bd9Sstevel@tonic-gate return (0); 536*7c478bd9Sstevel@tonic-gate } 537*7c478bd9Sstevel@tonic-gate 538*7c478bd9Sstevel@tonic-gate /* 539*7c478bd9Sstevel@tonic-gate * Try to find the filehandle "fh" in the table. Returns 0 and the 540*7c478bd9Sstevel@tonic-gate * corresponding table entry if found, error otherwise. 541*7c478bd9Sstevel@tonic-gate * If successfull and fhrecpp is non-null then *fhrecpp points to the 542*7c478bd9Sstevel@tonic-gate * returned record. If *fhrecpp was initially null, that record had 543*7c478bd9Sstevel@tonic-gate * been malloc'd and must be freed by caller. 544*7c478bd9Sstevel@tonic-gate */ 545*7c478bd9Sstevel@tonic-gate 546*7c478bd9Sstevel@tonic-gate static fhlist_ent * 547*7c478bd9Sstevel@tonic-gate fh_lookup(char *fhpath, fhandle_t *fh, fhlist_ent *fhrecp, int *errorp) 548*7c478bd9Sstevel@tonic-gate { 549*7c478bd9Sstevel@tonic-gate if (debug > 3) { 550*7c478bd9Sstevel@tonic-gate (void) printf("fh_lookup: fh "); 551*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, fh, sizeof (*fh)); 552*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 553*7c478bd9Sstevel@tonic-gate } 554*7c478bd9Sstevel@tonic-gate return (db_lookup(fhpath, fh, fhrecp, errorp)); 555*7c478bd9Sstevel@tonic-gate } 556*7c478bd9Sstevel@tonic-gate 557*7c478bd9Sstevel@tonic-gate /* 558*7c478bd9Sstevel@tonic-gate * Remove the mc link if exists when removing a regular link. 559*7c478bd9Sstevel@tonic-gate * Return 0 for success, error code otherwise. 560*7c478bd9Sstevel@tonic-gate */ 561*7c478bd9Sstevel@tonic-gate static int 562*7c478bd9Sstevel@tonic-gate fh_remove_mc_link(char *fhpath, fhandle_t *dfh, char *name, char **pathp) 563*7c478bd9Sstevel@tonic-gate { 564*7c478bd9Sstevel@tonic-gate int error; 565*7c478bd9Sstevel@tonic-gate char *str, *str1; 566*7c478bd9Sstevel@tonic-gate 567*7c478bd9Sstevel@tonic-gate /* Delete the multi-component path if exists */ 568*7c478bd9Sstevel@tonic-gate if ((pathp == NULL) || (*pathp == NULL)) { 569*7c478bd9Sstevel@tonic-gate str = nfslog_get_path(dfh, name, fhpath, "remove_mc_link"); 570*7c478bd9Sstevel@tonic-gate str1 = str; 571*7c478bd9Sstevel@tonic-gate } else { 572*7c478bd9Sstevel@tonic-gate str = *pathp; 573*7c478bd9Sstevel@tonic-gate str1 = NULL; 574*7c478bd9Sstevel@tonic-gate } 575*7c478bd9Sstevel@tonic-gate error = db_delete_link(fhpath, &public_fh, str); 576*7c478bd9Sstevel@tonic-gate if (str1 != NULL) 577*7c478bd9Sstevel@tonic-gate free(str1); 578*7c478bd9Sstevel@tonic-gate return (error); 579*7c478bd9Sstevel@tonic-gate } 580*7c478bd9Sstevel@tonic-gate 581*7c478bd9Sstevel@tonic-gate /* 582*7c478bd9Sstevel@tonic-gate * Remove the link entry from the fh table. 583*7c478bd9Sstevel@tonic-gate * Return 0 for success, error code otherwise. 584*7c478bd9Sstevel@tonic-gate */ 585*7c478bd9Sstevel@tonic-gate static int 586*7c478bd9Sstevel@tonic-gate fh_remove(char *fhpath, fhandle_t *dfh, char *name, char **pathp) 587*7c478bd9Sstevel@tonic-gate { 588*7c478bd9Sstevel@tonic-gate /* 589*7c478bd9Sstevel@tonic-gate * disconnect element from list 590*7c478bd9Sstevel@tonic-gate * 591*7c478bd9Sstevel@tonic-gate * Remove the link entry for the file. Remove fh entry if last link. 592*7c478bd9Sstevel@tonic-gate */ 593*7c478bd9Sstevel@tonic-gate if (IS_DOT_FILENAME(name)) { 594*7c478bd9Sstevel@tonic-gate /* we don't insert these to the database but not an error */ 595*7c478bd9Sstevel@tonic-gate if (debug > 2) { 596*7c478bd9Sstevel@tonic-gate PRINT_LINK_DATA(stdout, "fh_remove", dfh, name, 597*7c478bd9Sstevel@tonic-gate " - no dot files") 598*7c478bd9Sstevel@tonic-gate } 599*7c478bd9Sstevel@tonic-gate return (0); 600*7c478bd9Sstevel@tonic-gate } 601*7c478bd9Sstevel@tonic-gate if (debug > 2) { 602*7c478bd9Sstevel@tonic-gate PRINT_LINK_DATA(stdout, "fh_remove", dfh, name, "") 603*7c478bd9Sstevel@tonic-gate } 604*7c478bd9Sstevel@tonic-gate /* Delete the multi-component path if exists */ 605*7c478bd9Sstevel@tonic-gate (void) fh_remove_mc_link(fhpath, dfh, name, pathp); 606*7c478bd9Sstevel@tonic-gate return (db_delete_link(fhpath, dfh, name)); 607*7c478bd9Sstevel@tonic-gate } 608*7c478bd9Sstevel@tonic-gate 609*7c478bd9Sstevel@tonic-gate /* 610*7c478bd9Sstevel@tonic-gate * fh_rename - renames a link in the database (adds the new one if from link 611*7c478bd9Sstevel@tonic-gate * did not exist). 612*7c478bd9Sstevel@tonic-gate * Return 0 for success, error code otherwise. 613*7c478bd9Sstevel@tonic-gate */ 614*7c478bd9Sstevel@tonic-gate static int 615*7c478bd9Sstevel@tonic-gate fh_rename(char *fhpath, fhandle_t *from_dfh, char *from_name, char **from_pathp, 616*7c478bd9Sstevel@tonic-gate fhandle_t *to_dfh, char *to_name) 617*7c478bd9Sstevel@tonic-gate { 618*7c478bd9Sstevel@tonic-gate if (debug > 2) { 619*7c478bd9Sstevel@tonic-gate PRINT_LINK_DATA(stdout, "fh_rename: from:", from_dfh, 620*7c478bd9Sstevel@tonic-gate from_name, "") 621*7c478bd9Sstevel@tonic-gate PRINT_LINK_DATA(stdout, "fh_rename: to :", to_dfh, 622*7c478bd9Sstevel@tonic-gate to_name, "") 623*7c478bd9Sstevel@tonic-gate } 624*7c478bd9Sstevel@tonic-gate /* 625*7c478bd9Sstevel@tonic-gate * if any of these are dot files (should not happen), the rename 626*7c478bd9Sstevel@tonic-gate * becomes a "delete" or "add" operation because the dot files 627*7c478bd9Sstevel@tonic-gate * don't get in the database 628*7c478bd9Sstevel@tonic-gate */ 629*7c478bd9Sstevel@tonic-gate if (IS_DOT_FILENAME(to_name)) { 630*7c478bd9Sstevel@tonic-gate /* it is just a delete op */ 631*7c478bd9Sstevel@tonic-gate if (debug > 2) { 632*7c478bd9Sstevel@tonic-gate (void) printf("to: no dot files\nDelete from: '%s'\n", 633*7c478bd9Sstevel@tonic-gate from_name); 634*7c478bd9Sstevel@tonic-gate } 635*7c478bd9Sstevel@tonic-gate return (fh_remove(fhpath, from_dfh, from_name, from_pathp)); 636*7c478bd9Sstevel@tonic-gate } else if (IS_DOT_FILENAME(from_name)) { 637*7c478bd9Sstevel@tonic-gate /* we don't insert these to the database */ 638*7c478bd9Sstevel@tonic-gate if (debug > 2) { 639*7c478bd9Sstevel@tonic-gate (void) printf("rename - from: no dot files\n"); 640*7c478bd9Sstevel@tonic-gate } 641*7c478bd9Sstevel@tonic-gate /* can't insert the target, because don't have a handle */ 642*7c478bd9Sstevel@tonic-gate return (EINVAL); 643*7c478bd9Sstevel@tonic-gate } 644*7c478bd9Sstevel@tonic-gate /* Delete the multi-component path if exists */ 645*7c478bd9Sstevel@tonic-gate (void) fh_remove_mc_link(fhpath, from_dfh, from_name, from_pathp); 646*7c478bd9Sstevel@tonic-gate return (db_rename_link(fhpath, from_dfh, from_name, to_dfh, to_name)); 647*7c478bd9Sstevel@tonic-gate } 648*7c478bd9Sstevel@tonic-gate 649*7c478bd9Sstevel@tonic-gate /* 650*7c478bd9Sstevel@tonic-gate * fh_lookup_link - search the fhtable for the link defined by (dfh,name,fh). 651*7c478bd9Sstevel@tonic-gate * Return 0 and set *fhrecpp to the fhlist item corresponding to it if found, 652*7c478bd9Sstevel@tonic-gate * or error if not found. 653*7c478bd9Sstevel@tonic-gate * Possible configurations: 654*7c478bd9Sstevel@tonic-gate * 1. dfh, fh, name are all non-null: Only exact match accepted. 655*7c478bd9Sstevel@tonic-gate * 2. dfh,name non-null, fh null: return first match found. 656*7c478bd9Sstevel@tonic-gate * 3. fh,name non-null, dfh null: return first match found. 657*7c478bd9Sstevel@tonic-gate * 3. fh non-null, dfh, name null: return first match found. 658*7c478bd9Sstevel@tonic-gate * If successfull and fhrecpp is non-null then *fhrecpp points to the 659*7c478bd9Sstevel@tonic-gate * returned record. If *fhrecpp was initially null, that record had 660*7c478bd9Sstevel@tonic-gate * been malloc'd and must be freed by caller. 661*7c478bd9Sstevel@tonic-gate */ 662*7c478bd9Sstevel@tonic-gate static fhlist_ent * 663*7c478bd9Sstevel@tonic-gate fh_lookup_link(char *fhpath, fhandle_t *dfh, fhandle_t *fh, char *name, 664*7c478bd9Sstevel@tonic-gate fhlist_ent *fhrecp, int *errorp) 665*7c478bd9Sstevel@tonic-gate { 666*7c478bd9Sstevel@tonic-gate fhlist_ent *in_fhrecp = fhrecp; 667*7c478bd9Sstevel@tonic-gate 668*7c478bd9Sstevel@tonic-gate if ((name != NULL) && IS_DOT_FILENAME(name)) { 669*7c478bd9Sstevel@tonic-gate /* we don't insert these to the database but not an error */ 670*7c478bd9Sstevel@tonic-gate if (debug > 2) { 671*7c478bd9Sstevel@tonic-gate PRINT_FULL_DATA(stdout, "fh_lookup_link", dfh, fh, name, 672*7c478bd9Sstevel@tonic-gate " - no dot files\n") 673*7c478bd9Sstevel@tonic-gate } 674*7c478bd9Sstevel@tonic-gate *errorp = 0; 675*7c478bd9Sstevel@tonic-gate return (NULL); 676*7c478bd9Sstevel@tonic-gate } 677*7c478bd9Sstevel@tonic-gate if (debug > 3) { 678*7c478bd9Sstevel@tonic-gate PRINT_FULL_DATA(stdout, "fh_lookup_link", dfh, fh, name, "") 679*7c478bd9Sstevel@tonic-gate } 680*7c478bd9Sstevel@tonic-gate /* Add to database */ 681*7c478bd9Sstevel@tonic-gate if (fh != NULL) { 682*7c478bd9Sstevel@tonic-gate fhrecp = db_lookup(fhpath, fh, fhrecp, errorp); 683*7c478bd9Sstevel@tonic-gate if (fhrecp == NULL) { 684*7c478bd9Sstevel@tonic-gate if (debug > 3) 685*7c478bd9Sstevel@tonic-gate (void) printf("fh_lookup_link: fh not found\n"); 686*7c478bd9Sstevel@tonic-gate return (NULL); 687*7c478bd9Sstevel@tonic-gate } 688*7c478bd9Sstevel@tonic-gate /* Check if name and dfh match, if not search link */ 689*7c478bd9Sstevel@tonic-gate if (((dfh == NULL) || !fh_compare(dfh, &fhrecp->dfh)) && 690*7c478bd9Sstevel@tonic-gate ((name == NULL) || (strcmp(name, fhrecp->name) == 0))) { 691*7c478bd9Sstevel@tonic-gate /* found it */ 692*7c478bd9Sstevel@tonic-gate goto exit; 693*7c478bd9Sstevel@tonic-gate } 694*7c478bd9Sstevel@tonic-gate /* Found the primary record, but it's a different link */ 695*7c478bd9Sstevel@tonic-gate if (debug == 3) { /* Only log if >2 but already printed */ 696*7c478bd9Sstevel@tonic-gate PRINT_FULL_DATA(stdout, "fh_lookup_link", dfh, fh, 697*7c478bd9Sstevel@tonic-gate name, "") 698*7c478bd9Sstevel@tonic-gate } 699*7c478bd9Sstevel@tonic-gate if (debug > 2) { 700*7c478bd9Sstevel@tonic-gate PRINT_LINK_DATA(stdout, "Different primary link", 701*7c478bd9Sstevel@tonic-gate &fhrecp->dfh, fhrecp->name, "") 702*7c478bd9Sstevel@tonic-gate } 703*7c478bd9Sstevel@tonic-gate /* can now free the record unless it was supplied by caller */ 704*7c478bd9Sstevel@tonic-gate if (fhrecp != in_fhrecp) { 705*7c478bd9Sstevel@tonic-gate free(fhrecp); 706*7c478bd9Sstevel@tonic-gate fhrecp = NULL; 707*7c478bd9Sstevel@tonic-gate } 708*7c478bd9Sstevel@tonic-gate } 709*7c478bd9Sstevel@tonic-gate /* If here, we must search by link */ 710*7c478bd9Sstevel@tonic-gate if ((dfh == NULL) || (name == NULL)) { 711*7c478bd9Sstevel@tonic-gate if (debug > 2) 712*7c478bd9Sstevel@tonic-gate (void) printf("fh_lookup_link: invalid params\n"); 713*7c478bd9Sstevel@tonic-gate *errorp = EINVAL; 714*7c478bd9Sstevel@tonic-gate return (NULL); 715*7c478bd9Sstevel@tonic-gate } 716*7c478bd9Sstevel@tonic-gate fhrecp = db_lookup_link(fhpath, dfh, name, fhrecp, errorp); 717*7c478bd9Sstevel@tonic-gate if (fhrecp == NULL) { 718*7c478bd9Sstevel@tonic-gate if (debug > 3) 719*7c478bd9Sstevel@tonic-gate (void) printf("fh_lookup_link: link not found: %s\n", 720*7c478bd9Sstevel@tonic-gate ((*errorp >= 0) ? strerror(*errorp) : "Unknown")); 721*7c478bd9Sstevel@tonic-gate return (NULL); 722*7c478bd9Sstevel@tonic-gate } 723*7c478bd9Sstevel@tonic-gate /* If all args supplied, check if an exact match */ 724*7c478bd9Sstevel@tonic-gate if ((fh != NULL) && fh_compare(fh, &fhrecp->fh)) { 725*7c478bd9Sstevel@tonic-gate if (debug > 2) { 726*7c478bd9Sstevel@tonic-gate PRINT_FULL_DATA(stderr, "fh_lookup_link", dfh, fh, 727*7c478bd9Sstevel@tonic-gate name, "") 728*7c478bd9Sstevel@tonic-gate PRINT_LINK_DATA(stderr, "Different primary link", 729*7c478bd9Sstevel@tonic-gate &fhrecp->dfh, fhrecp->name, "") 730*7c478bd9Sstevel@tonic-gate } 731*7c478bd9Sstevel@tonic-gate if (fhrecp != in_fhrecp) 732*7c478bd9Sstevel@tonic-gate free(fhrecp); 733*7c478bd9Sstevel@tonic-gate *errorp = EINVAL; 734*7c478bd9Sstevel@tonic-gate return (NULL); 735*7c478bd9Sstevel@tonic-gate } 736*7c478bd9Sstevel@tonic-gate exit: 737*7c478bd9Sstevel@tonic-gate if (debug > 3) 738*7c478bd9Sstevel@tonic-gate (void) printf("lookup: found '%s' in fhtable\n", name); 739*7c478bd9Sstevel@tonic-gate *errorp = 0; 740*7c478bd9Sstevel@tonic-gate return (fhrecp); 741*7c478bd9Sstevel@tonic-gate } 742*7c478bd9Sstevel@tonic-gate 743*7c478bd9Sstevel@tonic-gate /* 744*7c478bd9Sstevel@tonic-gate * Export handle cache is maintained if we see an export handle that either 745*7c478bd9Sstevel@tonic-gate * cannot have the path for it determined, or we failed store it. 746*7c478bd9Sstevel@tonic-gate * Usually the path of an export handle can be identified in the NFSLOGTAB 747*7c478bd9Sstevel@tonic-gate * and since every path for that filesystem will be affected, it's worth 748*7c478bd9Sstevel@tonic-gate * caching the ones we had problem identifying. 749*7c478bd9Sstevel@tonic-gate */ 750*7c478bd9Sstevel@tonic-gate 751*7c478bd9Sstevel@tonic-gate /* 752*7c478bd9Sstevel@tonic-gate * find_fh_in_export_cache - given an export fh, find it in the cache and 753*7c478bd9Sstevel@tonic-gate * return the handle 754*7c478bd9Sstevel@tonic-gate */ 755*7c478bd9Sstevel@tonic-gate static struct export_handle_cache * 756*7c478bd9Sstevel@tonic-gate find_fh_in_export_cache(fhandle_t *fh) 757*7c478bd9Sstevel@tonic-gate { 758*7c478bd9Sstevel@tonic-gate struct export_handle_cache *p; 759*7c478bd9Sstevel@tonic-gate 760*7c478bd9Sstevel@tonic-gate for (p = exp_handle_cache; p != NULL; p = p->next) { 761*7c478bd9Sstevel@tonic-gate if (memcmp(fh, &p->fh, sizeof (*fh)) == 0) 762*7c478bd9Sstevel@tonic-gate break; 763*7c478bd9Sstevel@tonic-gate } 764*7c478bd9Sstevel@tonic-gate return (p); 765*7c478bd9Sstevel@tonic-gate } 766*7c478bd9Sstevel@tonic-gate 767*7c478bd9Sstevel@tonic-gate static void 768*7c478bd9Sstevel@tonic-gate add_fh_to_export_cache(fhandle_t *fh, char *path) 769*7c478bd9Sstevel@tonic-gate { 770*7c478bd9Sstevel@tonic-gate struct export_handle_cache *new; 771*7c478bd9Sstevel@tonic-gate 772*7c478bd9Sstevel@tonic-gate if ((new = malloc(sizeof (*new))) == NULL) { 773*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext( 774*7c478bd9Sstevel@tonic-gate "add_fh_to_export_cache: alloc new for '%s' Error %s\n"), 775*7c478bd9Sstevel@tonic-gate ((path != NULL) ? path : ""), strerror(errno)); 776*7c478bd9Sstevel@tonic-gate return; 777*7c478bd9Sstevel@tonic-gate } 778*7c478bd9Sstevel@tonic-gate if (path != NULL) { 779*7c478bd9Sstevel@tonic-gate if ((new->name = malloc(strlen(path) + 1)) == NULL) { 780*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext( 781*7c478bd9Sstevel@tonic-gate "add_fh_to_export_cache: alloc '%s'" 782*7c478bd9Sstevel@tonic-gate " Error %s\n"), path, strerror(errno)); 783*7c478bd9Sstevel@tonic-gate free(new); 784*7c478bd9Sstevel@tonic-gate return; 785*7c478bd9Sstevel@tonic-gate } 786*7c478bd9Sstevel@tonic-gate (void) strcpy(new->name, path); 787*7c478bd9Sstevel@tonic-gate } else { 788*7c478bd9Sstevel@tonic-gate new->name = NULL; 789*7c478bd9Sstevel@tonic-gate } 790*7c478bd9Sstevel@tonic-gate (void) memcpy(&new->fh, fh, sizeof (*fh)); 791*7c478bd9Sstevel@tonic-gate new->next = exp_handle_cache; 792*7c478bd9Sstevel@tonic-gate exp_handle_cache = new; 793*7c478bd9Sstevel@tonic-gate } 794*7c478bd9Sstevel@tonic-gate 795*7c478bd9Sstevel@tonic-gate /* 796*7c478bd9Sstevel@tonic-gate * update_export_point - called when the path for fh cannot be determined. 797*7c478bd9Sstevel@tonic-gate * In the past it called get_export_path() to get the name of the 798*7c478bd9Sstevel@tonic-gate * export point given a filehandle. This was a hack, since there's no 799*7c478bd9Sstevel@tonic-gate * reason why the filehandle should be lost. 800*7c478bd9Sstevel@tonic-gate * 801*7c478bd9Sstevel@tonic-gate * If a match is found, insert the path to the database. 802*7c478bd9Sstevel@tonic-gate * Return the inserted fhrecp is found, 803*7c478bd9Sstevel@tonic-gate * and NULL if not. If it is an exported fs but not in the list, log a 804*7c478bd9Sstevel@tonic-gate * error. 805*7c478bd9Sstevel@tonic-gate * If input fhrecp is non-null, it is a valid address for result, 806*7c478bd9Sstevel@tonic-gate * otherwise malloc it. 807*7c478bd9Sstevel@tonic-gate */ 808*7c478bd9Sstevel@tonic-gate static char * 809*7c478bd9Sstevel@tonic-gate update_export_point(char *fhpath, fhandle_t *fh, char *path) 810*7c478bd9Sstevel@tonic-gate { 811*7c478bd9Sstevel@tonic-gate struct export_handle_cache *p; 812*7c478bd9Sstevel@tonic-gate 813*7c478bd9Sstevel@tonic-gate if ((fh == NULL) || memcmp(&fh->fh_data, &fh->fh_xdata, fh->fh_len)) { 814*7c478bd9Sstevel@tonic-gate /* either null fh or not the root of a shared directory */ 815*7c478bd9Sstevel@tonic-gate return (NULL); 816*7c478bd9Sstevel@tonic-gate } 817*7c478bd9Sstevel@tonic-gate /* Did we already see (and fail) this one? */ 818*7c478bd9Sstevel@tonic-gate if ((p = find_fh_in_export_cache(fh)) != NULL) { 819*7c478bd9Sstevel@tonic-gate /* Found it! */ 820*7c478bd9Sstevel@tonic-gate if (debug > 2) { 821*7c478bd9Sstevel@tonic-gate PRINT_LINK_DATA(stdout, "update_export_point", 822*7c478bd9Sstevel@tonic-gate fh, ((p->name != NULL) ? p->name : ""), ""); 823*7c478bd9Sstevel@tonic-gate } 824*7c478bd9Sstevel@tonic-gate if (p->name == NULL) 825*7c478bd9Sstevel@tonic-gate return (NULL); 826*7c478bd9Sstevel@tonic-gate /* 827*7c478bd9Sstevel@tonic-gate * We should not normally be here - only add to cache if 828*7c478bd9Sstevel@tonic-gate * fh_add failed. 829*7c478bd9Sstevel@tonic-gate */ 830*7c478bd9Sstevel@tonic-gate if ((path == NULL) && 831*7c478bd9Sstevel@tonic-gate ((path = malloc(strlen(p->name) + 1)) == NULL)) { 832*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext( 833*7c478bd9Sstevel@tonic-gate "update_export_point: malloc '%s' Error %s"), 834*7c478bd9Sstevel@tonic-gate p->name, strerror(errno)); 835*7c478bd9Sstevel@tonic-gate return (NULL); 836*7c478bd9Sstevel@tonic-gate } 837*7c478bd9Sstevel@tonic-gate (void) strcpy(path, p->name); 838*7c478bd9Sstevel@tonic-gate return (path); 839*7c478bd9Sstevel@tonic-gate } 840*7c478bd9Sstevel@tonic-gate if ((path = get_export_path(fh, path)) == NULL) { 841*7c478bd9Sstevel@tonic-gate add_fh_to_export_cache(fh, NULL); 842*7c478bd9Sstevel@tonic-gate return (NULL); 843*7c478bd9Sstevel@tonic-gate } 844*7c478bd9Sstevel@tonic-gate /* Found it! */ 845*7c478bd9Sstevel@tonic-gate if (debug > 2) { 846*7c478bd9Sstevel@tonic-gate PRINT_LINK_DATA(stdout, "update_export_point", fh, path, "") 847*7c478bd9Sstevel@tonic-gate } 848*7c478bd9Sstevel@tonic-gate if (FH_ADD(fhpath, fh, fh, path)) { 849*7c478bd9Sstevel@tonic-gate /* cache this handle so we don't repeat the search */ 850*7c478bd9Sstevel@tonic-gate add_fh_to_export_cache(fh, path); 851*7c478bd9Sstevel@tonic-gate } 852*7c478bd9Sstevel@tonic-gate return (path); 853*7c478bd9Sstevel@tonic-gate } 854*7c478bd9Sstevel@tonic-gate 855*7c478bd9Sstevel@tonic-gate /* 856*7c478bd9Sstevel@tonic-gate * HACK!!! To get rid of get_export_path() use 857*7c478bd9Sstevel@tonic-gate */ 858*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 859*7c478bd9Sstevel@tonic-gate static char * 860*7c478bd9Sstevel@tonic-gate get_export_path(fhandle_t *fh, char *path) 861*7c478bd9Sstevel@tonic-gate { 862*7c478bd9Sstevel@tonic-gate return (NULL); 863*7c478bd9Sstevel@tonic-gate } 864*7c478bd9Sstevel@tonic-gate 865*7c478bd9Sstevel@tonic-gate /* 866*7c478bd9Sstevel@tonic-gate * Return the absolute pathname for the filehandle "fh", using the mapping 867*7c478bd9Sstevel@tonic-gate * table "fhlist". The caller must free the return string. 868*7c478bd9Sstevel@tonic-gate * name is an optional dir component name, to be appended at the end 869*7c478bd9Sstevel@tonic-gate * (if name is non-null, the function assumes the fh is the parent directory) 870*7c478bd9Sstevel@tonic-gate * 871*7c478bd9Sstevel@tonic-gate * Note: The original code was recursive, which was much more elegant but 872*7c478bd9Sstevel@tonic-gate * ran out of stack... 873*7c478bd9Sstevel@tonic-gate */ 874*7c478bd9Sstevel@tonic-gate 875*7c478bd9Sstevel@tonic-gate static char * 876*7c478bd9Sstevel@tonic-gate fh_print_absolute(char *fhpath, fhandle_t *fh, char *name) 877*7c478bd9Sstevel@tonic-gate { 878*7c478bd9Sstevel@tonic-gate char *str, *rootname, parent[MAXPATHLEN]; 879*7c478bd9Sstevel@tonic-gate int i, j, k, len, error; 880*7c478bd9Sstevel@tonic-gate fhlist_ent fhrec, *fhrecp; 881*7c478bd9Sstevel@tonic-gate fhandle_t prevfh; 882*7c478bd9Sstevel@tonic-gate int namelen; 883*7c478bd9Sstevel@tonic-gate 884*7c478bd9Sstevel@tonic-gate if (debug > 3) 885*7c478bd9Sstevel@tonic-gate (void) printf("fh_print_absolute: input name '%s'\n", 886*7c478bd9Sstevel@tonic-gate ((name != NULL) ? name : "")); 887*7c478bd9Sstevel@tonic-gate /* If name starts with '/' we are done */ 888*7c478bd9Sstevel@tonic-gate if ((name != NULL) && (name[0] == '/')) { 889*7c478bd9Sstevel@tonic-gate if ((str = strdup(name)) == NULL) { 890*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext( 891*7c478bd9Sstevel@tonic-gate "fh_print_absolute: strdup '%s' error %s\n"), 892*7c478bd9Sstevel@tonic-gate name, strerror(errno)); 893*7c478bd9Sstevel@tonic-gate } 894*7c478bd9Sstevel@tonic-gate return (str); 895*7c478bd9Sstevel@tonic-gate } 896*7c478bd9Sstevel@tonic-gate namelen = ((name != NULL) ? strlen(name) + 2 : 0); 897*7c478bd9Sstevel@tonic-gate parent[0] = '\0'; 898*7c478bd9Sstevel@tonic-gate 899*7c478bd9Sstevel@tonic-gate /* remember the last filehandle we've seen */ 900*7c478bd9Sstevel@tonic-gate (void) memcpy((void *) &prevfh, (void *) fh, sizeof (*fh)); 901*7c478bd9Sstevel@tonic-gate fh = &prevfh; 902*7c478bd9Sstevel@tonic-gate 903*7c478bd9Sstevel@tonic-gate /* dump all names in reverse order */ 904*7c478bd9Sstevel@tonic-gate while ((fhrecp = fh_lookup(fhpath, fh, &fhrec, &error)) != NULL && 905*7c478bd9Sstevel@tonic-gate !(fhrecp->flags & (EXPORT_POINT | PUBLIC_PATH))) { 906*7c478bd9Sstevel@tonic-gate 907*7c478bd9Sstevel@tonic-gate if (debug > 3) { 908*7c478bd9Sstevel@tonic-gate (void) printf("fh_print_absolute: name '%s'%s\n", 909*7c478bd9Sstevel@tonic-gate fhrecp->name, 910*7c478bd9Sstevel@tonic-gate ((fhrecp->flags & EXPORT_POINT) ? "root" : "")); 911*7c478bd9Sstevel@tonic-gate } 912*7c478bd9Sstevel@tonic-gate if (memcmp(&prevfh, &fhrecp->dfh, sizeof (*fh)) == 0) { 913*7c478bd9Sstevel@tonic-gate /* dfh == prevfh but not an export point */ 914*7c478bd9Sstevel@tonic-gate if (debug > 1) { 915*7c478bd9Sstevel@tonic-gate (void) printf( 916*7c478bd9Sstevel@tonic-gate "fh_print_absolute: fhrec loop:\n"); 917*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, fhrecp, 918*7c478bd9Sstevel@tonic-gate fhrecp->reclen); 919*7c478bd9Sstevel@tonic-gate } 920*7c478bd9Sstevel@tonic-gate break; 921*7c478bd9Sstevel@tonic-gate } 922*7c478bd9Sstevel@tonic-gate (void) strcat(parent, "/"); 923*7c478bd9Sstevel@tonic-gate (void) strcat(parent, fhrecp->name); 924*7c478bd9Sstevel@tonic-gate 925*7c478bd9Sstevel@tonic-gate /* remember the last filehandle we've seen */ 926*7c478bd9Sstevel@tonic-gate (void) memcpy(&prevfh, &fhrecp->dfh, sizeof (fhrecp->dfh)); 927*7c478bd9Sstevel@tonic-gate } 928*7c478bd9Sstevel@tonic-gate assert(fh == &prevfh); 929*7c478bd9Sstevel@tonic-gate 930*7c478bd9Sstevel@tonic-gate if (fhrecp != NULL) { 931*7c478bd9Sstevel@tonic-gate rootname = fhrecp->name; 932*7c478bd9Sstevel@tonic-gate } else { 933*7c478bd9Sstevel@tonic-gate /* Check if export point, just in case... */ 934*7c478bd9Sstevel@tonic-gate /* There should be enough room in parent, leave the '\0' */ 935*7c478bd9Sstevel@tonic-gate rootname = update_export_point( 936*7c478bd9Sstevel@tonic-gate fhpath, fh, &parent[strlen(parent) + 1]); 937*7c478bd9Sstevel@tonic-gate } 938*7c478bd9Sstevel@tonic-gate /* Now need to reverse the order */ 939*7c478bd9Sstevel@tonic-gate if (rootname != NULL) { /* *fhrecp is the export point */ 940*7c478bd9Sstevel@tonic-gate len = strlen(rootname) + 2; 941*7c478bd9Sstevel@tonic-gate } else { 942*7c478bd9Sstevel@tonic-gate len = 2 * (NFS_FHMAXDATA + fh->fh_len); /* fid instead */ 943*7c478bd9Sstevel@tonic-gate } 944*7c478bd9Sstevel@tonic-gate len = ROUNDUP32(len + namelen + strlen(parent)); 945*7c478bd9Sstevel@tonic-gate if ((str = malloc(len)) == NULL) { 946*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext( 947*7c478bd9Sstevel@tonic-gate "fh_print_absolute: malloc %d error %s\n"), 948*7c478bd9Sstevel@tonic-gate len, strerror(errno)); 949*7c478bd9Sstevel@tonic-gate return (NULL); 950*7c478bd9Sstevel@tonic-gate } 951*7c478bd9Sstevel@tonic-gate /* first put the export point path in */ 952*7c478bd9Sstevel@tonic-gate if (rootname != NULL) { /* *fhrecp is the export point */ 953*7c478bd9Sstevel@tonic-gate (void) strcpy(str, rootname); 954*7c478bd9Sstevel@tonic-gate } else { 955*7c478bd9Sstevel@tonic-gate sprint_fid(str, len, fh); 956*7c478bd9Sstevel@tonic-gate } 957*7c478bd9Sstevel@tonic-gate for (k = strlen(str), i = strlen(parent); (k < len) && (i >= 0); i--) { 958*7c478bd9Sstevel@tonic-gate for (j = i; (j >= 0) && (parent[j] != '/'); j--); 959*7c478bd9Sstevel@tonic-gate if (j < 0) 960*7c478bd9Sstevel@tonic-gate break; 961*7c478bd9Sstevel@tonic-gate (void) strcpy(&str[k], &parent[j]); 962*7c478bd9Sstevel@tonic-gate k += strlen(&str[k]); 963*7c478bd9Sstevel@tonic-gate parent[j] = '\0'; 964*7c478bd9Sstevel@tonic-gate } 965*7c478bd9Sstevel@tonic-gate if ((name != NULL) && ((k + namelen) <= len)) { 966*7c478bd9Sstevel@tonic-gate str[k] = '/'; 967*7c478bd9Sstevel@tonic-gate (void) strcpy(&str[k + 1], name); 968*7c478bd9Sstevel@tonic-gate } 969*7c478bd9Sstevel@tonic-gate if (debug > 3) 970*7c478bd9Sstevel@tonic-gate (void) printf("fh_print_absolute: path '%s'\n", str); 971*7c478bd9Sstevel@tonic-gate return (str); 972*7c478bd9Sstevel@tonic-gate } 973*7c478bd9Sstevel@tonic-gate 974*7c478bd9Sstevel@tonic-gate /* 975*7c478bd9Sstevel@tonic-gate * nfslog_find_fh_dispatch - get the dispatch struct for this request 976*7c478bd9Sstevel@tonic-gate */ 977*7c478bd9Sstevel@tonic-gate static struct nfsl_fh_proc_disp * 978*7c478bd9Sstevel@tonic-gate nfslog_find_fh_dispatch(nfslog_request_record *logrec) 979*7c478bd9Sstevel@tonic-gate { 980*7c478bd9Sstevel@tonic-gate nfslog_record_header *logrechdr = &logrec->re_header; 981*7c478bd9Sstevel@tonic-gate struct nfsl_fh_prog_disp *progtable; /* prog struct */ 982*7c478bd9Sstevel@tonic-gate struct nfsl_fh_vers_disp *verstable; /* version struct */ 983*7c478bd9Sstevel@tonic-gate int i, vers; 984*7c478bd9Sstevel@tonic-gate 985*7c478bd9Sstevel@tonic-gate /* Find prog element - search because can't use prog as array index */ 986*7c478bd9Sstevel@tonic-gate for (i = 0; (i < nfsl_fh_dispatch_table_arglen) && 987*7c478bd9Sstevel@tonic-gate (logrechdr->rh_prognum != nfsl_fh_dispatch_table[i].nfsl_dis_prog); 988*7c478bd9Sstevel@tonic-gate i++); 989*7c478bd9Sstevel@tonic-gate if (i >= nfsl_fh_dispatch_table_arglen) { /* program not logged */ 990*7c478bd9Sstevel@tonic-gate /* not an error */ 991*7c478bd9Sstevel@tonic-gate return (NULL); 992*7c478bd9Sstevel@tonic-gate } 993*7c478bd9Sstevel@tonic-gate progtable = &nfsl_fh_dispatch_table[i]; 994*7c478bd9Sstevel@tonic-gate /* Find vers element - no validity check - if here it's valid vers */ 995*7c478bd9Sstevel@tonic-gate vers = logrechdr->rh_version - progtable->nfsl_dis_versmin; 996*7c478bd9Sstevel@tonic-gate verstable = &progtable->nfsl_dis_vers_table[vers]; 997*7c478bd9Sstevel@tonic-gate /* Find proc element - no validity check - if here it's valid proc */ 998*7c478bd9Sstevel@tonic-gate return (&verstable->nfsl_dis_proc_table[logrechdr->rh_procnum]); 999*7c478bd9Sstevel@tonic-gate } 1000*7c478bd9Sstevel@tonic-gate 1001*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1002*7c478bd9Sstevel@tonic-gate static void 1003*7c478bd9Sstevel@tonic-gate nfslog_null_fhargs(caddr_t *nfsl_args, caddr_t *nfsl_res, 1004*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1005*7c478bd9Sstevel@tonic-gate { 1006*7c478bd9Sstevel@tonic-gate *pathp1 = NULL; 1007*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1008*7c478bd9Sstevel@tonic-gate } 1009*7c478bd9Sstevel@tonic-gate 1010*7c478bd9Sstevel@tonic-gate /* 1011*7c478bd9Sstevel@tonic-gate * nfslog_LOOKUP_calc - called by both lookup3 and lookup2. Handles the 1012*7c478bd9Sstevel@tonic-gate * mclookup as well as normal lookups. 1013*7c478bd9Sstevel@tonic-gate */ 1014*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1015*7c478bd9Sstevel@tonic-gate static void 1016*7c478bd9Sstevel@tonic-gate nfslog_LOOKUP_calc(fhandle_t *dfh, char *name, fhandle_t *fh, 1017*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2, char *str) 1018*7c478bd9Sstevel@tonic-gate { 1019*7c478bd9Sstevel@tonic-gate int error; 1020*7c478bd9Sstevel@tonic-gate fhlist_ent fhrec; 1021*7c478bd9Sstevel@tonic-gate char *name1 = NULL; 1022*7c478bd9Sstevel@tonic-gate 1023*7c478bd9Sstevel@tonic-gate if (fh == &public_fh) { 1024*7c478bd9Sstevel@tonic-gate /* a fake lookup to inform us of the public fs path */ 1025*7c478bd9Sstevel@tonic-gate if (error = FH_ADD(fhpath, fh, fh, name)) { 1026*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext( 1027*7c478bd9Sstevel@tonic-gate "%s: Add Public fs '%s' failed: %s\n"), 1028*7c478bd9Sstevel@tonic-gate str, name, 1029*7c478bd9Sstevel@tonic-gate ((error >= 0) ? strerror(error) : "Unknown")); 1030*7c478bd9Sstevel@tonic-gate } 1031*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1032*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(dfh, NULL, fhpath, str); 1033*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1034*7c478bd9Sstevel@tonic-gate } 1035*7c478bd9Sstevel@tonic-gate return; 1036*7c478bd9Sstevel@tonic-gate } 1037*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1038*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(dfh, name, fhpath, str); 1039*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1040*7c478bd9Sstevel@tonic-gate } 1041*7c478bd9Sstevel@tonic-gate 1042*7c478bd9Sstevel@tonic-gate /* If public fh mclookup, then insert complete path */ 1043*7c478bd9Sstevel@tonic-gate if (dfh == &public_fh) { 1044*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1045*7c478bd9Sstevel@tonic-gate name = *pathp1; 1046*7c478bd9Sstevel@tonic-gate } else { 1047*7c478bd9Sstevel@tonic-gate name = nfslog_get_path(dfh, name, fhpath, str); 1048*7c478bd9Sstevel@tonic-gate name1 = name; 1049*7c478bd9Sstevel@tonic-gate } 1050*7c478bd9Sstevel@tonic-gate } 1051*7c478bd9Sstevel@tonic-gate if (fh_lookup_link(fhpath, dfh, fh, name, &fhrec, &error) != NULL) { 1052*7c478bd9Sstevel@tonic-gate /* link already in table */ 1053*7c478bd9Sstevel@tonic-gate if (name1 != NULL) 1054*7c478bd9Sstevel@tonic-gate free(name1); 1055*7c478bd9Sstevel@tonic-gate return; 1056*7c478bd9Sstevel@tonic-gate } 1057*7c478bd9Sstevel@tonic-gate /* A new link so add it */ 1058*7c478bd9Sstevel@tonic-gate if (error = FH_ADD(fhpath, dfh, fh, name)) { 1059*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext( 1060*7c478bd9Sstevel@tonic-gate "%s: Add fh for '%s' failed: %s\n"), str, 1061*7c478bd9Sstevel@tonic-gate name, ((error >= 0) ? strerror(error) : "Unknown")); 1062*7c478bd9Sstevel@tonic-gate } 1063*7c478bd9Sstevel@tonic-gate if (name1 != NULL) 1064*7c478bd9Sstevel@tonic-gate free(name1); 1065*7c478bd9Sstevel@tonic-gate } 1066*7c478bd9Sstevel@tonic-gate 1067*7c478bd9Sstevel@tonic-gate /* 1068*7c478bd9Sstevel@tonic-gate * NFS VERSION 2 1069*7c478bd9Sstevel@tonic-gate */ 1070*7c478bd9Sstevel@tonic-gate 1071*7c478bd9Sstevel@tonic-gate /* Functions for updating the fhtable for fhtoppath */ 1072*7c478bd9Sstevel@tonic-gate 1073*7c478bd9Sstevel@tonic-gate /* 1074*7c478bd9Sstevel@tonic-gate * nfslog_GETATTR2_fhargs - updates path1 but no fhtable changes 1075*7c478bd9Sstevel@tonic-gate */ 1076*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1077*7c478bd9Sstevel@tonic-gate static void 1078*7c478bd9Sstevel@tonic-gate nfslog_GETATTR2_fhargs(fhandle_t *args, nfsstat *res, 1079*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1080*7c478bd9Sstevel@tonic-gate { 1081*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1082*7c478bd9Sstevel@tonic-gate (void) printf("=============\nGETATTR2: fh "); 1083*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, args, sizeof (*args)); 1084*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 1085*7c478bd9Sstevel@tonic-gate } 1086*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1087*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(NFSLOG_GET_FHANDLE2(args), 1088*7c478bd9Sstevel@tonic-gate NULL, fhpath, "getattr2"); 1089*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1090*7c478bd9Sstevel@tonic-gate } 1091*7c478bd9Sstevel@tonic-gate } 1092*7c478bd9Sstevel@tonic-gate 1093*7c478bd9Sstevel@tonic-gate /* 1094*7c478bd9Sstevel@tonic-gate * nfslog_SETATTR2_fhargs - updates path1 but no fhtable changes 1095*7c478bd9Sstevel@tonic-gate */ 1096*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1097*7c478bd9Sstevel@tonic-gate static void 1098*7c478bd9Sstevel@tonic-gate nfslog_SETATTR2_fhargs(nfslog_setattrargs *args, nfsstat *res, 1099*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1100*7c478bd9Sstevel@tonic-gate { 1101*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1102*7c478bd9Sstevel@tonic-gate (void) printf("=============\nSETATTR2: fh "); 1103*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, &args->saa_fh, 1104*7c478bd9Sstevel@tonic-gate sizeof (args->saa_fh)); 1105*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 1106*7c478bd9Sstevel@tonic-gate } 1107*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1108*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(NFSLOG_GET_FHANDLE2(&args->saa_fh), 1109*7c478bd9Sstevel@tonic-gate NULL, fhpath, "setattr2"); 1110*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1111*7c478bd9Sstevel@tonic-gate } 1112*7c478bd9Sstevel@tonic-gate } 1113*7c478bd9Sstevel@tonic-gate 1114*7c478bd9Sstevel@tonic-gate /* 1115*7c478bd9Sstevel@tonic-gate * nfslog_LOOKUP2_fhargs - search the table to ensure we have not added this 1116*7c478bd9Sstevel@tonic-gate * one already. Note that if the response status was anything but okay, 1117*7c478bd9Sstevel@tonic-gate * there is no fh to check... 1118*7c478bd9Sstevel@tonic-gate */ 1119*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1120*7c478bd9Sstevel@tonic-gate static void 1121*7c478bd9Sstevel@tonic-gate nfslog_LOOKUP2_fhargs(nfslog_diropargs *args, nfslog_diropres *res, 1122*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1123*7c478bd9Sstevel@tonic-gate { 1124*7c478bd9Sstevel@tonic-gate char *name; 1125*7c478bd9Sstevel@tonic-gate fhandle_t *dfh, *fh; 1126*7c478bd9Sstevel@tonic-gate 1127*7c478bd9Sstevel@tonic-gate dfh = &args->da_fhandle; 1128*7c478bd9Sstevel@tonic-gate name = args->da_name; 1129*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1130*7c478bd9Sstevel@tonic-gate if (res->dr_status == NFS_OK) 1131*7c478bd9Sstevel@tonic-gate fh = &res->nfslog_diropres_u.dr_ok.drok_fhandle; 1132*7c478bd9Sstevel@tonic-gate else 1133*7c478bd9Sstevel@tonic-gate fh = NULL; 1134*7c478bd9Sstevel@tonic-gate PRINT_FULL_DATA(stdout, "=============\nLOOKUP2", 1135*7c478bd9Sstevel@tonic-gate dfh, fh, name, "") 1136*7c478bd9Sstevel@tonic-gate if (res->dr_status != NFS_OK) 1137*7c478bd9Sstevel@tonic-gate (void) printf("status %d\n", res->dr_status); 1138*7c478bd9Sstevel@tonic-gate } 1139*7c478bd9Sstevel@tonic-gate dfh = NFSLOG_GET_FHANDLE2(dfh); 1140*7c478bd9Sstevel@tonic-gate if ((dfh == &public_fh) && (name[0] == '\x80')) { 1141*7c478bd9Sstevel@tonic-gate /* special mclookup */ 1142*7c478bd9Sstevel@tonic-gate name = &name[1]; 1143*7c478bd9Sstevel@tonic-gate } 1144*7c478bd9Sstevel@tonic-gate if (res->dr_status != NFS_OK) { 1145*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1146*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(dfh, name, fhpath, "lookup2"); 1147*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1148*7c478bd9Sstevel@tonic-gate } 1149*7c478bd9Sstevel@tonic-gate return; 1150*7c478bd9Sstevel@tonic-gate } 1151*7c478bd9Sstevel@tonic-gate fh = NFSLOG_GET_FHANDLE2(&res->nfslog_diropres_u.dr_ok.drok_fhandle); 1152*7c478bd9Sstevel@tonic-gate nfslog_LOOKUP_calc(dfh, name, fh, fhpath, pathp1, pathp2, "Lookup2"); 1153*7c478bd9Sstevel@tonic-gate } 1154*7c478bd9Sstevel@tonic-gate 1155*7c478bd9Sstevel@tonic-gate /* 1156*7c478bd9Sstevel@tonic-gate * nfslog_READLINK2_fhargs - updates path1 but no fhtable changes 1157*7c478bd9Sstevel@tonic-gate */ 1158*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1159*7c478bd9Sstevel@tonic-gate static void 1160*7c478bd9Sstevel@tonic-gate nfslog_READLINK2_fhargs(fhandle_t *args, nfslog_rdlnres *res, 1161*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1162*7c478bd9Sstevel@tonic-gate { 1163*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1164*7c478bd9Sstevel@tonic-gate (void) printf("=============\nREADLINK2: fh "); 1165*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, args, sizeof (*args)); 1166*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 1167*7c478bd9Sstevel@tonic-gate } 1168*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1169*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(NFSLOG_GET_FHANDLE2(args), 1170*7c478bd9Sstevel@tonic-gate NULL, fhpath, "readlink2"); 1171*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1172*7c478bd9Sstevel@tonic-gate } 1173*7c478bd9Sstevel@tonic-gate } 1174*7c478bd9Sstevel@tonic-gate 1175*7c478bd9Sstevel@tonic-gate /* 1176*7c478bd9Sstevel@tonic-gate * nfslog_READ2_fhargs - updates path1 but no fhtable changes 1177*7c478bd9Sstevel@tonic-gate */ 1178*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1179*7c478bd9Sstevel@tonic-gate static void 1180*7c478bd9Sstevel@tonic-gate nfslog_READ2_fhargs(nfslog_nfsreadargs *args, nfslog_rdresult *res, 1181*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1182*7c478bd9Sstevel@tonic-gate { 1183*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1184*7c478bd9Sstevel@tonic-gate (void) printf("=============\nREAD2: fh "); 1185*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, &args->ra_fhandle, 1186*7c478bd9Sstevel@tonic-gate sizeof (args->ra_fhandle)); 1187*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 1188*7c478bd9Sstevel@tonic-gate } 1189*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1190*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path( 1191*7c478bd9Sstevel@tonic-gate NFSLOG_GET_FHANDLE2(&args->ra_fhandle), 1192*7c478bd9Sstevel@tonic-gate NULL, fhpath, "read2"); 1193*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1194*7c478bd9Sstevel@tonic-gate } 1195*7c478bd9Sstevel@tonic-gate } 1196*7c478bd9Sstevel@tonic-gate 1197*7c478bd9Sstevel@tonic-gate /* 1198*7c478bd9Sstevel@tonic-gate * nfslog_WRITE2_fhargs - updates path1 but no fhtable changes 1199*7c478bd9Sstevel@tonic-gate */ 1200*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1201*7c478bd9Sstevel@tonic-gate static void 1202*7c478bd9Sstevel@tonic-gate nfslog_WRITE2_fhargs(nfslog_writeargs *args, nfslog_writeresult *res, 1203*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1204*7c478bd9Sstevel@tonic-gate { 1205*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1206*7c478bd9Sstevel@tonic-gate (void) printf("=============\nWRITE2: fh "); 1207*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, &args->waargs_fhandle, 1208*7c478bd9Sstevel@tonic-gate sizeof (args->waargs_fhandle)); 1209*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 1210*7c478bd9Sstevel@tonic-gate } 1211*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1212*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path( 1213*7c478bd9Sstevel@tonic-gate NFSLOG_GET_FHANDLE2(&args->waargs_fhandle), 1214*7c478bd9Sstevel@tonic-gate NULL, fhpath, "write2"); 1215*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1216*7c478bd9Sstevel@tonic-gate } 1217*7c478bd9Sstevel@tonic-gate } 1218*7c478bd9Sstevel@tonic-gate 1219*7c478bd9Sstevel@tonic-gate /* 1220*7c478bd9Sstevel@tonic-gate * nfslog_CREATE2_fhargs - if the operation succeeded, we are sure there can 1221*7c478bd9Sstevel@tonic-gate * be no such link in the fhtable, so just add it. 1222*7c478bd9Sstevel@tonic-gate */ 1223*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1224*7c478bd9Sstevel@tonic-gate static void 1225*7c478bd9Sstevel@tonic-gate nfslog_CREATE2_fhargs(nfslog_createargs *args, nfslog_diropres *res, 1226*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1227*7c478bd9Sstevel@tonic-gate { 1228*7c478bd9Sstevel@tonic-gate char *name; 1229*7c478bd9Sstevel@tonic-gate fhandle_t *dfh, *fh; 1230*7c478bd9Sstevel@tonic-gate int error; 1231*7c478bd9Sstevel@tonic-gate 1232*7c478bd9Sstevel@tonic-gate name = args->ca_da.da_name; 1233*7c478bd9Sstevel@tonic-gate dfh = &args->ca_da.da_fhandle; 1234*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1235*7c478bd9Sstevel@tonic-gate if (res->dr_status == NFS_OK) 1236*7c478bd9Sstevel@tonic-gate fh = &res->nfslog_diropres_u.dr_ok.drok_fhandle; 1237*7c478bd9Sstevel@tonic-gate else 1238*7c478bd9Sstevel@tonic-gate fh = NULL; 1239*7c478bd9Sstevel@tonic-gate PRINT_FULL_DATA(stdout, "=============\nCREATE2", 1240*7c478bd9Sstevel@tonic-gate dfh, fh, name, "") 1241*7c478bd9Sstevel@tonic-gate if (res->dr_status != NFS_OK) 1242*7c478bd9Sstevel@tonic-gate (void) printf("status %d\n", res->dr_status); 1243*7c478bd9Sstevel@tonic-gate } 1244*7c478bd9Sstevel@tonic-gate dfh = NFSLOG_GET_FHANDLE2(dfh); 1245*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1246*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(dfh, name, fhpath, "create2"); 1247*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1248*7c478bd9Sstevel@tonic-gate } 1249*7c478bd9Sstevel@tonic-gate 1250*7c478bd9Sstevel@tonic-gate if (res->dr_status != NFS_OK) 1251*7c478bd9Sstevel@tonic-gate /* no returned fh so nothing to add */ 1252*7c478bd9Sstevel@tonic-gate return; 1253*7c478bd9Sstevel@tonic-gate 1254*7c478bd9Sstevel@tonic-gate /* A new file handle so add it */ 1255*7c478bd9Sstevel@tonic-gate fh = NFSLOG_GET_FHANDLE2(&res->nfslog_diropres_u.dr_ok.drok_fhandle); 1256*7c478bd9Sstevel@tonic-gate if (error = FH_ADD(fhpath, dfh, fh, name)) { 1257*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext( 1258*7c478bd9Sstevel@tonic-gate "Create2: Add fh for '%s' failed: %s\n"), 1259*7c478bd9Sstevel@tonic-gate name, ((error >= 0) ? strerror(error) : "Unknown")); 1260*7c478bd9Sstevel@tonic-gate } 1261*7c478bd9Sstevel@tonic-gate } 1262*7c478bd9Sstevel@tonic-gate 1263*7c478bd9Sstevel@tonic-gate /* 1264*7c478bd9Sstevel@tonic-gate * nfslog_REMOVE2_fhargs - if the operation succeeded, remove the link from 1265*7c478bd9Sstevel@tonic-gate * the fhtable. 1266*7c478bd9Sstevel@tonic-gate */ 1267*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1268*7c478bd9Sstevel@tonic-gate static void 1269*7c478bd9Sstevel@tonic-gate nfslog_REMOVE2_fhargs(nfslog_diropargs *args, nfsstat *res, 1270*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1271*7c478bd9Sstevel@tonic-gate { 1272*7c478bd9Sstevel@tonic-gate char *name; 1273*7c478bd9Sstevel@tonic-gate fhandle_t *dfh; 1274*7c478bd9Sstevel@tonic-gate int error; 1275*7c478bd9Sstevel@tonic-gate 1276*7c478bd9Sstevel@tonic-gate name = args->da_name; 1277*7c478bd9Sstevel@tonic-gate dfh = &args->da_fhandle; 1278*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1279*7c478bd9Sstevel@tonic-gate PRINT_LINK_DATA(stdout, "=============\nREMOVE2", dfh, name, "") 1280*7c478bd9Sstevel@tonic-gate if (*res != NFS_OK) 1281*7c478bd9Sstevel@tonic-gate (void) printf("status %d\n", *res); 1282*7c478bd9Sstevel@tonic-gate } 1283*7c478bd9Sstevel@tonic-gate dfh = NFSLOG_GET_FHANDLE2(dfh); 1284*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1285*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(dfh, name, fhpath, "remove2"); 1286*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1287*7c478bd9Sstevel@tonic-gate } 1288*7c478bd9Sstevel@tonic-gate 1289*7c478bd9Sstevel@tonic-gate if (*res != NFS_OK) 1290*7c478bd9Sstevel@tonic-gate /* remove failed so nothing to update */ 1291*7c478bd9Sstevel@tonic-gate return; 1292*7c478bd9Sstevel@tonic-gate 1293*7c478bd9Sstevel@tonic-gate if (error = fh_remove(fhpath, dfh, name, pathp1)) { 1294*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext("Remove2: '%s' failed: %s\n"), 1295*7c478bd9Sstevel@tonic-gate name, ((error >= 0) ? strerror(error) : "Unknown")); 1296*7c478bd9Sstevel@tonic-gate } 1297*7c478bd9Sstevel@tonic-gate } 1298*7c478bd9Sstevel@tonic-gate 1299*7c478bd9Sstevel@tonic-gate /* 1300*7c478bd9Sstevel@tonic-gate * nfsl_RENAME2_fhargs - updates the dfh and name fields for the given fh 1301*7c478bd9Sstevel@tonic-gate * to change them to the new name. 1302*7c478bd9Sstevel@tonic-gate */ 1303*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1304*7c478bd9Sstevel@tonic-gate static void 1305*7c478bd9Sstevel@tonic-gate nfslog_RENAME2_fhargs(nfslog_rnmargs *args, nfsstat *res, 1306*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1307*7c478bd9Sstevel@tonic-gate { 1308*7c478bd9Sstevel@tonic-gate char *from_name, *to_name; 1309*7c478bd9Sstevel@tonic-gate fhandle_t *from_dfh, *to_dfh; 1310*7c478bd9Sstevel@tonic-gate int error; 1311*7c478bd9Sstevel@tonic-gate 1312*7c478bd9Sstevel@tonic-gate from_name = args->rna_from.da_name; 1313*7c478bd9Sstevel@tonic-gate from_dfh = &args->rna_from.da_fhandle; 1314*7c478bd9Sstevel@tonic-gate to_name = args->rna_to.da_name; 1315*7c478bd9Sstevel@tonic-gate to_dfh = &args->rna_to.da_fhandle; 1316*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1317*7c478bd9Sstevel@tonic-gate PRINT_LINK_DATA(stdout, "=============\nRENAME2: from", 1318*7c478bd9Sstevel@tonic-gate from_dfh, from_name, "") 1319*7c478bd9Sstevel@tonic-gate PRINT_LINK_DATA(stdout, "RENAME2: to ", to_dfh, 1320*7c478bd9Sstevel@tonic-gate to_name, "") 1321*7c478bd9Sstevel@tonic-gate if (*res != NFS_OK) 1322*7c478bd9Sstevel@tonic-gate (void) printf("status %d\n", *res); 1323*7c478bd9Sstevel@tonic-gate } 1324*7c478bd9Sstevel@tonic-gate from_dfh = NFSLOG_GET_FHANDLE2(from_dfh); 1325*7c478bd9Sstevel@tonic-gate to_dfh = NFSLOG_GET_FHANDLE2(to_dfh); 1326*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1327*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(from_dfh, from_name, fhpath, 1328*7c478bd9Sstevel@tonic-gate "rename2 from"); 1329*7c478bd9Sstevel@tonic-gate *pathp2 = nfslog_get_path(to_dfh, to_name, fhpath, 1330*7c478bd9Sstevel@tonic-gate "rename2 to"); 1331*7c478bd9Sstevel@tonic-gate } 1332*7c478bd9Sstevel@tonic-gate 1333*7c478bd9Sstevel@tonic-gate if (*res != NFS_OK) 1334*7c478bd9Sstevel@tonic-gate /* rename failed so nothing to update */ 1335*7c478bd9Sstevel@tonic-gate return; 1336*7c478bd9Sstevel@tonic-gate 1337*7c478bd9Sstevel@tonic-gate /* Rename the link in the database */ 1338*7c478bd9Sstevel@tonic-gate if (error = fh_rename(fhpath, from_dfh, from_name, pathp1, 1339*7c478bd9Sstevel@tonic-gate to_dfh, to_name)) { 1340*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext( 1341*7c478bd9Sstevel@tonic-gate "Rename2: Update from '%s' to '%s' failed: %s\n"), 1342*7c478bd9Sstevel@tonic-gate from_name, to_name, 1343*7c478bd9Sstevel@tonic-gate ((error >= 0) ? strerror(error) : "Unknown")); 1344*7c478bd9Sstevel@tonic-gate } 1345*7c478bd9Sstevel@tonic-gate } 1346*7c478bd9Sstevel@tonic-gate 1347*7c478bd9Sstevel@tonic-gate /* 1348*7c478bd9Sstevel@tonic-gate * nfslog_LINK2_fhargs - adds link name and fh to fhlist. Note that as a 1349*7c478bd9Sstevel@tonic-gate * result we may have more than one name for an fh. 1350*7c478bd9Sstevel@tonic-gate */ 1351*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1352*7c478bd9Sstevel@tonic-gate static void 1353*7c478bd9Sstevel@tonic-gate nfslog_LINK2_fhargs(nfslog_linkargs *args, nfsstat *res, 1354*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1355*7c478bd9Sstevel@tonic-gate { 1356*7c478bd9Sstevel@tonic-gate char *name; 1357*7c478bd9Sstevel@tonic-gate fhandle_t *dfh, *fh; 1358*7c478bd9Sstevel@tonic-gate int error; 1359*7c478bd9Sstevel@tonic-gate 1360*7c478bd9Sstevel@tonic-gate fh = &args->la_from; 1361*7c478bd9Sstevel@tonic-gate name = args->la_to.da_name; 1362*7c478bd9Sstevel@tonic-gate dfh = &args->la_to.da_fhandle; 1363*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1364*7c478bd9Sstevel@tonic-gate PRINT_FULL_DATA(stdout, "=============\nLINK2", 1365*7c478bd9Sstevel@tonic-gate dfh, fh, name, "") 1366*7c478bd9Sstevel@tonic-gate if (*res != NFS_OK) 1367*7c478bd9Sstevel@tonic-gate (void) printf("status %d\n", *res); 1368*7c478bd9Sstevel@tonic-gate } 1369*7c478bd9Sstevel@tonic-gate dfh = NFSLOG_GET_FHANDLE2(dfh); 1370*7c478bd9Sstevel@tonic-gate fh = NFSLOG_GET_FHANDLE2(fh); 1371*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1372*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(fh, NULL, fhpath, "link2 from"); 1373*7c478bd9Sstevel@tonic-gate *pathp2 = nfslog_get_path(dfh, name, fhpath, "link2 to"); 1374*7c478bd9Sstevel@tonic-gate } 1375*7c478bd9Sstevel@tonic-gate 1376*7c478bd9Sstevel@tonic-gate if (*res != NFS_OK) 1377*7c478bd9Sstevel@tonic-gate /* no returned fh so nothing to add */ 1378*7c478bd9Sstevel@tonic-gate return; 1379*7c478bd9Sstevel@tonic-gate 1380*7c478bd9Sstevel@tonic-gate /* A new link so add it, have fh_add find the link count */ 1381*7c478bd9Sstevel@tonic-gate if (error = FH_ADD(fhpath, dfh, fh, name)) { 1382*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext( 1383*7c478bd9Sstevel@tonic-gate "Link2: Add fh for '%s' failed: %s\n"), 1384*7c478bd9Sstevel@tonic-gate name, ((error >= 0) ? strerror(error) : "Unknown")); 1385*7c478bd9Sstevel@tonic-gate } 1386*7c478bd9Sstevel@tonic-gate } 1387*7c478bd9Sstevel@tonic-gate 1388*7c478bd9Sstevel@tonic-gate /* 1389*7c478bd9Sstevel@tonic-gate * nfslog_SYMLINK2_fhargs - adds symlink name and fh to fhlist if fh returned. 1390*7c478bd9Sstevel@tonic-gate */ 1391*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1392*7c478bd9Sstevel@tonic-gate static void 1393*7c478bd9Sstevel@tonic-gate nfslog_SYMLINK2_fhargs(nfslog_symlinkargs *args, nfsstat *res, 1394*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1395*7c478bd9Sstevel@tonic-gate { 1396*7c478bd9Sstevel@tonic-gate char *name; 1397*7c478bd9Sstevel@tonic-gate fhandle_t *dfh; 1398*7c478bd9Sstevel@tonic-gate 1399*7c478bd9Sstevel@tonic-gate name = args->sla_from.da_name; 1400*7c478bd9Sstevel@tonic-gate dfh = &args->sla_from.da_fhandle; 1401*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1402*7c478bd9Sstevel@tonic-gate PRINT_LINK_DATA(stdout, "=============\nSYMLINK2", 1403*7c478bd9Sstevel@tonic-gate dfh, name, "") 1404*7c478bd9Sstevel@tonic-gate } 1405*7c478bd9Sstevel@tonic-gate dfh = NFSLOG_GET_FHANDLE2(dfh); 1406*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1407*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(dfh, name, fhpath, "symlink2"); 1408*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1409*7c478bd9Sstevel@tonic-gate } 1410*7c478bd9Sstevel@tonic-gate } 1411*7c478bd9Sstevel@tonic-gate 1412*7c478bd9Sstevel@tonic-gate /* 1413*7c478bd9Sstevel@tonic-gate * nfslog_READDIR2_fhargs - updates path1 but no fhtable changes 1414*7c478bd9Sstevel@tonic-gate */ 1415*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1416*7c478bd9Sstevel@tonic-gate static void 1417*7c478bd9Sstevel@tonic-gate nfslog_READDIR2_fhargs(nfslog_rddirargs *args, nfslog_rddirres *res, 1418*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1419*7c478bd9Sstevel@tonic-gate { 1420*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1421*7c478bd9Sstevel@tonic-gate (void) printf("=============\nREADDIR2: fh "); 1422*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, &args->rda_fh, 1423*7c478bd9Sstevel@tonic-gate sizeof (args->rda_fh)); 1424*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 1425*7c478bd9Sstevel@tonic-gate } 1426*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1427*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(NFSLOG_GET_FHANDLE2(&args->rda_fh), 1428*7c478bd9Sstevel@tonic-gate NULL, fhpath, "readdir2"); 1429*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1430*7c478bd9Sstevel@tonic-gate } 1431*7c478bd9Sstevel@tonic-gate } 1432*7c478bd9Sstevel@tonic-gate 1433*7c478bd9Sstevel@tonic-gate /* 1434*7c478bd9Sstevel@tonic-gate * nfslog_STATFS2_fhargs - updates path1 but no fhtable changes 1435*7c478bd9Sstevel@tonic-gate */ 1436*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1437*7c478bd9Sstevel@tonic-gate static void 1438*7c478bd9Sstevel@tonic-gate nfslog_STATFS2_fhargs(fhandle_t *args, nfsstat *res, 1439*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1440*7c478bd9Sstevel@tonic-gate { 1441*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1442*7c478bd9Sstevel@tonic-gate (void) printf("=============\nSTATFS2: fh "); 1443*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, args, sizeof (*args)); 1444*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 1445*7c478bd9Sstevel@tonic-gate } 1446*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1447*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(NFSLOG_GET_FHANDLE2(args), 1448*7c478bd9Sstevel@tonic-gate NULL, fhpath, "statfs2"); 1449*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1450*7c478bd9Sstevel@tonic-gate } 1451*7c478bd9Sstevel@tonic-gate } 1452*7c478bd9Sstevel@tonic-gate 1453*7c478bd9Sstevel@tonic-gate /* 1454*7c478bd9Sstevel@tonic-gate * NFS VERSION 3 1455*7c478bd9Sstevel@tonic-gate */ 1456*7c478bd9Sstevel@tonic-gate 1457*7c478bd9Sstevel@tonic-gate /* Functions for updating the fhtable for fhtoppath */ 1458*7c478bd9Sstevel@tonic-gate 1459*7c478bd9Sstevel@tonic-gate /* 1460*7c478bd9Sstevel@tonic-gate * nfslog_GETATTR3_fhargs - updates path1 but no fhtable changes 1461*7c478bd9Sstevel@tonic-gate */ 1462*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1463*7c478bd9Sstevel@tonic-gate static void 1464*7c478bd9Sstevel@tonic-gate nfslog_GETATTR3_fhargs(nfs_fh3 *args, nfsstat3 *res, 1465*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1466*7c478bd9Sstevel@tonic-gate { 1467*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1468*7c478bd9Sstevel@tonic-gate (void) printf("=============\nGETATTR3: fh "); 1469*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, args, sizeof (*args)); 1470*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 1471*7c478bd9Sstevel@tonic-gate } 1472*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1473*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(NFSLOG_GET_FHANDLE3(args), NULL, 1474*7c478bd9Sstevel@tonic-gate fhpath, "getattr3"); 1475*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1476*7c478bd9Sstevel@tonic-gate } 1477*7c478bd9Sstevel@tonic-gate } 1478*7c478bd9Sstevel@tonic-gate 1479*7c478bd9Sstevel@tonic-gate /* 1480*7c478bd9Sstevel@tonic-gate * nfslog_SETATTR3_fhargs - updates path1 but no fhtable changes 1481*7c478bd9Sstevel@tonic-gate */ 1482*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1483*7c478bd9Sstevel@tonic-gate static void 1484*7c478bd9Sstevel@tonic-gate nfslog_SETATTR3_fhargs(nfslog_SETATTR3args *args, nfsstat3 *res, 1485*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1486*7c478bd9Sstevel@tonic-gate { 1487*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1488*7c478bd9Sstevel@tonic-gate (void) printf("=============\nSETATTR3: fh "); 1489*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, &args->object, 1490*7c478bd9Sstevel@tonic-gate sizeof (args->object)); 1491*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 1492*7c478bd9Sstevel@tonic-gate } 1493*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1494*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(NFSLOG_GET_FHANDLE3(&args->object), 1495*7c478bd9Sstevel@tonic-gate NULL, fhpath, "setattr3"); 1496*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1497*7c478bd9Sstevel@tonic-gate } 1498*7c478bd9Sstevel@tonic-gate } 1499*7c478bd9Sstevel@tonic-gate 1500*7c478bd9Sstevel@tonic-gate /* 1501*7c478bd9Sstevel@tonic-gate * nfslog_LOOKUP3_fhargs - search the table to ensure we have not added this 1502*7c478bd9Sstevel@tonic-gate * one already. Note that if the response status was anything but okay, 1503*7c478bd9Sstevel@tonic-gate * there is no fh to check... 1504*7c478bd9Sstevel@tonic-gate */ 1505*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1506*7c478bd9Sstevel@tonic-gate static void 1507*7c478bd9Sstevel@tonic-gate nfslog_LOOKUP3_fhargs(nfslog_diropargs3 *args, nfslog_LOOKUP3res *res, 1508*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1509*7c478bd9Sstevel@tonic-gate { 1510*7c478bd9Sstevel@tonic-gate char *name; 1511*7c478bd9Sstevel@tonic-gate fhandle_t *dfh, *fh; 1512*7c478bd9Sstevel@tonic-gate 1513*7c478bd9Sstevel@tonic-gate name = args->name; 1514*7c478bd9Sstevel@tonic-gate dfh = NFSLOG_GET_FHANDLE3(&args->dir); 1515*7c478bd9Sstevel@tonic-gate 1516*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1517*7c478bd9Sstevel@tonic-gate if (res->status == NFS3_OK) 1518*7c478bd9Sstevel@tonic-gate fh = NFSLOG_GET_FHANDLE3( 1519*7c478bd9Sstevel@tonic-gate &res->nfslog_LOOKUP3res_u.object); 1520*7c478bd9Sstevel@tonic-gate else 1521*7c478bd9Sstevel@tonic-gate fh = NULL; 1522*7c478bd9Sstevel@tonic-gate PRINT_FULL_DATA(stdout, "=============\nLOOKUP3", 1523*7c478bd9Sstevel@tonic-gate dfh, fh, name, "") 1524*7c478bd9Sstevel@tonic-gate if (res->status != NFS3_OK) 1525*7c478bd9Sstevel@tonic-gate (void) printf("status %d\n", res->status); 1526*7c478bd9Sstevel@tonic-gate } 1527*7c478bd9Sstevel@tonic-gate if ((dfh == &public_fh) && (name[0] == '\x80')) { 1528*7c478bd9Sstevel@tonic-gate /* special mclookup */ 1529*7c478bd9Sstevel@tonic-gate name = &name[1]; 1530*7c478bd9Sstevel@tonic-gate } 1531*7c478bd9Sstevel@tonic-gate if (res->status != NFS3_OK) { 1532*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1533*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(dfh, name, fhpath, "lookup3"); 1534*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1535*7c478bd9Sstevel@tonic-gate } 1536*7c478bd9Sstevel@tonic-gate return; 1537*7c478bd9Sstevel@tonic-gate } 1538*7c478bd9Sstevel@tonic-gate fh = NFSLOG_GET_FHANDLE3(&res->nfslog_LOOKUP3res_u.object); 1539*7c478bd9Sstevel@tonic-gate nfslog_LOOKUP_calc(dfh, name, fh, fhpath, pathp1, pathp2, "Lookup3"); 1540*7c478bd9Sstevel@tonic-gate } 1541*7c478bd9Sstevel@tonic-gate 1542*7c478bd9Sstevel@tonic-gate /* 1543*7c478bd9Sstevel@tonic-gate * nfslog_ACCESS3_fhargs - updates path1 but no fhtable changes 1544*7c478bd9Sstevel@tonic-gate */ 1545*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1546*7c478bd9Sstevel@tonic-gate static void 1547*7c478bd9Sstevel@tonic-gate nfslog_ACCESS3_fhargs(nfs_fh3 *args, nfsstat3 *res, 1548*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1549*7c478bd9Sstevel@tonic-gate { 1550*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1551*7c478bd9Sstevel@tonic-gate (void) printf("=============\nACCESS3: fh "); 1552*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, args, 1553*7c478bd9Sstevel@tonic-gate sizeof (*args)); 1554*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 1555*7c478bd9Sstevel@tonic-gate } 1556*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1557*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(NFSLOG_GET_FHANDLE3(args), 1558*7c478bd9Sstevel@tonic-gate NULL, fhpath, "access3"); 1559*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1560*7c478bd9Sstevel@tonic-gate } 1561*7c478bd9Sstevel@tonic-gate } 1562*7c478bd9Sstevel@tonic-gate 1563*7c478bd9Sstevel@tonic-gate /* 1564*7c478bd9Sstevel@tonic-gate * nfslog_READLINK3_fhargs - updates path1 but no fhtable changes 1565*7c478bd9Sstevel@tonic-gate */ 1566*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1567*7c478bd9Sstevel@tonic-gate static void 1568*7c478bd9Sstevel@tonic-gate nfslog_READLINK3_fhargs(nfs_fh3 *args, nfslog_READLINK3res *res, 1569*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1570*7c478bd9Sstevel@tonic-gate { 1571*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1572*7c478bd9Sstevel@tonic-gate (void) printf("=============\nREADLINK3: fh "); 1573*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, args, sizeof (*args)); 1574*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 1575*7c478bd9Sstevel@tonic-gate } 1576*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1577*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(NFSLOG_GET_FHANDLE3(args), NULL, 1578*7c478bd9Sstevel@tonic-gate fhpath, "readlink3"); 1579*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1580*7c478bd9Sstevel@tonic-gate } 1581*7c478bd9Sstevel@tonic-gate } 1582*7c478bd9Sstevel@tonic-gate 1583*7c478bd9Sstevel@tonic-gate /* 1584*7c478bd9Sstevel@tonic-gate * nfslog_READ3_fhargs - updates path1 but no fhtable changes 1585*7c478bd9Sstevel@tonic-gate */ 1586*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1587*7c478bd9Sstevel@tonic-gate static void 1588*7c478bd9Sstevel@tonic-gate nfslog_READ3_fhargs(nfslog_READ3args *args, nfslog_READ3res *res, 1589*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1590*7c478bd9Sstevel@tonic-gate { 1591*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1592*7c478bd9Sstevel@tonic-gate (void) printf("=============\nREAD3: fh "); 1593*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, &args->file, 1594*7c478bd9Sstevel@tonic-gate sizeof (args->file)); 1595*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 1596*7c478bd9Sstevel@tonic-gate } 1597*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1598*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(NFSLOG_GET_FHANDLE3(&args->file), 1599*7c478bd9Sstevel@tonic-gate NULL, fhpath, "read3"); 1600*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1601*7c478bd9Sstevel@tonic-gate } 1602*7c478bd9Sstevel@tonic-gate } 1603*7c478bd9Sstevel@tonic-gate 1604*7c478bd9Sstevel@tonic-gate /* 1605*7c478bd9Sstevel@tonic-gate * nfslog_WRITE3_fhargs - updates path1 but no fhtable changes 1606*7c478bd9Sstevel@tonic-gate */ 1607*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1608*7c478bd9Sstevel@tonic-gate static void 1609*7c478bd9Sstevel@tonic-gate nfslog_WRITE3_fhargs(nfslog_WRITE3args *args, nfslog_WRITE3res *res, 1610*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1611*7c478bd9Sstevel@tonic-gate { 1612*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1613*7c478bd9Sstevel@tonic-gate (void) printf("=============\nWRITE3: fh "); 1614*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, &args->file, 1615*7c478bd9Sstevel@tonic-gate sizeof (args->file)); 1616*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 1617*7c478bd9Sstevel@tonic-gate } 1618*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1619*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(NFSLOG_GET_FHANDLE3(&args->file), 1620*7c478bd9Sstevel@tonic-gate NULL, fhpath, "write3"); 1621*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1622*7c478bd9Sstevel@tonic-gate } 1623*7c478bd9Sstevel@tonic-gate } 1624*7c478bd9Sstevel@tonic-gate 1625*7c478bd9Sstevel@tonic-gate /* 1626*7c478bd9Sstevel@tonic-gate * nfslog_CREATE3_fhargs - if the operation succeeded, we are sure there can 1627*7c478bd9Sstevel@tonic-gate * be no such link in the fhtable, so just add it. 1628*7c478bd9Sstevel@tonic-gate */ 1629*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1630*7c478bd9Sstevel@tonic-gate static void 1631*7c478bd9Sstevel@tonic-gate nfslog_CREATE3_fhargs(nfslog_CREATE3args *args, nfslog_CREATE3res *res, 1632*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1633*7c478bd9Sstevel@tonic-gate { 1634*7c478bd9Sstevel@tonic-gate char *name; 1635*7c478bd9Sstevel@tonic-gate fhandle_t *dfh, *fh; 1636*7c478bd9Sstevel@tonic-gate int error; 1637*7c478bd9Sstevel@tonic-gate 1638*7c478bd9Sstevel@tonic-gate name = args->where.name; 1639*7c478bd9Sstevel@tonic-gate dfh = NFSLOG_GET_FHANDLE3(&args->where.dir); 1640*7c478bd9Sstevel@tonic-gate 1641*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1642*7c478bd9Sstevel@tonic-gate if (res->status == NFS3_OK) 1643*7c478bd9Sstevel@tonic-gate fh = NFSLOG_GET_FHANDLE3( 1644*7c478bd9Sstevel@tonic-gate &res->nfslog_CREATE3res_u.ok.obj.handle); 1645*7c478bd9Sstevel@tonic-gate else 1646*7c478bd9Sstevel@tonic-gate fh = NULL; 1647*7c478bd9Sstevel@tonic-gate PRINT_FULL_DATA(stdout, "=============\nCREATE3", 1648*7c478bd9Sstevel@tonic-gate dfh, fh, name, "") 1649*7c478bd9Sstevel@tonic-gate if (res->status != NFS3_OK) 1650*7c478bd9Sstevel@tonic-gate (void) printf("status %d\n", res->status); 1651*7c478bd9Sstevel@tonic-gate } 1652*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1653*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(dfh, name, fhpath, "create3"); 1654*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1655*7c478bd9Sstevel@tonic-gate } 1656*7c478bd9Sstevel@tonic-gate 1657*7c478bd9Sstevel@tonic-gate if ((res->status != NFS3_OK) || 1658*7c478bd9Sstevel@tonic-gate !res->nfslog_CREATE3res_u.ok.obj.handle_follows) 1659*7c478bd9Sstevel@tonic-gate /* no returned fh so nothing to add */ 1660*7c478bd9Sstevel@tonic-gate return; 1661*7c478bd9Sstevel@tonic-gate 1662*7c478bd9Sstevel@tonic-gate /* A new file handle so add it */ 1663*7c478bd9Sstevel@tonic-gate fh = NFSLOG_GET_FHANDLE3(&res->nfslog_CREATE3res_u.ok.obj.handle); 1664*7c478bd9Sstevel@tonic-gate if (error = FH_ADD(fhpath, dfh, fh, name)) { 1665*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext( 1666*7c478bd9Sstevel@tonic-gate "Create3: Add fh for '%s' failed: %s\n"), 1667*7c478bd9Sstevel@tonic-gate name, ((error >= 0) ? strerror(error) : "Unknown")); 1668*7c478bd9Sstevel@tonic-gate } 1669*7c478bd9Sstevel@tonic-gate } 1670*7c478bd9Sstevel@tonic-gate 1671*7c478bd9Sstevel@tonic-gate /* 1672*7c478bd9Sstevel@tonic-gate * nfslog_MKDIR3_fhargs - if the operation succeeded, we are sure there can 1673*7c478bd9Sstevel@tonic-gate * be no such link in the fhtable, so just add it. 1674*7c478bd9Sstevel@tonic-gate */ 1675*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1676*7c478bd9Sstevel@tonic-gate static void 1677*7c478bd9Sstevel@tonic-gate nfslog_MKDIR3_fhargs(nfslog_MKDIR3args *args, nfslog_MKDIR3res *res, 1678*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1679*7c478bd9Sstevel@tonic-gate { 1680*7c478bd9Sstevel@tonic-gate char *name; 1681*7c478bd9Sstevel@tonic-gate fhandle_t *dfh, *fh; 1682*7c478bd9Sstevel@tonic-gate int error; 1683*7c478bd9Sstevel@tonic-gate 1684*7c478bd9Sstevel@tonic-gate name = args->where.name; 1685*7c478bd9Sstevel@tonic-gate dfh = NFSLOG_GET_FHANDLE3(&args->where.dir); 1686*7c478bd9Sstevel@tonic-gate 1687*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1688*7c478bd9Sstevel@tonic-gate if (res->status == NFS3_OK) 1689*7c478bd9Sstevel@tonic-gate fh = NFSLOG_GET_FHANDLE3( 1690*7c478bd9Sstevel@tonic-gate &res->nfslog_MKDIR3res_u.obj.handle); 1691*7c478bd9Sstevel@tonic-gate else 1692*7c478bd9Sstevel@tonic-gate fh = NULL; 1693*7c478bd9Sstevel@tonic-gate PRINT_FULL_DATA(stdout, "=============\nMKDIR3", 1694*7c478bd9Sstevel@tonic-gate dfh, fh, name, "") 1695*7c478bd9Sstevel@tonic-gate if (res->status != NFS3_OK) 1696*7c478bd9Sstevel@tonic-gate (void) printf("status %d\n", res->status); 1697*7c478bd9Sstevel@tonic-gate } 1698*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1699*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(dfh, name, fhpath, "mkdir3"); 1700*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1701*7c478bd9Sstevel@tonic-gate } 1702*7c478bd9Sstevel@tonic-gate 1703*7c478bd9Sstevel@tonic-gate if ((res->status != NFS3_OK) || 1704*7c478bd9Sstevel@tonic-gate !res->nfslog_MKDIR3res_u.obj.handle_follows) 1705*7c478bd9Sstevel@tonic-gate /* no returned fh so nothing to add */ 1706*7c478bd9Sstevel@tonic-gate return; 1707*7c478bd9Sstevel@tonic-gate 1708*7c478bd9Sstevel@tonic-gate /* A new file handle so add it */ 1709*7c478bd9Sstevel@tonic-gate fh = NFSLOG_GET_FHANDLE3(&res->nfslog_MKDIR3res_u.obj.handle); 1710*7c478bd9Sstevel@tonic-gate if (error = FH_ADD(fhpath, dfh, fh, name)) { 1711*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext( 1712*7c478bd9Sstevel@tonic-gate "Mkdir3: Add fh for '%s' failed: %s\n"), 1713*7c478bd9Sstevel@tonic-gate name, ((error >= 0) ? strerror(error) : "Unknown")); 1714*7c478bd9Sstevel@tonic-gate } 1715*7c478bd9Sstevel@tonic-gate } 1716*7c478bd9Sstevel@tonic-gate 1717*7c478bd9Sstevel@tonic-gate /* 1718*7c478bd9Sstevel@tonic-gate * nfslog_REMOVE3_fhargs - if the operation succeeded, remove the link from 1719*7c478bd9Sstevel@tonic-gate * the fhtable. 1720*7c478bd9Sstevel@tonic-gate */ 1721*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1722*7c478bd9Sstevel@tonic-gate static void 1723*7c478bd9Sstevel@tonic-gate nfslog_REMOVE3_fhargs(nfslog_REMOVE3args *args, nfsstat3 *res, 1724*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1725*7c478bd9Sstevel@tonic-gate { 1726*7c478bd9Sstevel@tonic-gate char *name; 1727*7c478bd9Sstevel@tonic-gate fhandle_t *dfh; 1728*7c478bd9Sstevel@tonic-gate int error; 1729*7c478bd9Sstevel@tonic-gate 1730*7c478bd9Sstevel@tonic-gate name = args->object.name; 1731*7c478bd9Sstevel@tonic-gate dfh = NFSLOG_GET_FHANDLE3(&args->object.dir); 1732*7c478bd9Sstevel@tonic-gate 1733*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1734*7c478bd9Sstevel@tonic-gate PRINT_LINK_DATA(stdout, "=============\nREMOVE3", dfh, name, "") 1735*7c478bd9Sstevel@tonic-gate if (*res != NFS3_OK) 1736*7c478bd9Sstevel@tonic-gate (void) printf("status %d\n", *res); 1737*7c478bd9Sstevel@tonic-gate } 1738*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1739*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(dfh, name, fhpath, "remove3"); 1740*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1741*7c478bd9Sstevel@tonic-gate } 1742*7c478bd9Sstevel@tonic-gate 1743*7c478bd9Sstevel@tonic-gate if (*res != NFS3_OK) 1744*7c478bd9Sstevel@tonic-gate /* remove failed so nothing to update */ 1745*7c478bd9Sstevel@tonic-gate return; 1746*7c478bd9Sstevel@tonic-gate 1747*7c478bd9Sstevel@tonic-gate if (error = fh_remove(fhpath, dfh, name, pathp1)) { 1748*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext("Remove3: '%s' failed: %s\n"), 1749*7c478bd9Sstevel@tonic-gate name, ((error >= 0) ? strerror(error) : "Unknown")); 1750*7c478bd9Sstevel@tonic-gate } 1751*7c478bd9Sstevel@tonic-gate } 1752*7c478bd9Sstevel@tonic-gate 1753*7c478bd9Sstevel@tonic-gate /* 1754*7c478bd9Sstevel@tonic-gate * nfslog_RMDIR3_fhargs - if the operation succeeded, remove the link from 1755*7c478bd9Sstevel@tonic-gate * the fhtable. 1756*7c478bd9Sstevel@tonic-gate */ 1757*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1758*7c478bd9Sstevel@tonic-gate static void 1759*7c478bd9Sstevel@tonic-gate nfslog_RMDIR3_fhargs(nfslog_RMDIR3args *args, nfsstat3 *res, 1760*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1761*7c478bd9Sstevel@tonic-gate { 1762*7c478bd9Sstevel@tonic-gate char *name; 1763*7c478bd9Sstevel@tonic-gate fhandle_t *dfh; 1764*7c478bd9Sstevel@tonic-gate int error; 1765*7c478bd9Sstevel@tonic-gate 1766*7c478bd9Sstevel@tonic-gate name = args->object.name; 1767*7c478bd9Sstevel@tonic-gate dfh = NFSLOG_GET_FHANDLE3(&args->object.dir); 1768*7c478bd9Sstevel@tonic-gate 1769*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1770*7c478bd9Sstevel@tonic-gate PRINT_LINK_DATA(stdout, "=============\nRMDIR3", dfh, name, "") 1771*7c478bd9Sstevel@tonic-gate if (*res != NFS3_OK) 1772*7c478bd9Sstevel@tonic-gate (void) printf("status %d\n", *res); 1773*7c478bd9Sstevel@tonic-gate } 1774*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1775*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(dfh, name, fhpath, "rmdir3"); 1776*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1777*7c478bd9Sstevel@tonic-gate } 1778*7c478bd9Sstevel@tonic-gate 1779*7c478bd9Sstevel@tonic-gate if (*res != NFS3_OK) 1780*7c478bd9Sstevel@tonic-gate /* rmdir failed so nothing to update */ 1781*7c478bd9Sstevel@tonic-gate return; 1782*7c478bd9Sstevel@tonic-gate 1783*7c478bd9Sstevel@tonic-gate if (error = fh_remove(fhpath, dfh, name, pathp1)) { 1784*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext("Rmdir3: '%s' failed: %s\n"), 1785*7c478bd9Sstevel@tonic-gate name, ((error >= 0) ? strerror(error) : "Unknown")); 1786*7c478bd9Sstevel@tonic-gate } 1787*7c478bd9Sstevel@tonic-gate } 1788*7c478bd9Sstevel@tonic-gate 1789*7c478bd9Sstevel@tonic-gate /* 1790*7c478bd9Sstevel@tonic-gate * nfslog_RENAME3_fhargs - if the operation succeeded, update the existing 1791*7c478bd9Sstevel@tonic-gate * fhtable entry to point to new dir and name. 1792*7c478bd9Sstevel@tonic-gate */ 1793*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1794*7c478bd9Sstevel@tonic-gate static void 1795*7c478bd9Sstevel@tonic-gate nfslog_RENAME3_fhargs(nfslog_RENAME3args *args, nfsstat3 *res, 1796*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1797*7c478bd9Sstevel@tonic-gate { 1798*7c478bd9Sstevel@tonic-gate char *from_name, *to_name; 1799*7c478bd9Sstevel@tonic-gate fhandle_t *from_dfh, *to_dfh; 1800*7c478bd9Sstevel@tonic-gate int error; 1801*7c478bd9Sstevel@tonic-gate 1802*7c478bd9Sstevel@tonic-gate from_name = args->from.name; 1803*7c478bd9Sstevel@tonic-gate from_dfh = NFSLOG_GET_FHANDLE3(&args->from.dir); 1804*7c478bd9Sstevel@tonic-gate to_name = args->to.name; 1805*7c478bd9Sstevel@tonic-gate to_dfh = NFSLOG_GET_FHANDLE3(&args->to.dir); 1806*7c478bd9Sstevel@tonic-gate 1807*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1808*7c478bd9Sstevel@tonic-gate PRINT_LINK_DATA(stdout, "=============\nRENAME3: from", 1809*7c478bd9Sstevel@tonic-gate from_dfh, from_name, "") 1810*7c478bd9Sstevel@tonic-gate PRINT_LINK_DATA(stdout, "=============\nRENAME3: to ", 1811*7c478bd9Sstevel@tonic-gate to_dfh, to_name, "") 1812*7c478bd9Sstevel@tonic-gate if (*res != NFS3_OK) 1813*7c478bd9Sstevel@tonic-gate (void) printf("status %d\n", *res); 1814*7c478bd9Sstevel@tonic-gate } 1815*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1816*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(from_dfh, from_name, fhpath, 1817*7c478bd9Sstevel@tonic-gate "rename3 from"); 1818*7c478bd9Sstevel@tonic-gate *pathp2 = nfslog_get_path(to_dfh, to_name, fhpath, 1819*7c478bd9Sstevel@tonic-gate "rename3 to"); 1820*7c478bd9Sstevel@tonic-gate } 1821*7c478bd9Sstevel@tonic-gate if (*res != NFS3_OK) 1822*7c478bd9Sstevel@tonic-gate /* rename failed so nothing to update */ 1823*7c478bd9Sstevel@tonic-gate return; 1824*7c478bd9Sstevel@tonic-gate 1825*7c478bd9Sstevel@tonic-gate if (error = fh_rename(fhpath, from_dfh, from_name, pathp1, 1826*7c478bd9Sstevel@tonic-gate to_dfh, to_name)) { 1827*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext( 1828*7c478bd9Sstevel@tonic-gate "Rename3: Update from '%s' to '%s' failed: %s\n"), 1829*7c478bd9Sstevel@tonic-gate from_name, to_name, 1830*7c478bd9Sstevel@tonic-gate ((error >= 0) ? strerror(error) : "Unknown")); 1831*7c478bd9Sstevel@tonic-gate } 1832*7c478bd9Sstevel@tonic-gate } 1833*7c478bd9Sstevel@tonic-gate 1834*7c478bd9Sstevel@tonic-gate /* 1835*7c478bd9Sstevel@tonic-gate * nfslog_LINK3_fhargs - if the operation succeeded, we are sure there can 1836*7c478bd9Sstevel@tonic-gate * be no such link in the fhtable, so just add it. 1837*7c478bd9Sstevel@tonic-gate */ 1838*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1839*7c478bd9Sstevel@tonic-gate static void 1840*7c478bd9Sstevel@tonic-gate nfslog_LINK3_fhargs(nfslog_LINK3args *args, nfsstat3 *res, 1841*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1842*7c478bd9Sstevel@tonic-gate { 1843*7c478bd9Sstevel@tonic-gate char *name; 1844*7c478bd9Sstevel@tonic-gate fhandle_t *dfh, *fh; 1845*7c478bd9Sstevel@tonic-gate int error; 1846*7c478bd9Sstevel@tonic-gate 1847*7c478bd9Sstevel@tonic-gate fh = NFSLOG_GET_FHANDLE3(&args->file); 1848*7c478bd9Sstevel@tonic-gate name = args->link.name; 1849*7c478bd9Sstevel@tonic-gate dfh = NFSLOG_GET_FHANDLE3(&args->link.dir); 1850*7c478bd9Sstevel@tonic-gate 1851*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1852*7c478bd9Sstevel@tonic-gate PRINT_FULL_DATA(stdout, "=============\nLINK3", 1853*7c478bd9Sstevel@tonic-gate dfh, fh, name, "") 1854*7c478bd9Sstevel@tonic-gate if (*res != NFS3_OK) 1855*7c478bd9Sstevel@tonic-gate (void) printf("status %d\n", *res); 1856*7c478bd9Sstevel@tonic-gate } 1857*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1858*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(fh, NULL, fhpath, "link3 from"); 1859*7c478bd9Sstevel@tonic-gate *pathp2 = nfslog_get_path(dfh, name, fhpath, "link3 to"); 1860*7c478bd9Sstevel@tonic-gate } 1861*7c478bd9Sstevel@tonic-gate 1862*7c478bd9Sstevel@tonic-gate if (*res != NFS3_OK) 1863*7c478bd9Sstevel@tonic-gate /* link failed so nothing to add */ 1864*7c478bd9Sstevel@tonic-gate return; 1865*7c478bd9Sstevel@tonic-gate 1866*7c478bd9Sstevel@tonic-gate /* A new link so add it, have fh_add find link count */ 1867*7c478bd9Sstevel@tonic-gate if (error = FH_ADD(fhpath, dfh, fh, name)) { 1868*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext( 1869*7c478bd9Sstevel@tonic-gate "Link3: Add fh for '%s' failed: %s\n"), 1870*7c478bd9Sstevel@tonic-gate name, ((error >= 0) ? strerror(error) : "Unknown")); 1871*7c478bd9Sstevel@tonic-gate } 1872*7c478bd9Sstevel@tonic-gate } 1873*7c478bd9Sstevel@tonic-gate 1874*7c478bd9Sstevel@tonic-gate /* 1875*7c478bd9Sstevel@tonic-gate * nfslog_MKNOD3_fhargs - if the operation succeeded, we are sure there can 1876*7c478bd9Sstevel@tonic-gate * be no such link in the fhtable, so just add it. 1877*7c478bd9Sstevel@tonic-gate */ 1878*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1879*7c478bd9Sstevel@tonic-gate static void 1880*7c478bd9Sstevel@tonic-gate nfslog_MKNOD3_fhargs(nfslog_MKNOD3args *args, nfslog_MKNOD3res *res, 1881*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1882*7c478bd9Sstevel@tonic-gate { 1883*7c478bd9Sstevel@tonic-gate char *name; 1884*7c478bd9Sstevel@tonic-gate fhandle_t *dfh, *fh; 1885*7c478bd9Sstevel@tonic-gate int error; 1886*7c478bd9Sstevel@tonic-gate 1887*7c478bd9Sstevel@tonic-gate name = args->where.name; 1888*7c478bd9Sstevel@tonic-gate dfh = NFSLOG_GET_FHANDLE3(&args->where.dir); 1889*7c478bd9Sstevel@tonic-gate 1890*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1891*7c478bd9Sstevel@tonic-gate if (res->status == NFS3_OK) 1892*7c478bd9Sstevel@tonic-gate fh = NFSLOG_GET_FHANDLE3( 1893*7c478bd9Sstevel@tonic-gate &res->nfslog_MKNOD3res_u.obj.handle); 1894*7c478bd9Sstevel@tonic-gate else 1895*7c478bd9Sstevel@tonic-gate fh = NULL; 1896*7c478bd9Sstevel@tonic-gate PRINT_FULL_DATA(stdout, "=============\nMKNOD3", 1897*7c478bd9Sstevel@tonic-gate dfh, fh, name, "") 1898*7c478bd9Sstevel@tonic-gate if (res->status != NFS3_OK) 1899*7c478bd9Sstevel@tonic-gate (void) printf("status %d\n", res->status); 1900*7c478bd9Sstevel@tonic-gate } 1901*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1902*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(dfh, name, fhpath, "mknod3"); 1903*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1904*7c478bd9Sstevel@tonic-gate } 1905*7c478bd9Sstevel@tonic-gate if ((res->status != NFS3_OK) || 1906*7c478bd9Sstevel@tonic-gate !res->nfslog_MKNOD3res_u.obj.handle_follows) 1907*7c478bd9Sstevel@tonic-gate /* no returned fh so nothing to add */ 1908*7c478bd9Sstevel@tonic-gate return; 1909*7c478bd9Sstevel@tonic-gate 1910*7c478bd9Sstevel@tonic-gate /* A new file handle so add it */ 1911*7c478bd9Sstevel@tonic-gate fh = NFSLOG_GET_FHANDLE3(&res->nfslog_MKNOD3res_u.obj.handle); 1912*7c478bd9Sstevel@tonic-gate if (error = FH_ADD(fhpath, dfh, fh, name)) { 1913*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext("Mknod3: Add fh for '%s' failed: %s\n"), 1914*7c478bd9Sstevel@tonic-gate name, ((error >= 0) ? strerror(error) : "Unknown")); 1915*7c478bd9Sstevel@tonic-gate } 1916*7c478bd9Sstevel@tonic-gate } 1917*7c478bd9Sstevel@tonic-gate 1918*7c478bd9Sstevel@tonic-gate /* 1919*7c478bd9Sstevel@tonic-gate * nfslog_SYMLINK3_fhargs - if the operation succeeded, we are sure there can 1920*7c478bd9Sstevel@tonic-gate * be no such link in the fhtable, so just add it. 1921*7c478bd9Sstevel@tonic-gate */ 1922*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1923*7c478bd9Sstevel@tonic-gate static void 1924*7c478bd9Sstevel@tonic-gate nfslog_SYMLINK3_fhargs(nfslog_SYMLINK3args *args, nfslog_SYMLINK3res *res, 1925*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1926*7c478bd9Sstevel@tonic-gate { 1927*7c478bd9Sstevel@tonic-gate char *name; 1928*7c478bd9Sstevel@tonic-gate fhandle_t *dfh, *fh; 1929*7c478bd9Sstevel@tonic-gate int error; 1930*7c478bd9Sstevel@tonic-gate 1931*7c478bd9Sstevel@tonic-gate name = args->where.name; 1932*7c478bd9Sstevel@tonic-gate dfh = NFSLOG_GET_FHANDLE3(&args->where.dir); 1933*7c478bd9Sstevel@tonic-gate 1934*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1935*7c478bd9Sstevel@tonic-gate if (res->status == NFS3_OK) 1936*7c478bd9Sstevel@tonic-gate fh = NFSLOG_GET_FHANDLE3( 1937*7c478bd9Sstevel@tonic-gate &res->nfslog_SYMLINK3res_u.obj.handle); 1938*7c478bd9Sstevel@tonic-gate else 1939*7c478bd9Sstevel@tonic-gate fh = NULL; 1940*7c478bd9Sstevel@tonic-gate PRINT_FULL_DATA(stdout, "=============\nSYMLINK3", 1941*7c478bd9Sstevel@tonic-gate dfh, fh, name, "") 1942*7c478bd9Sstevel@tonic-gate if (res->status != NFS3_OK) 1943*7c478bd9Sstevel@tonic-gate (void) printf("status %d\n", res->status); 1944*7c478bd9Sstevel@tonic-gate } 1945*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1946*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(dfh, name, fhpath, "symlink3"); 1947*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1948*7c478bd9Sstevel@tonic-gate } 1949*7c478bd9Sstevel@tonic-gate 1950*7c478bd9Sstevel@tonic-gate if ((res->status != NFS3_OK) || 1951*7c478bd9Sstevel@tonic-gate !res->nfslog_SYMLINK3res_u.obj.handle_follows) 1952*7c478bd9Sstevel@tonic-gate /* no returned fh so nothing to add */ 1953*7c478bd9Sstevel@tonic-gate return; 1954*7c478bd9Sstevel@tonic-gate 1955*7c478bd9Sstevel@tonic-gate /* A new file handle so add it */ 1956*7c478bd9Sstevel@tonic-gate fh = NFSLOG_GET_FHANDLE3(&res->nfslog_SYMLINK3res_u.obj.handle); 1957*7c478bd9Sstevel@tonic-gate if (error = FH_ADD(fhpath, dfh, fh, name)) { 1958*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext( 1959*7c478bd9Sstevel@tonic-gate "Symlink3: Add fh for '%s' failed: %s\n"), 1960*7c478bd9Sstevel@tonic-gate name, ((error >= 0) ? strerror(error) : "Unknown")); 1961*7c478bd9Sstevel@tonic-gate } 1962*7c478bd9Sstevel@tonic-gate } 1963*7c478bd9Sstevel@tonic-gate 1964*7c478bd9Sstevel@tonic-gate /* 1965*7c478bd9Sstevel@tonic-gate * nfslog_READDIR3_fhargs - updates path1 but no fhtable changes 1966*7c478bd9Sstevel@tonic-gate */ 1967*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1968*7c478bd9Sstevel@tonic-gate static void 1969*7c478bd9Sstevel@tonic-gate nfslog_READDIR3_fhargs(nfs_fh3 *args, nfsstat3 *res, 1970*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1971*7c478bd9Sstevel@tonic-gate { 1972*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1973*7c478bd9Sstevel@tonic-gate (void) printf("=============\nREADDIR3: fh "); 1974*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, args, 1975*7c478bd9Sstevel@tonic-gate sizeof (*args)); 1976*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 1977*7c478bd9Sstevel@tonic-gate } 1978*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 1979*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(NFSLOG_GET_FHANDLE3(args), 1980*7c478bd9Sstevel@tonic-gate NULL, fhpath, "readdir3"); 1981*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 1982*7c478bd9Sstevel@tonic-gate } 1983*7c478bd9Sstevel@tonic-gate } 1984*7c478bd9Sstevel@tonic-gate 1985*7c478bd9Sstevel@tonic-gate /* 1986*7c478bd9Sstevel@tonic-gate * nfslog_READDIRPLUS3_fhargs - updates path1 but no fhtable changes 1987*7c478bd9Sstevel@tonic-gate */ 1988*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 1989*7c478bd9Sstevel@tonic-gate static void 1990*7c478bd9Sstevel@tonic-gate nfslog_READDIRPLUS3_fhargs(nfslog_READDIRPLUS3args *args, 1991*7c478bd9Sstevel@tonic-gate nfslog_READDIRPLUS3res *res, 1992*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 1993*7c478bd9Sstevel@tonic-gate { 1994*7c478bd9Sstevel@tonic-gate char *name; 1995*7c478bd9Sstevel@tonic-gate fhandle_t *dfh, *fh; 1996*7c478bd9Sstevel@tonic-gate nfslog_entryplus3 *ep; 1997*7c478bd9Sstevel@tonic-gate 1998*7c478bd9Sstevel@tonic-gate if (debug > 2) { 1999*7c478bd9Sstevel@tonic-gate (void) printf("=============\nREADDIRPLUS3: fh "); 2000*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, &args->dir, 2001*7c478bd9Sstevel@tonic-gate sizeof (args->dir)); 2002*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 2003*7c478bd9Sstevel@tonic-gate } 2004*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 2005*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(NFSLOG_GET_FHANDLE3(&args->dir), 2006*7c478bd9Sstevel@tonic-gate NULL, fhpath, "readdirplus3"); 2007*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 2008*7c478bd9Sstevel@tonic-gate } 2009*7c478bd9Sstevel@tonic-gate 2010*7c478bd9Sstevel@tonic-gate if (res->status == NFS3_OK) { 2011*7c478bd9Sstevel@tonic-gate 2012*7c478bd9Sstevel@tonic-gate dfh = NFSLOG_GET_FHANDLE3(&args->dir); 2013*7c478bd9Sstevel@tonic-gate 2014*7c478bd9Sstevel@tonic-gate /* 2015*7c478bd9Sstevel@tonic-gate * Loop through the fh/name pair and add them 2016*7c478bd9Sstevel@tonic-gate * to the mappings. 2017*7c478bd9Sstevel@tonic-gate */ 2018*7c478bd9Sstevel@tonic-gate for (ep = res->nfslog_READDIRPLUS3res_u.ok.reply.entries; 2019*7c478bd9Sstevel@tonic-gate ep != NULL; 2020*7c478bd9Sstevel@tonic-gate ep = ep->nextentry) { 2021*7c478bd9Sstevel@tonic-gate 2022*7c478bd9Sstevel@tonic-gate name = ep->name; 2023*7c478bd9Sstevel@tonic-gate 2024*7c478bd9Sstevel@tonic-gate fh = NFSLOG_GET_FHANDLE3(&ep->name_handle.handle); 2025*7c478bd9Sstevel@tonic-gate 2026*7c478bd9Sstevel@tonic-gate nfslog_LOOKUP_calc(dfh, name, fh, 2027*7c478bd9Sstevel@tonic-gate fhpath, NULL, NULL, 2028*7c478bd9Sstevel@tonic-gate "ReaddirPlus3"); 2029*7c478bd9Sstevel@tonic-gate } 2030*7c478bd9Sstevel@tonic-gate } 2031*7c478bd9Sstevel@tonic-gate } 2032*7c478bd9Sstevel@tonic-gate 2033*7c478bd9Sstevel@tonic-gate /* 2034*7c478bd9Sstevel@tonic-gate * nfslog_FSSTAT3_fhargs - updates path1 but no fhtable changes 2035*7c478bd9Sstevel@tonic-gate */ 2036*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 2037*7c478bd9Sstevel@tonic-gate static void 2038*7c478bd9Sstevel@tonic-gate nfslog_FSSTAT3_fhargs(nfs_fh3 *args, nfsstat3 *res, 2039*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 2040*7c478bd9Sstevel@tonic-gate { 2041*7c478bd9Sstevel@tonic-gate if (debug > 2) { 2042*7c478bd9Sstevel@tonic-gate (void) printf("=============\nFSSTAT3: fh "); 2043*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, args, 2044*7c478bd9Sstevel@tonic-gate sizeof (*args)); 2045*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 2046*7c478bd9Sstevel@tonic-gate } 2047*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 2048*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(NFSLOG_GET_FHANDLE3(args), NULL, 2049*7c478bd9Sstevel@tonic-gate fhpath, "fsstat3"); 2050*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 2051*7c478bd9Sstevel@tonic-gate } 2052*7c478bd9Sstevel@tonic-gate } 2053*7c478bd9Sstevel@tonic-gate 2054*7c478bd9Sstevel@tonic-gate /* 2055*7c478bd9Sstevel@tonic-gate * nfslog_FSINFO3_fhargs - updates path1 but no fhtable changes 2056*7c478bd9Sstevel@tonic-gate */ 2057*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 2058*7c478bd9Sstevel@tonic-gate static void 2059*7c478bd9Sstevel@tonic-gate nfslog_FSINFO3_fhargs(nfs_fh3 *args, nfsstat3 *res, 2060*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 2061*7c478bd9Sstevel@tonic-gate { 2062*7c478bd9Sstevel@tonic-gate if (debug > 2) { 2063*7c478bd9Sstevel@tonic-gate (void) printf("=============\nFSINFO3: fh "); 2064*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, args, 2065*7c478bd9Sstevel@tonic-gate sizeof (*args)); 2066*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 2067*7c478bd9Sstevel@tonic-gate } 2068*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 2069*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(NFSLOG_GET_FHANDLE3(args), NULL, 2070*7c478bd9Sstevel@tonic-gate fhpath, "fsinfo3"); 2071*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 2072*7c478bd9Sstevel@tonic-gate } 2073*7c478bd9Sstevel@tonic-gate } 2074*7c478bd9Sstevel@tonic-gate 2075*7c478bd9Sstevel@tonic-gate /* 2076*7c478bd9Sstevel@tonic-gate * nfslog_PATHCONF3_fhargs - updates path1 but no fhtable changes 2077*7c478bd9Sstevel@tonic-gate */ 2078*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 2079*7c478bd9Sstevel@tonic-gate static void 2080*7c478bd9Sstevel@tonic-gate nfslog_PATHCONF3_fhargs(nfs_fh3 *args, nfsstat3 *res, 2081*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 2082*7c478bd9Sstevel@tonic-gate { 2083*7c478bd9Sstevel@tonic-gate if (debug > 2) { 2084*7c478bd9Sstevel@tonic-gate (void) printf("=============\nPATHCONF3: fh "); 2085*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, args, 2086*7c478bd9Sstevel@tonic-gate sizeof (*args)); 2087*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 2088*7c478bd9Sstevel@tonic-gate } 2089*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 2090*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(NFSLOG_GET_FHANDLE3(args), NULL, 2091*7c478bd9Sstevel@tonic-gate fhpath, "pathconf3"); 2092*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 2093*7c478bd9Sstevel@tonic-gate } 2094*7c478bd9Sstevel@tonic-gate } 2095*7c478bd9Sstevel@tonic-gate 2096*7c478bd9Sstevel@tonic-gate /* 2097*7c478bd9Sstevel@tonic-gate * nfslog_COMMIT3_fhargs - updates path1 but no fhtable changes 2098*7c478bd9Sstevel@tonic-gate */ 2099*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 2100*7c478bd9Sstevel@tonic-gate static void 2101*7c478bd9Sstevel@tonic-gate nfslog_COMMIT3_fhargs(nfslog_COMMIT3args *args, nfsstat3 *res, 2102*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 2103*7c478bd9Sstevel@tonic-gate { 2104*7c478bd9Sstevel@tonic-gate if (debug > 2) { 2105*7c478bd9Sstevel@tonic-gate (void) printf("=============\nCOMMIT3: fh "); 2106*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, &args->file, 2107*7c478bd9Sstevel@tonic-gate sizeof (args->file)); 2108*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 2109*7c478bd9Sstevel@tonic-gate } 2110*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 2111*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(NFSLOG_GET_FHANDLE3(&args->file), 2112*7c478bd9Sstevel@tonic-gate NULL, fhpath, "commit3"); 2113*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 2114*7c478bd9Sstevel@tonic-gate } 2115*7c478bd9Sstevel@tonic-gate } 2116*7c478bd9Sstevel@tonic-gate 2117*7c478bd9Sstevel@tonic-gate /* 2118*7c478bd9Sstevel@tonic-gate * NFSLOG VERSION 1 2119*7c478bd9Sstevel@tonic-gate */ 2120*7c478bd9Sstevel@tonic-gate 2121*7c478bd9Sstevel@tonic-gate /* 2122*7c478bd9Sstevel@tonic-gate * nfslog_SHARE_fhargs - adds export path and handle to fhlist 2123*7c478bd9Sstevel@tonic-gate */ 2124*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 2125*7c478bd9Sstevel@tonic-gate static void 2126*7c478bd9Sstevel@tonic-gate nfslog_SHARE_fhargs(nfslog_sharefsargs *args, nfslog_sharefsres *res, 2127*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 2128*7c478bd9Sstevel@tonic-gate { 2129*7c478bd9Sstevel@tonic-gate fhlist_ent fhrec; 2130*7c478bd9Sstevel@tonic-gate fhandle_t *fh; 2131*7c478bd9Sstevel@tonic-gate int error; 2132*7c478bd9Sstevel@tonic-gate 2133*7c478bd9Sstevel@tonic-gate if (debug > 2) { 2134*7c478bd9Sstevel@tonic-gate (void) printf( 2135*7c478bd9Sstevel@tonic-gate "=============\nSHARE: name '%s', fh ", args->sh_path); 2136*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, &args->sh_fh_buf, 2137*7c478bd9Sstevel@tonic-gate sizeof (fhandle_t)); 2138*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 2139*7c478bd9Sstevel@tonic-gate } 2140*7c478bd9Sstevel@tonic-gate 2141*7c478bd9Sstevel@tonic-gate fh = &args->sh_fh_buf; 2142*7c478bd9Sstevel@tonic-gate 2143*7c478bd9Sstevel@tonic-gate /* 2144*7c478bd9Sstevel@tonic-gate * This bcopy is done because the fh_data for the export/share directory 2145*7c478bd9Sstevel@tonic-gate * is not meaningful with respect to the database keys. Therefore, we 2146*7c478bd9Sstevel@tonic-gate * copy the export or fh_xdata fid to the fh_data so that a reasonable 2147*7c478bd9Sstevel@tonic-gate * entry will be added in the data base. 2148*7c478bd9Sstevel@tonic-gate */ 2149*7c478bd9Sstevel@tonic-gate bcopy(fh->fh_xdata, fh->fh_data, fh->fh_xlen); 2150*7c478bd9Sstevel@tonic-gate 2151*7c478bd9Sstevel@tonic-gate /* If debug print the database */ 2152*7c478bd9Sstevel@tonic-gate if (debug > 10) { 2153*7c478bd9Sstevel@tonic-gate fh_print_all_keys(fhpath, fh); 2154*7c478bd9Sstevel@tonic-gate } 2155*7c478bd9Sstevel@tonic-gate if (fh_lookup_link(fhpath, fh, fh, 2156*7c478bd9Sstevel@tonic-gate args->sh_path, &fhrec, &error) == NULL) { 2157*7c478bd9Sstevel@tonic-gate if (error = FH_ADD(fhpath, fh, fh, args->sh_path)) { 2158*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext( 2159*7c478bd9Sstevel@tonic-gate "Share: Add fh for '%s' failed: %s\n"), 2160*7c478bd9Sstevel@tonic-gate args->sh_path, ((error >= 0) ? 2161*7c478bd9Sstevel@tonic-gate strerror(error) : "Unknown")); 2162*7c478bd9Sstevel@tonic-gate } 2163*7c478bd9Sstevel@tonic-gate } 2164*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 2165*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(fh, NULL, fhpath, "share"); 2166*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 2167*7c478bd9Sstevel@tonic-gate } 2168*7c478bd9Sstevel@tonic-gate } 2169*7c478bd9Sstevel@tonic-gate 2170*7c478bd9Sstevel@tonic-gate /* 2171*7c478bd9Sstevel@tonic-gate * nfslog_UNSHARE_fhargs - remove export path and handle from fhlist 2172*7c478bd9Sstevel@tonic-gate */ 2173*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 2174*7c478bd9Sstevel@tonic-gate static void 2175*7c478bd9Sstevel@tonic-gate nfslog_UNSHARE_fhargs(nfslog_sharefsargs *args, nfslog_sharefsres *res, 2176*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 2177*7c478bd9Sstevel@tonic-gate { 2178*7c478bd9Sstevel@tonic-gate fhandle_t *fh; 2179*7c478bd9Sstevel@tonic-gate int error; 2180*7c478bd9Sstevel@tonic-gate 2181*7c478bd9Sstevel@tonic-gate if (debug > 2) { 2182*7c478bd9Sstevel@tonic-gate (void) printf("=============\nUNSHARE: name '%s', fh ", 2183*7c478bd9Sstevel@tonic-gate args->sh_path); 2184*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, &args->sh_fh_buf, 2185*7c478bd9Sstevel@tonic-gate sizeof (fhandle_t)); 2186*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 2187*7c478bd9Sstevel@tonic-gate } 2188*7c478bd9Sstevel@tonic-gate 2189*7c478bd9Sstevel@tonic-gate fh = &args->sh_fh_buf; 2190*7c478bd9Sstevel@tonic-gate 2191*7c478bd9Sstevel@tonic-gate /* 2192*7c478bd9Sstevel@tonic-gate * This bcopy is done because the fh_data for the export/share directory 2193*7c478bd9Sstevel@tonic-gate * is not meaningful with respect to the database keys. Therefore, we 2194*7c478bd9Sstevel@tonic-gate * copy the export or fh_xdata fid to the fh_data so that a reasonable 2195*7c478bd9Sstevel@tonic-gate * entry will be added in the data base. 2196*7c478bd9Sstevel@tonic-gate */ 2197*7c478bd9Sstevel@tonic-gate bcopy(fh->fh_xdata, fh->fh_data, fh->fh_xlen); 2198*7c478bd9Sstevel@tonic-gate 2199*7c478bd9Sstevel@tonic-gate /* If debug print the database */ 2200*7c478bd9Sstevel@tonic-gate if (debug > 10) { 2201*7c478bd9Sstevel@tonic-gate fh_print_all_keys(fhpath, fh); 2202*7c478bd9Sstevel@tonic-gate } 2203*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 2204*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(fh, NULL, fhpath, "share"); 2205*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 2206*7c478bd9Sstevel@tonic-gate } 2207*7c478bd9Sstevel@tonic-gate if (error = fh_remove(fhpath, fh, args->sh_path, pathp1)) { 2208*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext("Unshare: '%s' failed: %s\n"), 2209*7c478bd9Sstevel@tonic-gate args->sh_path, ((error >= 0) ? strerror(error) : 2210*7c478bd9Sstevel@tonic-gate "Unknown")); 2211*7c478bd9Sstevel@tonic-gate } 2212*7c478bd9Sstevel@tonic-gate } 2213*7c478bd9Sstevel@tonic-gate 2214*7c478bd9Sstevel@tonic-gate /* ARGSUSED */ 2215*7c478bd9Sstevel@tonic-gate static void 2216*7c478bd9Sstevel@tonic-gate nfslog_GETFH_fhargs(nfslog_getfhargs *args, nfsstat *res, 2217*7c478bd9Sstevel@tonic-gate char *fhpath, char **pathp1, char **pathp2) 2218*7c478bd9Sstevel@tonic-gate { 2219*7c478bd9Sstevel@tonic-gate fhlist_ent fhrec; 2220*7c478bd9Sstevel@tonic-gate fhandle_t *fh; 2221*7c478bd9Sstevel@tonic-gate int error; 2222*7c478bd9Sstevel@tonic-gate 2223*7c478bd9Sstevel@tonic-gate if (debug > 2) { 2224*7c478bd9Sstevel@tonic-gate (void) printf("=============\nGETFH3: name '%s', fh ", 2225*7c478bd9Sstevel@tonic-gate args->gfh_path); 2226*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, &args->gfh_fh_buf, 2227*7c478bd9Sstevel@tonic-gate sizeof (fhandle_t)); 2228*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 2229*7c478bd9Sstevel@tonic-gate } 2230*7c478bd9Sstevel@tonic-gate 2231*7c478bd9Sstevel@tonic-gate fh = &args->gfh_fh_buf; 2232*7c478bd9Sstevel@tonic-gate 2233*7c478bd9Sstevel@tonic-gate /* If debug print the database */ 2234*7c478bd9Sstevel@tonic-gate if (debug > 10) { 2235*7c478bd9Sstevel@tonic-gate fh_print_all_keys(fhpath, fh); 2236*7c478bd9Sstevel@tonic-gate } 2237*7c478bd9Sstevel@tonic-gate if (fh_lookup_link(fhpath, fh, fh, 2238*7c478bd9Sstevel@tonic-gate args->gfh_path, &fhrec, &error) == NULL) { 2239*7c478bd9Sstevel@tonic-gate if (error = FH_ADD(fhpath, fh, fh, args->gfh_path)) { 2240*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext( 2241*7c478bd9Sstevel@tonic-gate "Getfh: Add fh for '%s' failed: %s\n"), 2242*7c478bd9Sstevel@tonic-gate args->gfh_path, ((error >= 0) ? 2243*7c478bd9Sstevel@tonic-gate strerror(error) : "Unknown")); 2244*7c478bd9Sstevel@tonic-gate } 2245*7c478bd9Sstevel@tonic-gate } 2246*7c478bd9Sstevel@tonic-gate if (pathp1 != NULL) { 2247*7c478bd9Sstevel@tonic-gate *pathp1 = nfslog_get_path(fh, NULL, fhpath, "getfh"); 2248*7c478bd9Sstevel@tonic-gate *pathp2 = NULL; 2249*7c478bd9Sstevel@tonic-gate } 2250*7c478bd9Sstevel@tonic-gate } 2251*7c478bd9Sstevel@tonic-gate 2252*7c478bd9Sstevel@tonic-gate /* 2253*7c478bd9Sstevel@tonic-gate * Exported function 2254*7c478bd9Sstevel@tonic-gate */ 2255*7c478bd9Sstevel@tonic-gate 2256*7c478bd9Sstevel@tonic-gate /* 2257*7c478bd9Sstevel@tonic-gate * nfslog_get_path - gets the path for this file. fh must be supplied, 2258*7c478bd9Sstevel@tonic-gate * name may be null. If name is supplied, fh is assumed to be a directory 2259*7c478bd9Sstevel@tonic-gate * filehandle, with name as its component. fhpath is the generic path for the 2260*7c478bd9Sstevel@tonic-gate * fhtopath table and prtstr is the name of the caller (for debug purposes). 2261*7c478bd9Sstevel@tonic-gate * Returns the malloc'd path. The caller must free it later. 2262*7c478bd9Sstevel@tonic-gate */ 2263*7c478bd9Sstevel@tonic-gate char * 2264*7c478bd9Sstevel@tonic-gate nfslog_get_path(fhandle_t *fh, char *name, char *fhpath, char *prtstr) 2265*7c478bd9Sstevel@tonic-gate { 2266*7c478bd9Sstevel@tonic-gate char *pathp = fh_print_absolute(fhpath, fh, name); 2267*7c478bd9Sstevel@tonic-gate 2268*7c478bd9Sstevel@tonic-gate if (debug > 3) { 2269*7c478bd9Sstevel@tonic-gate (void) printf(" %s: path '%s', fh ", prtstr, pathp); 2270*7c478bd9Sstevel@tonic-gate debug_opaque_print(stdout, fh, sizeof (*fh)); 2271*7c478bd9Sstevel@tonic-gate (void) printf("\n"); 2272*7c478bd9Sstevel@tonic-gate } 2273*7c478bd9Sstevel@tonic-gate return (pathp); 2274*7c478bd9Sstevel@tonic-gate } 2275*7c478bd9Sstevel@tonic-gate 2276*7c478bd9Sstevel@tonic-gate /* 2277*7c478bd9Sstevel@tonic-gate * nfslog_process_fh_rec - updates the fh table based on the rpc req 2278*7c478bd9Sstevel@tonic-gate * Return 0 for success, error otherwise. If success return the path 2279*7c478bd9Sstevel@tonic-gate * for the input file handle(s) if so indicated. 2280*7c478bd9Sstevel@tonic-gate */ 2281*7c478bd9Sstevel@tonic-gate int 2282*7c478bd9Sstevel@tonic-gate nfslog_process_fh_rec(struct nfslog_lr *lrp, char *fhpath, char **pathp1, 2283*7c478bd9Sstevel@tonic-gate char **pathp2, bool_t return_path) 2284*7c478bd9Sstevel@tonic-gate { 2285*7c478bd9Sstevel@tonic-gate struct nfsl_fh_proc_disp *disp; 2286*7c478bd9Sstevel@tonic-gate nfslog_request_record *logrec = &lrp->log_record; 2287*7c478bd9Sstevel@tonic-gate nfslog_record_header *logrechdr = &logrec->re_header; 2288*7c478bd9Sstevel@tonic-gate 2289*7c478bd9Sstevel@tonic-gate if ((disp = nfslog_find_fh_dispatch(logrec)) != NULL) { 2290*7c478bd9Sstevel@tonic-gate /* 2291*7c478bd9Sstevel@tonic-gate * Allocate space for the args and results and decode 2292*7c478bd9Sstevel@tonic-gate */ 2293*7c478bd9Sstevel@tonic-gate logrec->re_rpc_arg = calloc(1, disp->args_size); 2294*7c478bd9Sstevel@tonic-gate 2295*7c478bd9Sstevel@tonic-gate if (!(*disp->xdr_args)(&lrp->xdrs, logrec->re_rpc_arg)) { 2296*7c478bd9Sstevel@tonic-gate free(logrec->re_rpc_arg); 2297*7c478bd9Sstevel@tonic-gate logrec->re_rpc_arg = NULL; 2298*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext("argument decode failed")); 2299*7c478bd9Sstevel@tonic-gate return (FALSE); 2300*7c478bd9Sstevel@tonic-gate } 2301*7c478bd9Sstevel@tonic-gate /* used later for free of data structures */ 2302*7c478bd9Sstevel@tonic-gate lrp->xdrargs = disp->xdr_args; 2303*7c478bd9Sstevel@tonic-gate 2304*7c478bd9Sstevel@tonic-gate logrec->re_rpc_res = calloc(1, disp->res_size); 2305*7c478bd9Sstevel@tonic-gate if (!(*disp->xdr_res)(&lrp->xdrs, logrec->re_rpc_res)) { 2306*7c478bd9Sstevel@tonic-gate free(logrec->re_rpc_res); 2307*7c478bd9Sstevel@tonic-gate logrec->re_rpc_res = NULL; 2308*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext("results decode failed")); 2309*7c478bd9Sstevel@tonic-gate return (FALSE); 2310*7c478bd9Sstevel@tonic-gate } 2311*7c478bd9Sstevel@tonic-gate /* used later for free of data structures */ 2312*7c478bd9Sstevel@tonic-gate lrp->xdrres = disp->xdr_res; 2313*7c478bd9Sstevel@tonic-gate 2314*7c478bd9Sstevel@tonic-gate /* 2315*7c478bd9Sstevel@tonic-gate * Process the operation within the context of the file handle 2316*7c478bd9Sstevel@tonic-gate * mapping process 2317*7c478bd9Sstevel@tonic-gate */ 2318*7c478bd9Sstevel@tonic-gate if (return_path) { 2319*7c478bd9Sstevel@tonic-gate (*disp->nfsl_dis_args)(logrec->re_rpc_arg, 2320*7c478bd9Sstevel@tonic-gate logrec->re_rpc_res, fhpath, pathp1, pathp2); 2321*7c478bd9Sstevel@tonic-gate } else { 2322*7c478bd9Sstevel@tonic-gate if ((logrechdr->rh_version == NFS_VERSION && 2323*7c478bd9Sstevel@tonic-gate logrechdr->rh_procnum == RFS_LINK) || 2324*7c478bd9Sstevel@tonic-gate (logrechdr->rh_version == NFS_V3 && 2325*7c478bd9Sstevel@tonic-gate logrechdr->rh_procnum == NFSPROC3_LINK)) { 2326*7c478bd9Sstevel@tonic-gate 2327*7c478bd9Sstevel@tonic-gate (*disp->nfsl_dis_args)(logrec->re_rpc_arg, 2328*7c478bd9Sstevel@tonic-gate logrec->re_rpc_res, 2329*7c478bd9Sstevel@tonic-gate fhpath, pathp1, pathp2); 2330*7c478bd9Sstevel@tonic-gate } else { 2331*7c478bd9Sstevel@tonic-gate (*disp->nfsl_dis_args)(logrec->re_rpc_arg, 2332*7c478bd9Sstevel@tonic-gate logrec->re_rpc_res, 2333*7c478bd9Sstevel@tonic-gate fhpath, NULL, NULL); 2334*7c478bd9Sstevel@tonic-gate } 2335*7c478bd9Sstevel@tonic-gate } 2336*7c478bd9Sstevel@tonic-gate return (TRUE); 2337*7c478bd9Sstevel@tonic-gate } else { 2338*7c478bd9Sstevel@tonic-gate syslog(LOG_ERR, gettext("procedure unknown")); 2339*7c478bd9Sstevel@tonic-gate return (FALSE); 2340*7c478bd9Sstevel@tonic-gate } 2341*7c478bd9Sstevel@tonic-gate } 2342