xref: /titanic_51/usr/src/uts/common/fs/smbclnt/smbfs/smbfs.h (revision b7b0558ae6cf66a2c72f08f9104c1559d962bc84)
1 /*
2  * Copyright (c) 2000-2001, Boris Popov
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *    This product includes software developed by Boris Popov.
16  * 4. Neither the name of the author nor the names of any co-contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  *
32  * $Id: smbfs.h,v 1.30.100.1 2005/05/27 02:35:28 lindak Exp $
33  */
34 
35 /*
36  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
37  * Use is subject to license terms.
38  */
39 
40 #ifndef	_SMBFS_SMBFS_H
41 #define	_SMBFS_SMBFS_H
42 
43 /*
44  * FS-specific VFS structures for smbfs.
45  * (per-mount stuff, etc.)
46  *
47  * This file used to have mount args stuff,
48  * but that's now in sys/fs/smbfs_mount.h
49  */
50 
51 #include <sys/param.h>
52 #include <sys/fstyp.h>
53 #include <sys/avl.h>
54 #include <sys/list.h>
55 #include <sys/t_lock.h>
56 #include <sys/vfs.h>
57 #include <sys/fs/smbfs_mount.h>
58 
59 /*
60  * Path component length
61  *
62  * The generic fs code uses MAXNAMELEN to represent
63  * what the largest component length is, but note:
64  * that length DOES include the terminating NULL.
65  * SMB_MAXFNAMELEN does NOT include the NULL.
66  */
67 #define	SMB_MAXFNAMELEN		(MAXNAMELEN-1)	/* 255 */
68 
69 /*
70  * SM_MAX_STATFSTIME is the maximum time to cache statvfs data. Since this
71  * should be a fast call on the server, the time the data cached is short.
72  * That lets the cache handle bursts of statvfs() requests without generating
73  * lots of network traffic.
74  */
75 #define	SM_MAX_STATFSTIME 2
76 
77 /* Mask values for smbmount structure sm_status field */
78 #define	SM_STATUS_STATFS_BUSY 0x00000001 /* statvfs is in progress */
79 #define	SM_STATUS_STATFS_WANT 0x00000002 /* statvfs wakeup is wanted */
80 #define	SM_STATUS_TIMEO 0x00000004 /* this mount is not responding */
81 #define	SM_STATUS_DEAD	0x00000010 /* connection gone - unmount this */
82 
83 extern const struct fs_operation_def	smbfs_vnodeops_template[];
84 extern struct vnodeops			*smbfs_vnodeops;
85 
86 struct smbnode;
87 struct smb_share;
88 
89 /*
90  * The values for smi_flags (from nfs_clnt.h)
91  */
92 #define	SMI_INT		0x04		/* interrupts allowed */
93 #define	SMI_NOAC	0x10		/* don't cache attributes */
94 #define	SMI_LLOCK	0x80		/* local locking only */
95 #define	SMI_ACL		0x2000		/* share supports ACLs */
96 #define	SMI_EXTATTR	0x80000		/* share supports ext. attrs */
97 #define	SMI_DEAD	0x200000	/* mount has been terminated */
98 
99 /*
100  * Stuff returned by smbfs_smb_qfsattr
101  * See [CIFS] SMB_QUERY_FS_ATTRIBUTE_INFO
102  */
103 typedef struct smb_fs_attr_info {
104 	uint32_t	fsa_aflags;	/* Attr. flags [CIFS 4.1.6.6] */
105 	uint32_t	fsa_maxname;	/* max. component length */
106 	char		fsa_tname[FSTYPSZ]; /* type name, i.e. "NTFS" */
107 } smb_fs_attr_info_t;
108 
109 /*
110  * Corresponds to Darwin: struct smbmount
111  */
112 typedef struct smbmntinfo {
113 	struct vfs		*smi_vfsp;	/* mount back pointer to vfs */
114 	struct smbnode		*smi_root;	/* the root node */
115 	struct smb_share	*smi_share;	/* netsmb SMB share conn data */
116 	kmutex_t		smi_lock;	/* mutex for flags, etc. */
117 	uint32_t		smi_flags;	/* NFS-derived flag bits */
118 	uint32_t		smi_status;	/* status bits for this mount */
119 	hrtime_t		smi_statfstime;	/* sm_statvfsbuf cache time */
120 	statvfs64_t		smi_statvfsbuf;	/* cached statvfs data */
121 	kcondvar_t		smi_statvfs_cv;
122 	smb_fs_attr_info_t	smi_fsa;	/* SMB FS attributes. */
123 #define	smi_fsattr		smi_fsa.fsa_aflags
124 
125 	/*
126 	 * The smbfs node cache for this mount.
127 	 * Named "hash" for historical reasons.
128 	 * See smbfs_node.h for details.
129 	 */
130 	avl_tree_t		smi_hash_avl;
131 	krwlock_t		smi_hash_lk;
132 
133 	/*
134 	 * Kstat statistics
135 	 */
136 	struct kstat    *smi_io_kstats;
137 	struct kstat    *smi_ro_kstats;
138 
139 	/*
140 	 * Zones support.
141 	 */
142 	struct zone		*smi_zone;	/* Zone mounted in */
143 	list_node_t		smi_zone_node;	/* Link to per-zone smi list */
144 	/* Lock for the list is: smi_globals_t -> smg_lock */
145 
146 	/*
147 	 * Stuff copied or derived from the mount args
148 	 */
149 	uid_t		smi_uid;		/* user id */
150 	gid_t		smi_gid;		/* group id */
151 	mode_t		smi_fmode;		/* mode for files */
152 	mode_t		smi_dmode;		/* mode for dirs */
153 
154 	hrtime_t	smi_acregmin;	/* min time to hold cached file attr */
155 	hrtime_t	smi_acregmax;	/* max time to hold cached file attr */
156 	hrtime_t	smi_acdirmin;	/* min time to hold cached dir attr */
157 	hrtime_t	smi_acdirmax;	/* max time to hold cached dir attr */
158 } smbmntinfo_t;
159 
160 /*
161  * Attribute cache timeout defaults (in seconds).
162  */
163 #define	SMBFS_ACREGMIN	3	/* min secs to hold cached file attr */
164 #define	SMBFS_ACREGMAX	60	/* max secs to hold cached file attr */
165 #define	SMBFS_ACDIRMIN	30	/* min secs to hold cached dir attr */
166 #define	SMBFS_ACDIRMAX	60	/* max secs to hold cached dir attr */
167 /* and limits for the mount options */
168 #define	SMBFS_ACMINMAX	600	/* 10 min. is longest min timeout */
169 #define	SMBFS_ACMAXMAX	3600	/* 1 hr is longest max timeout */
170 
171 /*
172  * High-res time is nanoseconds.
173  */
174 #define	SEC2HR(sec)	((sec) * (hrtime_t)NANOSEC)
175 
176 /*
177  * vnode pointer to mount info
178  */
179 #define	VTOSMI(vp)	((smbmntinfo_t *)(((vp)->v_vfsp)->vfs_data))
180 #define	VFTOSMI(vfsp)	((smbmntinfo_t *)((vfsp)->vfs_data))
181 #define	SMBINTR(vp)	(VTOSMI(vp)->smi_flags & SMI_INT)
182 
183 #endif	/* _SMBFS_SMBFS_H */
184