Print this page
NEX-6276 SMB sparse file support
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-4083 Upstream changes from illumos 5917 and 5995
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-3620 need upstream cleanups for smbsrv
Reviewed by: Hans Rosenfeld <hans.rosenfeld@nexenta.com>
SMB-11 SMB2 message parse & dispatch
SMB-12 SMB2 Negotiate Protocol
SMB-13 SMB2 Session Setup
SMB-14 SMB2 Logoff
SMB-15 SMB2 Tree Connect
SMB-16 SMB2 Tree Disconnect
SMB-17 SMB2 Create
SMB-18 SMB2 Close
SMB-19 SMB2 Flush
SMB-20 SMB2 Read
SMB-21 SMB2 Write
SMB-22 SMB2 Lock/Unlock
SMB-23 SMB2 Ioctl
SMB-24 SMB2 Cancel
SMB-25 SMB2 Echo
SMB-26 SMB2 Query Dir
SMB-27 SMB2 Change Notify
SMB-28 SMB2 Query Info
SMB-29 SMB2 Set Info
SMB-30 SMB2 Oplocks
SMB-53 SMB2 Create Context options
(SMB2 code review cleanup 1, 2, 3)
SMB-50 User-mode SMB server
Includes work by these authors:
Thomas Keiser <thomas.keiser@nexenta.com>
Albert Lee <trisk@nexenta.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/lib/smbsrv/libfksmbsrv/common/fake_vfs.c
+++ new/usr/src/lib/smbsrv/libfksmbsrv/common/fake_vfs.c
1 1 /*
2 2 * This file and its contents are supplied under the terms of the
|
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
3 3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 4 * You may only use this file in accordance with the terms of version
5 5 * 1.0 of the CDDL.
6 6 *
7 7 * A full copy of the text of the CDDL should have accompanied this
8 8 * source. A copy of the CDDL is also available via the Internet at
9 9 * http://www.illumos.org/license/CDDL.
10 10 */
11 11
12 12 /*
13 - * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
13 + * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
14 14 */
15 15
16 16 #include <sys/types.h>
17 17 #include <sys/param.h>
18 18 #include <sys/t_lock.h>
19 19 #include <sys/errno.h>
20 20 #include <sys/cred.h>
21 21 #include <sys/user.h>
22 22 #include <sys/uio.h>
23 23 #include <sys/file.h>
24 24 #include <sys/pathname.h>
25 25 #include <sys/vfs.h>
26 26 #include <sys/vnode.h>
27 27 #include <sys/stat.h>
28 28 #include <sys/mode.h>
29 29 #include <sys/conf.h>
30 30 #include <sys/sysmacros.h>
31 31 #include <sys/cmn_err.h>
32 32 #include <sys/systm.h>
33 33 #include <sys/kmem.h>
34 34 #include <sys/debug.h>
35 35 #include <sys/acl.h>
36 36 #include <sys/nbmlock.h>
37 37 #include <sys/fcntl.h>
38 38 #include <sys/poll.h>
39 39
40 40 #include <errno.h>
41 41 #include <fcntl.h>
42 42 #include <unistd.h>
|
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
43 43
44 44 #include "vncache.h"
45 45
46 46 #define VFTBITS(feature) ((feature) & 0xFFFFFFFFLL)
47 47
48 48 static uint64_t vfs_features = VFSFT_XVATTR;
49 49
50 50 vnode_t *rootdir = NULL; /* pointer to root inode vnode. */
51 51
52 52 static struct vfs fake_rootvfs;
53 +static struct vfsops fake_vfsops;
53 54 struct vfs *rootvfs = NULL;
55 +static struct vfssw fake_vfssw = {
56 + .vsw_name = "fake" /* see smb_tree.c:smb_mtype[] */
57 +};
54 58
55 59 int
56 60 fksmbsrv_vfs_init(void)
57 61 {
58 62 struct stat st;
59 63 int err, fd;
60 64 vnode_t *vp;
61 65 char *name = "/";
62 66
63 67 if (rootvfs == NULL) {
64 68 rootvfs = &fake_rootvfs;
65 69 rootvfs->vfs_mntpt = refstr_alloc(name);
66 70 rootvfs->vfs_fsid.val[0] = 1;
71 + rootvfs->vfs_op = &fake_vfsops;
67 72 }
68 73
69 74 if (rootdir == NULL) {
70 75 if (lstat(name, &st) == -1)
71 76 return (errno);
72 77 fd = open(name, O_RDONLY, 0);
73 78 if (fd < 0) {
74 79 return (errno);
75 80 }
76 81 if (fstat(fd, &st) == -1) {
77 82 err = errno;
78 83 (void) close(fd);
79 84 return (err);
80 85 }
81 86 vp = vncache_enter(&st, NULL, "", fd);
82 87 /* extra hold for rootvp */
83 88 vn_hold(vp);
84 89 rootdir = vp;
85 90
86 91 /* VFS stuff in global zone struct. */
87 92 zone0.zone_rootvp = rootdir;
88 93 zone0.zone_rootpath = "/";
89 94 }
90 95
91 96 return (0);
92 97
93 98 }
94 99
95 100
96 101 /*
97 102 * Query a vfs for a feature.
98 103 * Returns 1 if feature is present, 0 if not
99 104 */
100 105 /* ARGSUSED */
101 106 int
102 107 vfs_has_feature(vfs_t *vfsp, vfs_feature_t feature)
103 108 {
104 109 int ret = 0;
105 110
106 111 if (vfs_features & VFTBITS(feature))
107 112 ret = 1;
108 113
109 114 return (ret);
110 115 }
111 116
112 117 /* ARGSUSED */
113 118 struct vfs *
114 119 getvfs(fsid_t *fsid)
115 120 {
116 121 return (rootvfs);
117 122 }
118 123
|
↓ open down ↓ |
42 lines elided |
↑ open up ↑ |
119 124 vfsops_t *
120 125 vfs_getops(vfs_t *vfsp)
121 126 {
122 127 return (vfsp->vfs_op);
123 128 }
124 129
125 130 /* ARGSUSED */
126 131 struct vfssw *
127 132 vfs_getvfsswbyvfsops(vfsops_t *vfsops)
128 133 {
134 + if (vfsops == &fake_vfsops)
135 + return (&fake_vfssw);
129 136 return (NULL);
130 137 }
131 138
132 139 /* ARGSUSED */
133 140 void
134 141 vfs_unrefvfssw(struct vfssw *vswp)
135 142 {
136 143 }
137 144
138 145 /* ARGSUSED */
139 146 int
140 147 fsop_root(vfs_t *vfsp, vnode_t **vpp)
141 148 {
142 149 vnode_t *vp;
143 150
144 151 if ((vp = rootdir) == NULL)
145 152 return (ENXIO);
146 153
147 154 vn_hold(vp);
148 155 *vpp = vp;
149 156 return (0);
150 157 }
151 158
152 159 /* ARGSUSED */
153 160 int
154 161 fsop_statfs(vfs_t *vfsp, statvfs64_t *sp)
155 162 {
156 163 vnode_t *vp;
157 164 int rc;
158 165
159 166 if ((vp = rootdir) == NULL)
160 167 return (ENXIO);
161 168
162 169 rc = fstatvfs64(vp->v_fd, sp);
163 170 if (rc == -1) {
164 171 rc = errno;
165 172 }
166 173
167 174 return (rc);
168 175 }
169 176
170 177 refstr_t *
171 178 vfs_getmntpoint(const struct vfs *vfsp)
172 179 {
173 180 refstr_t *mntpt;
174 181
175 182 mntpt = vfsp->vfs_mntpt;
176 183 refstr_hold(mntpt);
177 184
178 185 return (mntpt);
179 186 }
180 187
181 188 /* ARGSUSED */
182 189 void
183 190 vfs_hold(vfs_t *vfsp)
184 191 {
185 192 }
186 193
187 194 /* ARGSUSED */
188 195 void
189 196 vfs_rele(vfs_t *vfsp)
190 197 {
191 198 }
192 199
193 200 /* ARGSUSED */
194 201 int
195 202 vfs_lock(vfs_t *vfsp)
196 203 {
197 204 return (0);
198 205 }
199 206
200 207 /* ARGSUSED */
201 208 int
202 209 vfs_rlock(vfs_t *vfsp)
203 210 {
204 211 return (0);
205 212 }
206 213
207 214 /* ARGSUSED */
208 215 void
209 216 vfs_lock_wait(vfs_t *vfsp)
210 217 {
211 218 }
212 219
213 220 /* ARGSUSED */
214 221 void
215 222 vfs_rlock_wait(vfs_t *vfsp)
216 223 {
217 224 }
218 225
219 226 /* ARGSUSED */
220 227 void
221 228 vfs_unlock(vfs_t *vfsp)
222 229 {
223 230 }
224 231
225 232
226 233 static u_longlong_t fs_caller_id;
227 234 u_longlong_t
228 235 fs_new_caller_id(void)
229 236 {
230 237 return (++fs_caller_id);
231 238 }
232 239
233 240 static sysid_t lm_sysid;
234 241 sysid_t
235 242 lm_alloc_sysidt(void)
236 243 {
237 244 return (++lm_sysid);
238 245 }
239 246
240 247 /* ARGSUSED */
241 248 void
242 249 lm_free_sysidt(sysid_t id)
243 250 {
244 251 }
|
↓ open down ↓ |
106 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX