10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate /* 230Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 280Sstevel@tonic-gate /* All Rights Reserved */ 290Sstevel@tonic-gate 300Sstevel@tonic-gate #ifndef _NFS_EXPORT_H 310Sstevel@tonic-gate #define _NFS_EXPORT_H 320Sstevel@tonic-gate 330Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 340Sstevel@tonic-gate 350Sstevel@tonic-gate #include <nfs/nfs_sec.h> 360Sstevel@tonic-gate #include <rpcsvc/nfsauth_prot.h> 370Sstevel@tonic-gate #include <sys/vnode.h> 380Sstevel@tonic-gate #include <nfs/nfs4.h> 390Sstevel@tonic-gate 400Sstevel@tonic-gate #ifdef __cplusplus 410Sstevel@tonic-gate extern "C" { 420Sstevel@tonic-gate #endif 430Sstevel@tonic-gate 440Sstevel@tonic-gate /* 450Sstevel@tonic-gate * nfs pseudo flavor number is owned by IANA. Need to make sure the 460Sstevel@tonic-gate * Solaris specific NFS_FLAVOR_NOMAP number will not overlap with any 470Sstevel@tonic-gate * new IANA defined pseudo flavor numbers. The chance for the overlap 480Sstevel@tonic-gate * is very small since the growth of new flavor numbers is expected 490Sstevel@tonic-gate * to be limited. 500Sstevel@tonic-gate */ 510Sstevel@tonic-gate #define NFS_FLAVOR_NOMAP 999999 /* no nfs flavor mapping */ 520Sstevel@tonic-gate 530Sstevel@tonic-gate /* 54*2060Sms193421 * As duplicate flavors can be passed into exportfs in the arguments, we 55*2060Sms193421 * allocate a cleaned up array with non duplicate flavors on the stack. 56*2060Sms193421 * So we need to know how much to allocate. 57*2060Sms193421 */ 58*2060Sms193421 #define MAX_FLAVORS 6 /* none, sys, dh, krb5, krb5i krb5p */ 59*2060Sms193421 60*2060Sms193421 /* 610Sstevel@tonic-gate * Note: exported_lock is currently used to ensure the integrity of 620Sstevel@tonic-gate * the secinfo fields. 630Sstevel@tonic-gate */ 640Sstevel@tonic-gate struct secinfo { 650Sstevel@tonic-gate seconfig_t s_secinfo; /* /etc/nfssec.conf entry */ 660Sstevel@tonic-gate unsigned int s_flags; /* flags (see below) */ 67*2060Sms193421 int32_t s_refcnt; /* reference count for tracking */ 680Sstevel@tonic-gate /* how many children (self included) */ 690Sstevel@tonic-gate /* use this flavor. */ 700Sstevel@tonic-gate int s_window; /* window */ 710Sstevel@tonic-gate int s_rootcnt; /* count of root names */ 720Sstevel@tonic-gate caddr_t *s_rootnames; /* array of root names */ 730Sstevel@tonic-gate /* they are strings for AUTH_DES and */ 740Sstevel@tonic-gate /* rpc_gss_principal_t for RPCSEC_GSS */ 750Sstevel@tonic-gate }; 760Sstevel@tonic-gate 770Sstevel@tonic-gate #ifdef _SYSCALL32 780Sstevel@tonic-gate struct secinfo32 { 790Sstevel@tonic-gate seconfig32_t s_secinfo; /* /etc/nfssec.conf entry */ 800Sstevel@tonic-gate uint32_t s_flags; /* flags (see below) */ 81*2060Sms193421 int32_t s_refcnt; /* reference count for tracking */ 820Sstevel@tonic-gate /* how many children (self included) */ 830Sstevel@tonic-gate /* use this flavor. */ 840Sstevel@tonic-gate int32_t s_window; /* window */ 850Sstevel@tonic-gate int32_t s_rootcnt; /* count of root names */ 860Sstevel@tonic-gate caddr32_t s_rootnames; /* array of root names */ 870Sstevel@tonic-gate /* they are strings for AUTH_DES and */ 880Sstevel@tonic-gate /* rpc_gss_principal_t for RPCSEC_GSS */ 890Sstevel@tonic-gate }; 900Sstevel@tonic-gate #endif /* _SYSCALL32 */ 910Sstevel@tonic-gate 920Sstevel@tonic-gate /* 930Sstevel@tonic-gate * security negotiation related 940Sstevel@tonic-gate */ 950Sstevel@tonic-gate 960Sstevel@tonic-gate #define SEC_QUERY 0x01 /* query sec modes */ 970Sstevel@tonic-gate 980Sstevel@tonic-gate struct sec_ol { 990Sstevel@tonic-gate int sec_flags; /* security nego flags */ 1000Sstevel@tonic-gate uint_t sec_index; /* index into sec flavor array */ 1010Sstevel@tonic-gate }; 1020Sstevel@tonic-gate 1030Sstevel@tonic-gate /* 1040Sstevel@tonic-gate * Per-mode flags (secinfo.s_flags) 1050Sstevel@tonic-gate */ 1060Sstevel@tonic-gate #define M_RO 0x01 /* exported ro to all */ 1070Sstevel@tonic-gate #define M_ROL 0x02 /* exported ro to all listed */ 1080Sstevel@tonic-gate #define M_RW 0x04 /* exported rw to all */ 1090Sstevel@tonic-gate #define M_RWL 0x08 /* exported ro to all listed */ 1100Sstevel@tonic-gate #define M_ROOT 0x10 /* root list is defined */ 1110Sstevel@tonic-gate #define M_4SEC_EXPORTED 0x20 /* this is an explicitly shared flavor */ 1120Sstevel@tonic-gate 1130Sstevel@tonic-gate /* invalid secinfo reference count */ 1140Sstevel@tonic-gate #define SEC_REF_INVALID(p) ((p)->s_refcnt < 1) 1150Sstevel@tonic-gate 1160Sstevel@tonic-gate /* last secinfo reference */ 1170Sstevel@tonic-gate #define SEC_REF_LAST(p) ((p)->s_refcnt == 1) 1180Sstevel@tonic-gate 1190Sstevel@tonic-gate /* sec flavor explicitly shared for the exported node */ 1200Sstevel@tonic-gate #define SEC_REF_EXPORTED(p) ((p)->s_flags & M_4SEC_EXPORTED) 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate /* the only reference count left is for referring itself */ 1230Sstevel@tonic-gate #define SEC_REF_SELF(p) (SEC_REF_LAST(p) && SEC_REF_EXPORTED(p)) 1240Sstevel@tonic-gate 1250Sstevel@tonic-gate /* 1260Sstevel@tonic-gate * The export information passed to exportfs() (Version 2) 1270Sstevel@tonic-gate */ 1280Sstevel@tonic-gate #define EX_CURRENT_VERSION 2 /* current version of exportdata struct */ 1290Sstevel@tonic-gate 1300Sstevel@tonic-gate struct exportdata { 1310Sstevel@tonic-gate int ex_version; /* structure version */ 1320Sstevel@tonic-gate char *ex_path; /* exported path */ 1330Sstevel@tonic-gate size_t ex_pathlen; /* path length */ 1340Sstevel@tonic-gate int ex_flags; /* flags */ 1350Sstevel@tonic-gate unsigned int ex_anon; /* uid for unauthenticated requests */ 1360Sstevel@tonic-gate int ex_seccnt; /* count of security modes */ 1370Sstevel@tonic-gate struct secinfo *ex_secinfo; /* security mode info */ 1380Sstevel@tonic-gate char *ex_index; /* index file for public filesystem */ 1390Sstevel@tonic-gate char *ex_log_buffer; /* path to logging buffer file */ 1400Sstevel@tonic-gate size_t ex_log_bufferlen; /* buffer file path len */ 1410Sstevel@tonic-gate char *ex_tag; /* tag used to identify log config */ 1420Sstevel@tonic-gate size_t ex_taglen; /* tag length */ 1430Sstevel@tonic-gate }; 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate #ifdef _SYSCALL32 1460Sstevel@tonic-gate struct exportdata32 { 1470Sstevel@tonic-gate int32_t ex_version; /* structure version */ 1480Sstevel@tonic-gate caddr32_t ex_path; /* exported path */ 1490Sstevel@tonic-gate int32_t ex_pathlen; /* path length */ 1500Sstevel@tonic-gate int32_t ex_flags; /* flags */ 1510Sstevel@tonic-gate uint32_t ex_anon; /* uid for unauthenticated requests */ 1520Sstevel@tonic-gate int32_t ex_seccnt; /* count of security modes */ 1530Sstevel@tonic-gate caddr32_t ex_secinfo; /* security mode info */ 1540Sstevel@tonic-gate caddr32_t ex_index; /* index file for public filesystem */ 1550Sstevel@tonic-gate caddr32_t ex_log_buffer; /* path to logging buffer file */ 1560Sstevel@tonic-gate int32_t ex_log_bufferlen; /* buffer file path len */ 1570Sstevel@tonic-gate caddr32_t ex_tag; /* tag used to identify log config */ 1580Sstevel@tonic-gate int32_t ex_taglen; /* tag length */ 1590Sstevel@tonic-gate }; 1600Sstevel@tonic-gate #endif /* _SYSCALL32 */ 1610Sstevel@tonic-gate 1620Sstevel@tonic-gate /* 1630Sstevel@tonic-gate * exported vfs flags. 1640Sstevel@tonic-gate */ 1650Sstevel@tonic-gate 1660Sstevel@tonic-gate #define EX_NOSUID 0x01 /* exported with unsetable set[ug]ids */ 1670Sstevel@tonic-gate #define EX_ACLOK 0x02 /* exported with maximal access if acl exists */ 1680Sstevel@tonic-gate #define EX_PUBLIC 0x04 /* exported with public filehandle */ 1690Sstevel@tonic-gate #define EX_NOSUB 0x08 /* no nfs_getfh or MCL below export point */ 1700Sstevel@tonic-gate #define EX_INDEX 0x10 /* exported with index file specified */ 1710Sstevel@tonic-gate #define EX_LOG 0x20 /* logging enabled */ 1720Sstevel@tonic-gate #define EX_LOG_ALLOPS 0x40 /* logging of all RPC operations enabled */ 1730Sstevel@tonic-gate /* by default only operations which affect */ 1740Sstevel@tonic-gate /* transaction logging are enabled */ 1750Sstevel@tonic-gate #define EX_PSEUDO 0x80 /* pseudo filesystem export */ 1760Sstevel@tonic-gate #ifdef VOLATILE_FH_TEST 1770Sstevel@tonic-gate #define EX_VOLFH 0x100 /* XXX nfsv4 fh may expire anytime */ 1780Sstevel@tonic-gate #define EX_VOLRNM 0x200 /* XXX nfsv4 fh expire at rename */ 1790Sstevel@tonic-gate #define EX_VOLMIG 0x400 /* XXX nfsv4 fh expire at migration */ 1800Sstevel@tonic-gate #define EX_NOEXPOPEN 0x800 /* XXX nfsv4 fh no expire with open */ 1810Sstevel@tonic-gate #endif /* VOLATILE_FH_TEST */ 1820Sstevel@tonic-gate 1830Sstevel@tonic-gate #ifdef _KERNEL 1840Sstevel@tonic-gate 1850Sstevel@tonic-gate #define RPC_IDEMPOTENT 0x1 /* idempotent or not */ 1860Sstevel@tonic-gate /* 1870Sstevel@tonic-gate * Be very careful about which NFS procedures get the RPC_ALLOWANON bit. 1880Sstevel@tonic-gate * Right now, it this bit is on, we ignore the results of per NFS request 1890Sstevel@tonic-gate * access control. 1900Sstevel@tonic-gate */ 1910Sstevel@tonic-gate #define RPC_ALLOWANON 0x2 /* allow anonymous access */ 1920Sstevel@tonic-gate #define RPC_MAPRESP 0x4 /* use mapped response buffer */ 1930Sstevel@tonic-gate #define RPC_AVOIDWORK 0x8 /* do work avoidance for dups */ 1940Sstevel@tonic-gate #define RPC_PUBLICFH_OK 0x10 /* allow use of public filehandle */ 1950Sstevel@tonic-gate 1960Sstevel@tonic-gate /* 1970Sstevel@tonic-gate * RPC_ALL is an or of all above bits to be used with "don't care" 1980Sstevel@tonic-gate * nfsv4 ops. The flags of an nfsv4 request is the bit-AND of the 1990Sstevel@tonic-gate * per-op flags. 2000Sstevel@tonic-gate */ 2010Sstevel@tonic-gate #define RPC_ALL (RPC_IDEMPOTENT|RPC_ALLOWANON|RPC_AVOIDWORK|RPC_PUBLICFH_OK) 2020Sstevel@tonic-gate 2030Sstevel@tonic-gate 2040Sstevel@tonic-gate #ifdef VOLATILE_FH_TEST 2050Sstevel@tonic-gate struct ex_vol_rename { 2060Sstevel@tonic-gate nfs_fh4_fmt_t vrn_fh_fmt; 2070Sstevel@tonic-gate struct ex_vol_rename *vrn_next; 2080Sstevel@tonic-gate }; 2090Sstevel@tonic-gate #endif /* VOLATILE_FH_TEST */ 2100Sstevel@tonic-gate 2110Sstevel@tonic-gate /* 2120Sstevel@tonic-gate * An authorization cache entry 2130Sstevel@tonic-gate */ 2140Sstevel@tonic-gate struct auth_cache { 2150Sstevel@tonic-gate struct netbuf auth_addr; 2160Sstevel@tonic-gate int auth_flavor; 2170Sstevel@tonic-gate int auth_access; 2180Sstevel@tonic-gate time_t auth_time; 2190Sstevel@tonic-gate struct auth_cache *auth_next; 2200Sstevel@tonic-gate }; 2210Sstevel@tonic-gate 2220Sstevel@tonic-gate #define AUTH_TABLESIZE 32 2230Sstevel@tonic-gate 2240Sstevel@tonic-gate /* 2250Sstevel@tonic-gate * Structure containing log file meta-data. 2260Sstevel@tonic-gate */ 2270Sstevel@tonic-gate struct log_file { 2280Sstevel@tonic-gate unsigned int lf_flags; /* flags (see below) */ 2290Sstevel@tonic-gate int lf_writers; /* outstanding writers */ 2300Sstevel@tonic-gate int lf_refcnt; /* references to this struct */ 2310Sstevel@tonic-gate caddr_t lf_path; /* buffer file location */ 2320Sstevel@tonic-gate vnode_t *lf_vp; /* vnode for the buffer file */ 2330Sstevel@tonic-gate kmutex_t lf_lock; 2340Sstevel@tonic-gate kcondvar_t lf_cv_waiters; 2350Sstevel@tonic-gate }; 2360Sstevel@tonic-gate 2370Sstevel@tonic-gate /* 2380Sstevel@tonic-gate * log_file and log_buffer flags. 2390Sstevel@tonic-gate */ 2400Sstevel@tonic-gate #define L_WAITING 0x01 /* flush of in-core data to stable */ 2410Sstevel@tonic-gate /* storage in progress */ 2420Sstevel@tonic-gate #define L_PRINTED 0x02 /* error message printed to console */ 2430Sstevel@tonic-gate #define L_ERROR 0x04 /* error condition detected */ 2440Sstevel@tonic-gate 2450Sstevel@tonic-gate /* 2460Sstevel@tonic-gate * The logging buffer information. 2470Sstevel@tonic-gate * This structure may be shared by multiple exportinfo structures, 2480Sstevel@tonic-gate * if they share the same buffer file. 2490Sstevel@tonic-gate * This structure contains the basic information about the buffer, such 2500Sstevel@tonic-gate * as it's location in the filesystem. 2510Sstevel@tonic-gate * 2520Sstevel@tonic-gate * 'lb_lock' protects all the fields in this structure except for 'lb_path', 2530Sstevel@tonic-gate * and 'lb_next'. 2540Sstevel@tonic-gate * 'lb_path' is a write-once/read-many field which needs no locking, it is 2550Sstevel@tonic-gate * set before the structure is linked to any exportinfo structure. 2560Sstevel@tonic-gate * 'lb_next' is protected by the log_buffer_list_lock. 2570Sstevel@tonic-gate */ 2580Sstevel@tonic-gate struct log_buffer { 2590Sstevel@tonic-gate unsigned int lb_flags; /* L_ONLIST set? */ 2600Sstevel@tonic-gate int lb_refcnt; /* references to this struct */ 2610Sstevel@tonic-gate unsigned int lb_rec_id; /* used to generate unique id */ 2620Sstevel@tonic-gate caddr_t lb_path; /* buffer file pathname */ 2630Sstevel@tonic-gate struct log_file *lb_logfile; /* points to log_file structure */ 2640Sstevel@tonic-gate kmutex_t lb_lock; 2650Sstevel@tonic-gate struct log_buffer *lb_next; 2660Sstevel@tonic-gate kcondvar_t lb_cv_waiters; 2670Sstevel@tonic-gate caddr_t lb_records; /* linked list of records to write */ 2680Sstevel@tonic-gate int lb_num_recs; /* # of records to write */ 2690Sstevel@tonic-gate ssize_t lb_size_queued; /* number of bytes queued for write */ 2700Sstevel@tonic-gate }; 2710Sstevel@tonic-gate 2720Sstevel@tonic-gate #define LOG_BUFFER_HOLD(lbp) { \ 2730Sstevel@tonic-gate mutex_enter(&(lbp)->lb_lock); \ 2740Sstevel@tonic-gate (lbp)->lb_refcnt++; \ 2750Sstevel@tonic-gate mutex_exit(&(lbp)->lb_lock); \ 2760Sstevel@tonic-gate } 2770Sstevel@tonic-gate 2780Sstevel@tonic-gate #define LOG_BUFFER_RELE(lbp) { \ 2790Sstevel@tonic-gate log_buffer_rele(lbp); \ 2800Sstevel@tonic-gate } 2810Sstevel@tonic-gate 2820Sstevel@tonic-gate #define EXPTABLESIZE 16 2830Sstevel@tonic-gate 2840Sstevel@tonic-gate /* 2850Sstevel@tonic-gate * A node associated with an export entry on the 2860Sstevel@tonic-gate * list of exported filesystems. 2870Sstevel@tonic-gate * 2880Sstevel@tonic-gate * exi_count+exi_lock protects an individual exportinfo from being freed 2890Sstevel@tonic-gate * when in use. 2900Sstevel@tonic-gate * You must have the writer lock on exported_lock to add/delete an exportinfo 2910Sstevel@tonic-gate * structure to/from the list. 2920Sstevel@tonic-gate * 2930Sstevel@tonic-gate * exi_volatile_dev maps to VSW_VOLATILEDEV. It means that the 2940Sstevel@tonic-gate * underlying fs devno can change on each mount. When set, the server 2950Sstevel@tonic-gate * should not use va_fsid for a GETATTR(FATTR4_FSID) reply. It must 2960Sstevel@tonic-gate * use exi_fsid because it is guaranteed to be persistent. This isn't 2970Sstevel@tonic-gate * in any way related to NFS4 volatile filehandles. 2980Sstevel@tonic-gate */ 2990Sstevel@tonic-gate struct exportinfo { 3000Sstevel@tonic-gate struct exportdata exi_export; 3010Sstevel@tonic-gate fsid_t exi_fsid; 3020Sstevel@tonic-gate struct fid exi_fid; 3030Sstevel@tonic-gate struct exportinfo *exi_hash; 3040Sstevel@tonic-gate fhandle_t exi_fh; 3050Sstevel@tonic-gate krwlock_t exi_cache_lock; 3060Sstevel@tonic-gate kmutex_t exi_lock; 3070Sstevel@tonic-gate uint_t exi_count; 3080Sstevel@tonic-gate vnode_t *exi_vp; 3090Sstevel@tonic-gate vnode_t *exi_dvp; 3100Sstevel@tonic-gate struct auth_cache *exi_cache[AUTH_TABLESIZE]; 3110Sstevel@tonic-gate struct log_buffer *exi_logbuffer; 3120Sstevel@tonic-gate struct exp_visible *exi_visible; 3130Sstevel@tonic-gate unsigned exi_volatile_dev:1; 3140Sstevel@tonic-gate #ifdef VOLATILE_FH_TEST 3150Sstevel@tonic-gate uint32_t exi_volatile_id; 3160Sstevel@tonic-gate struct ex_vol_rename *exi_vol_rename; 3170Sstevel@tonic-gate kmutex_t exi_vol_rename_lock; 3180Sstevel@tonic-gate #endif /* VOLATILE_FH_TEST */ 3190Sstevel@tonic-gate }; 3200Sstevel@tonic-gate 3210Sstevel@tonic-gate /* 3220Sstevel@tonic-gate * exp_visible is a visible list per filesystem. It is for filesystems 3230Sstevel@tonic-gate * that may need a limited view of its contents. A pseudo export and 3240Sstevel@tonic-gate * a real export at the mount point (VROOT) which has a subtree shared 3250Sstevel@tonic-gate * has a visible list. 3260Sstevel@tonic-gate * 3270Sstevel@tonic-gate * The exi_visible field is NULL for normal, non=pseudo filesystems 3280Sstevel@tonic-gate * which do not have any subtree exported. If the field is non-null, 3290Sstevel@tonic-gate * it points to a list of visible entries, identified by vis_fid and/or 3300Sstevel@tonic-gate * vis_ino. The presence of a "visible" list means that if this export 3310Sstevel@tonic-gate * can only have a limited view, it can only view the entries in the 3320Sstevel@tonic-gate * exp_visible list. The directories in the fid list comprise paths that 3330Sstevel@tonic-gate * lead to exported directories. 3340Sstevel@tonic-gate * 3350Sstevel@tonic-gate * The vis_count field records the number of paths in this filesystem 3360Sstevel@tonic-gate * that use this directory. The vis_exported field is non-zero if the 3370Sstevel@tonic-gate * entry is an exported directory (leaf node). 3380Sstevel@tonic-gate */ 3390Sstevel@tonic-gate 3400Sstevel@tonic-gate struct exp_visible { 3410Sstevel@tonic-gate vnode_t *vis_vp; 3420Sstevel@tonic-gate fid_t vis_fid; 3430Sstevel@tonic-gate u_longlong_t vis_ino; 3440Sstevel@tonic-gate int vis_count; 3450Sstevel@tonic-gate int vis_exported; 3460Sstevel@tonic-gate struct exp_visible *vis_next; 3470Sstevel@tonic-gate }; 3480Sstevel@tonic-gate 3490Sstevel@tonic-gate #define PSEUDO(exi) ((exi)->exi_export.ex_flags & EX_PSEUDO) 3500Sstevel@tonic-gate 3510Sstevel@tonic-gate #define EQFSID(fsidp1, fsidp2) \ 3520Sstevel@tonic-gate (((fsidp1)->val[0] == (fsidp2)->val[0]) && \ 3530Sstevel@tonic-gate ((fsidp1)->val[1] == (fsidp2)->val[1])) 3540Sstevel@tonic-gate 3550Sstevel@tonic-gate #define EQFID(fidp1, fidp2) \ 3560Sstevel@tonic-gate ((fidp1)->fid_len == (fidp2)->fid_len && \ 357806Sek110237 bcmp((char *)(fidp1)->fid_data, (char *)(fidp2)->fid_data, \ 3580Sstevel@tonic-gate (uint_t)(fidp1)->fid_len) == 0) 3590Sstevel@tonic-gate 3600Sstevel@tonic-gate #define exportmatch(exi, fsid, fid) \ 3610Sstevel@tonic-gate (EQFSID(&(exi)->exi_fsid, (fsid)) && EQFID(&(exi)->exi_fid, (fid))) 3620Sstevel@tonic-gate 3630Sstevel@tonic-gate /* 3640Sstevel@tonic-gate * Returns true iff exported filesystem is read-only to the given host. 3650Sstevel@tonic-gate * 3660Sstevel@tonic-gate * Note: this macro should be as fast as possible since it's called 3670Sstevel@tonic-gate * on each NFS modification request. 3680Sstevel@tonic-gate */ 3690Sstevel@tonic-gate #define rdonly(exi, req) (nfsauth_access(exi, req) & NFSAUTH_RO) 3700Sstevel@tonic-gate #define rdonly4(exi, vp, req) \ 3710Sstevel@tonic-gate (vn_is_readonly(vp) || \ 3720Sstevel@tonic-gate (nfsauth4_access(exi, vp, req) & (NFSAUTH_RO | NFSAUTH_LIMITED))) 3730Sstevel@tonic-gate 3740Sstevel@tonic-gate extern int nfsauth4_access(struct exportinfo *, vnode_t *, 3750Sstevel@tonic-gate struct svc_req *); 3760Sstevel@tonic-gate extern int nfsauth4_secinfo_access(struct exportinfo *, 3770Sstevel@tonic-gate struct svc_req *, int, int); 3780Sstevel@tonic-gate extern int nfs_fhhash(fsid_t *, fid_t *); 3790Sstevel@tonic-gate extern int nfs_fhbcmp(char *, char *, int); 3800Sstevel@tonic-gate extern int nfs_exportinit(void); 3810Sstevel@tonic-gate extern void nfs_exportfini(void); 3820Sstevel@tonic-gate extern int chk_clnt_sec(struct exportinfo *, struct svc_req *req); 3830Sstevel@tonic-gate extern int makefh(fhandle_t *, struct vnode *, struct exportinfo *); 3840Sstevel@tonic-gate extern int makefh_ol(fhandle_t *, struct exportinfo *, uint_t); 3850Sstevel@tonic-gate extern int makefh3(nfs_fh3 *, struct vnode *, struct exportinfo *); 3860Sstevel@tonic-gate extern int makefh3_ol(nfs_fh3 *, struct exportinfo *, uint_t); 3870Sstevel@tonic-gate extern vnode_t *nfs_fhtovp(fhandle_t *, struct exportinfo *); 3880Sstevel@tonic-gate extern vnode_t *nfs3_fhtovp(nfs_fh3 *, struct exportinfo *); 3890Sstevel@tonic-gate extern vnode_t *lm_fhtovp(fhandle_t *fh); 3900Sstevel@tonic-gate extern vnode_t *lm_nfs3_fhtovp(nfs_fh3 *fh); 3910Sstevel@tonic-gate extern struct exportinfo *checkexport(fsid_t *, struct fid *); 3920Sstevel@tonic-gate extern struct exportinfo *checkexport4(fsid_t *, struct fid *, vnode_t *vp); 3930Sstevel@tonic-gate extern void exi_rele(struct exportinfo *); 3940Sstevel@tonic-gate extern struct exportinfo *nfs_vptoexi(vnode_t *, vnode_t *, cred_t *, int *, 3950Sstevel@tonic-gate int *, bool_t); 3960Sstevel@tonic-gate extern int nfs_check_vpexi(vnode_t *, vnode_t *, cred_t *, 3970Sstevel@tonic-gate struct exportinfo **); 3980Sstevel@tonic-gate extern void export_link(struct exportinfo *); 3990Sstevel@tonic-gate extern int export_unlink(fsid_t *, fid_t *, vnode_t *, 4000Sstevel@tonic-gate struct exportinfo **); 4010Sstevel@tonic-gate extern vnode_t *untraverse(vnode_t *); 4020Sstevel@tonic-gate 4030Sstevel@tonic-gate /* 4040Sstevel@tonic-gate * Functions that handle the NFSv4 server namespace 4050Sstevel@tonic-gate */ 4060Sstevel@tonic-gate extern int treeclimb_export(struct exportinfo *); 4070Sstevel@tonic-gate extern int treeclimb_unexport(struct exportinfo *); 4080Sstevel@tonic-gate extern int nfs_visible(struct exportinfo *, vnode_t *, int *); 4090Sstevel@tonic-gate extern int nfs_visible_inode(struct exportinfo *, ino64_t, int *); 4100Sstevel@tonic-gate extern int has_visible(struct exportinfo *, vnode_t *); 4110Sstevel@tonic-gate extern void free_visible(struct exp_visible *); 4120Sstevel@tonic-gate extern int nfs_exported(struct exportinfo *, vnode_t *); 4130Sstevel@tonic-gate extern int pseudo_exportfs(vnode_t *, struct exp_visible *, 4140Sstevel@tonic-gate struct exportdata *); 4150Sstevel@tonic-gate extern int vop_fid_pseudo(vnode_t *, fid_t *fidp); 4160Sstevel@tonic-gate extern int nfs4_vget_pseudo(struct exportinfo *, vnode_t **, fid_t *); 4170Sstevel@tonic-gate /* 4180Sstevel@tonic-gate * Functions that handle the NFSv4 server namespace security flavors 4190Sstevel@tonic-gate * information. 4200Sstevel@tonic-gate */ 4210Sstevel@tonic-gate extern void srv_secinfo_exp2pseu(struct exportdata *, struct exportdata *); 4220Sstevel@tonic-gate 4230Sstevel@tonic-gate /* 4240Sstevel@tonic-gate * "public" and default (root) location for public filehandle 4250Sstevel@tonic-gate */ 4260Sstevel@tonic-gate extern struct exportinfo *exi_public, *exi_root; 4270Sstevel@tonic-gate extern fhandle_t nullfh2; /* for comparing V2 filehandles */ 4280Sstevel@tonic-gate extern krwlock_t exported_lock; 4290Sstevel@tonic-gate extern struct exportinfo *exptable[]; 4300Sstevel@tonic-gate 4310Sstevel@tonic-gate /* 4320Sstevel@tonic-gate * Two macros for identifying public filehandles. 4330Sstevel@tonic-gate * A v2 public filehandle is 32 zero bytes. 4340Sstevel@tonic-gate * A v3 public filehandle is zero length. 4350Sstevel@tonic-gate */ 4360Sstevel@tonic-gate #define PUBLIC_FH2(fh) \ 4370Sstevel@tonic-gate ((fh)->fh_fsid.val[1] == 0 && \ 4380Sstevel@tonic-gate bcmp((fh), &nullfh2, sizeof (fhandle_t)) == 0) 4390Sstevel@tonic-gate 4400Sstevel@tonic-gate #define PUBLIC_FH3(fh) \ 4410Sstevel@tonic-gate ((fh)->fh3_length == 0) 4420Sstevel@tonic-gate 4430Sstevel@tonic-gate extern int makefh4(nfs_fh4 *, struct vnode *, struct exportinfo *); 4440Sstevel@tonic-gate extern vnode_t *nfs4_fhtovp(nfs_fh4 *, struct exportinfo *, nfsstat4 *); 4450Sstevel@tonic-gate 4460Sstevel@tonic-gate #endif /* _KERNEL */ 4470Sstevel@tonic-gate 4480Sstevel@tonic-gate #ifdef __cplusplus 4490Sstevel@tonic-gate } 4500Sstevel@tonic-gate #endif 4510Sstevel@tonic-gate 4520Sstevel@tonic-gate #endif /* _NFS_EXPORT_H */ 453