14bff34e3Sthurlow /* 24bff34e3Sthurlow * Copyright (c) 2000-2001, Boris Popov 34bff34e3Sthurlow * All rights reserved. 44bff34e3Sthurlow * 54bff34e3Sthurlow * Redistribution and use in source and binary forms, with or without 64bff34e3Sthurlow * modification, are permitted provided that the following conditions 74bff34e3Sthurlow * are met: 84bff34e3Sthurlow * 1. Redistributions of source code must retain the above copyright 94bff34e3Sthurlow * notice, this list of conditions and the following disclaimer. 104bff34e3Sthurlow * 2. Redistributions in binary form must reproduce the above copyright 114bff34e3Sthurlow * notice, this list of conditions and the following disclaimer in the 124bff34e3Sthurlow * documentation and/or other materials provided with the distribution. 134bff34e3Sthurlow * 3. All advertising materials mentioning features or use of this software 144bff34e3Sthurlow * must display the following acknowledgement: 154bff34e3Sthurlow * This product includes software developed by Boris Popov. 164bff34e3Sthurlow * 4. Neither the name of the author nor the names of any co-contributors 174bff34e3Sthurlow * may be used to endorse or promote products derived from this software 184bff34e3Sthurlow * without specific prior written permission. 194bff34e3Sthurlow * 204bff34e3Sthurlow * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 214bff34e3Sthurlow * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 224bff34e3Sthurlow * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 234bff34e3Sthurlow * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 244bff34e3Sthurlow * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 254bff34e3Sthurlow * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 264bff34e3Sthurlow * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 274bff34e3Sthurlow * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 284bff34e3Sthurlow * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 294bff34e3Sthurlow * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 304bff34e3Sthurlow * SUCH DAMAGE. 314bff34e3Sthurlow * 324bff34e3Sthurlow * $Id: smbfs.h,v 1.30.100.1 2005/05/27 02:35:28 lindak Exp $ 334bff34e3Sthurlow */ 344bff34e3Sthurlow 354bff34e3Sthurlow /* 36*a19609f8Sjv227347 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 374bff34e3Sthurlow */ 384bff34e3Sthurlow 394bff34e3Sthurlow #ifndef _SMBFS_SMBFS_H 404bff34e3Sthurlow #define _SMBFS_SMBFS_H 414bff34e3Sthurlow 424bff34e3Sthurlow /* 434bff34e3Sthurlow * FS-specific VFS structures for smbfs. 444bff34e3Sthurlow * (per-mount stuff, etc.) 454bff34e3Sthurlow * 464bff34e3Sthurlow * This file used to have mount args stuff, 474bff34e3Sthurlow * but that's now in sys/fs/smbfs_mount.h 484bff34e3Sthurlow */ 494bff34e3Sthurlow 50613a2f6bSGordon Ross #include <sys/param.h> 51613a2f6bSGordon Ross #include <sys/fstyp.h> 5202d09e03SGordon Ross #include <sys/avl.h> 534bff34e3Sthurlow #include <sys/list.h> 5402d09e03SGordon Ross #include <sys/t_lock.h> 554bff34e3Sthurlow #include <sys/vfs.h> 5642d15982SGordon Ross #include <sys/vfs_opreg.h> 574bff34e3Sthurlow #include <sys/fs/smbfs_mount.h> 58*a19609f8Sjv227347 #include <sys/zone.h> 594bff34e3Sthurlow 60613a2f6bSGordon Ross /* 61613a2f6bSGordon Ross * Path component length 62613a2f6bSGordon Ross * 63613a2f6bSGordon Ross * The generic fs code uses MAXNAMELEN to represent 64613a2f6bSGordon Ross * what the largest component length is, but note: 65613a2f6bSGordon Ross * that length DOES include the terminating NULL. 66613a2f6bSGordon Ross * SMB_MAXFNAMELEN does NOT include the NULL. 67613a2f6bSGordon Ross */ 68613a2f6bSGordon Ross #define SMB_MAXFNAMELEN (MAXNAMELEN-1) /* 255 */ 694bff34e3Sthurlow 704bff34e3Sthurlow /* 714bff34e3Sthurlow * SM_MAX_STATFSTIME is the maximum time to cache statvfs data. Since this 724bff34e3Sthurlow * should be a fast call on the server, the time the data cached is short. 734bff34e3Sthurlow * That lets the cache handle bursts of statvfs() requests without generating 744bff34e3Sthurlow * lots of network traffic. 754bff34e3Sthurlow */ 764bff34e3Sthurlow #define SM_MAX_STATFSTIME 2 774bff34e3Sthurlow 784bff34e3Sthurlow /* Mask values for smbmount structure sm_status field */ 794bff34e3Sthurlow #define SM_STATUS_STATFS_BUSY 0x00000001 /* statvfs is in progress */ 804bff34e3Sthurlow #define SM_STATUS_STATFS_WANT 0x00000002 /* statvfs wakeup is wanted */ 814bff34e3Sthurlow #define SM_STATUS_TIMEO 0x00000004 /* this mount is not responding */ 824bff34e3Sthurlow #define SM_STATUS_DEAD 0x00000010 /* connection gone - unmount this */ 834bff34e3Sthurlow 844bff34e3Sthurlow extern const struct fs_operation_def smbfs_vnodeops_template[]; 854bff34e3Sthurlow extern struct vnodeops *smbfs_vnodeops; 864bff34e3Sthurlow 874bff34e3Sthurlow struct smbnode; 884bff34e3Sthurlow struct smb_share; 894bff34e3Sthurlow 904bff34e3Sthurlow /* 9102d09e03SGordon Ross * The values for smi_flags (from nfs_clnt.h) 924bff34e3Sthurlow */ 9302d09e03SGordon Ross #define SMI_INT 0x04 /* interrupts allowed */ 9402d09e03SGordon Ross #define SMI_NOAC 0x10 /* don't cache attributes */ 954bff34e3Sthurlow #define SMI_LLOCK 0x80 /* local locking only */ 9602d09e03SGordon Ross #define SMI_ACL 0x2000 /* share supports ACLs */ 9702d09e03SGordon Ross #define SMI_EXTATTR 0x80000 /* share supports ext. attrs */ 9802d09e03SGordon Ross #define SMI_DEAD 0x200000 /* mount has been terminated */ 994bff34e3Sthurlow 1004bff34e3Sthurlow /* 101613a2f6bSGordon Ross * Stuff returned by smbfs_smb_qfsattr 102613a2f6bSGordon Ross * See [CIFS] SMB_QUERY_FS_ATTRIBUTE_INFO 103613a2f6bSGordon Ross */ 104613a2f6bSGordon Ross typedef struct smb_fs_attr_info { 105613a2f6bSGordon Ross uint32_t fsa_aflags; /* Attr. flags [CIFS 4.1.6.6] */ 106613a2f6bSGordon Ross uint32_t fsa_maxname; /* max. component length */ 107613a2f6bSGordon Ross char fsa_tname[FSTYPSZ]; /* type name, i.e. "NTFS" */ 108613a2f6bSGordon Ross } smb_fs_attr_info_t; 109613a2f6bSGordon Ross 110613a2f6bSGordon Ross /* 1114bff34e3Sthurlow * Corresponds to Darwin: struct smbmount 1124bff34e3Sthurlow */ 1134bff34e3Sthurlow typedef struct smbmntinfo { 1144bff34e3Sthurlow struct vfs *smi_vfsp; /* mount back pointer to vfs */ 1154bff34e3Sthurlow struct smbnode *smi_root; /* the root node */ 1164bff34e3Sthurlow struct smb_share *smi_share; /* netsmb SMB share conn data */ 1174bff34e3Sthurlow kmutex_t smi_lock; /* mutex for flags, etc. */ 1184bff34e3Sthurlow uint32_t smi_flags; /* NFS-derived flag bits */ 1194bff34e3Sthurlow uint32_t smi_status; /* status bits for this mount */ 1204bff34e3Sthurlow hrtime_t smi_statfstime; /* sm_statvfsbuf cache time */ 1214bff34e3Sthurlow statvfs64_t smi_statvfsbuf; /* cached statvfs data */ 1224bff34e3Sthurlow kcondvar_t smi_statvfs_cv; 123613a2f6bSGordon Ross smb_fs_attr_info_t smi_fsa; /* SMB FS attributes. */ 124613a2f6bSGordon Ross #define smi_fsattr smi_fsa.fsa_aflags 1254bff34e3Sthurlow 1264bff34e3Sthurlow /* 12702d09e03SGordon Ross * The smbfs node cache for this mount. 12802d09e03SGordon Ross * Named "hash" for historical reasons. 12902d09e03SGordon Ross * See smbfs_node.h for details. 13002d09e03SGordon Ross */ 13102d09e03SGordon Ross avl_tree_t smi_hash_avl; 13202d09e03SGordon Ross krwlock_t smi_hash_lk; 13302d09e03SGordon Ross 13402d09e03SGordon Ross /* 1354bff34e3Sthurlow * Kstat statistics 1364bff34e3Sthurlow */ 1374bff34e3Sthurlow struct kstat *smi_io_kstats; 1384bff34e3Sthurlow struct kstat *smi_ro_kstats; 1394bff34e3Sthurlow 1404bff34e3Sthurlow /* 1414bff34e3Sthurlow * Zones support. 1424bff34e3Sthurlow */ 143*a19609f8Sjv227347 zone_ref_t smi_zone_ref; /* Zone FS is mounted in */ 1444bff34e3Sthurlow list_node_t smi_zone_node; /* Link to per-zone smi list */ 1454bff34e3Sthurlow /* Lock for the list is: smi_globals_t -> smg_lock */ 1464bff34e3Sthurlow 1474bff34e3Sthurlow /* 14802d09e03SGordon Ross * Stuff copied or derived from the mount args 1494bff34e3Sthurlow */ 15002d09e03SGordon Ross uid_t smi_uid; /* user id */ 15102d09e03SGordon Ross gid_t smi_gid; /* group id */ 15202d09e03SGordon Ross mode_t smi_fmode; /* mode for files */ 15302d09e03SGordon Ross mode_t smi_dmode; /* mode for dirs */ 15402d09e03SGordon Ross 15502d09e03SGordon Ross hrtime_t smi_acregmin; /* min time to hold cached file attr */ 15602d09e03SGordon Ross hrtime_t smi_acregmax; /* max time to hold cached file attr */ 15702d09e03SGordon Ross hrtime_t smi_acdirmin; /* min time to hold cached dir attr */ 15802d09e03SGordon Ross hrtime_t smi_acdirmax; /* max time to hold cached dir attr */ 1594bff34e3Sthurlow } smbmntinfo_t; 1604bff34e3Sthurlow 16102d09e03SGordon Ross /* 16202d09e03SGordon Ross * Attribute cache timeout defaults (in seconds). 16302d09e03SGordon Ross */ 16402d09e03SGordon Ross #define SMBFS_ACREGMIN 3 /* min secs to hold cached file attr */ 16502d09e03SGordon Ross #define SMBFS_ACREGMAX 60 /* max secs to hold cached file attr */ 16602d09e03SGordon Ross #define SMBFS_ACDIRMIN 30 /* min secs to hold cached dir attr */ 16702d09e03SGordon Ross #define SMBFS_ACDIRMAX 60 /* max secs to hold cached dir attr */ 16802d09e03SGordon Ross /* and limits for the mount options */ 16902d09e03SGordon Ross #define SMBFS_ACMINMAX 600 /* 10 min. is longest min timeout */ 17002d09e03SGordon Ross #define SMBFS_ACMAXMAX 3600 /* 1 hr is longest max timeout */ 17102d09e03SGordon Ross 17202d09e03SGordon Ross /* 17302d09e03SGordon Ross * High-res time is nanoseconds. 17402d09e03SGordon Ross */ 17502d09e03SGordon Ross #define SEC2HR(sec) ((sec) * (hrtime_t)NANOSEC) 1764bff34e3Sthurlow 1774bff34e3Sthurlow /* 1784bff34e3Sthurlow * vnode pointer to mount info 1794bff34e3Sthurlow */ 1804bff34e3Sthurlow #define VTOSMI(vp) ((smbmntinfo_t *)(((vp)->v_vfsp)->vfs_data)) 1814bff34e3Sthurlow #define VFTOSMI(vfsp) ((smbmntinfo_t *)((vfsp)->vfs_data)) 1824bff34e3Sthurlow #define SMBINTR(vp) (VTOSMI(vp)->smi_flags & SMI_INT) 1834bff34e3Sthurlow 1844bff34e3Sthurlow #endif /* _SMBFS_SMBFS_H */ 185