Deleted Added
full compact
smbfs_vfsops.c (243397) smbfs_vfsops.c (250236)
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 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
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 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/fs/smbfs/smbfs_vfsops.c 243397 2012-11-22 09:13:45Z davide $
26 * $FreeBSD: head/sys/fs/smbfs/smbfs_vfsops.c 250236 2013-05-04 14:03:18Z davide $
27 */
28
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/proc.h>
32#include <sys/bio.h>
33#include <sys/buf.h>
34#include <sys/kernel.h>

--- 82 unchanged lines hidden (view full) ---

117 ma = mount_argf(ma, "caseopt", "%d", args.caseopt);
118
119 error = kernel_mount(ma, flags);
120
121 return (error);
122}
123
124static const char *smbfs_opts[] = {
27 */
28
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/proc.h>
32#include <sys/bio.h>
33#include <sys/buf.h>
34#include <sys/kernel.h>

--- 82 unchanged lines hidden (view full) ---

117 ma = mount_argf(ma, "caseopt", "%d", args.caseopt);
118
119 error = kernel_mount(ma, flags);
120
121 return (error);
122}
123
124static const char *smbfs_opts[] = {
125 "dev", "soft", "intr", "strong", "have_nls", "long",
125 "fd", "soft", "intr", "strong", "have_nls", "long",
126 "mountpoint", "rootpath", "uid", "gid", "file_mode", "dir_mode",
127 "caseopt", "errmsg", NULL
128};
129
130static int
131smbfs_mount(struct mount *mp)
132{
133 struct smbmount *smp = NULL;
134 struct smb_vc *vcp;
135 struct smb_share *ssp = NULL;
136 struct vnode *vp;
137 struct thread *td;
126 "mountpoint", "rootpath", "uid", "gid", "file_mode", "dir_mode",
127 "caseopt", "errmsg", NULL
128};
129
130static int
131smbfs_mount(struct mount *mp)
132{
133 struct smbmount *smp = NULL;
134 struct smb_vc *vcp;
135 struct smb_share *ssp = NULL;
136 struct vnode *vp;
137 struct thread *td;
138 struct smb_dev *dev;
138 struct smb_cred *scred;
139 int error, v;
140 char *pc, *pe;
141
139 struct smb_cred *scred;
140 int error, v;
141 char *pc, *pe;
142
143 dev = NULL;
142 td = curthread;
143 if (mp->mnt_flag & (MNT_UPDATE | MNT_ROOTFS))
144 return EOPNOTSUPP;
145
146 if (vfs_filteropt(mp->mnt_optnew, smbfs_opts)) {
147 vfs_mount_error(mp, "%s", "Invalid option");
148 return (EINVAL);
149 }
150
151 scred = smbfs_malloc_scred();
152 smb_makescred(scred, td, td->td_ucred);
144 td = curthread;
145 if (mp->mnt_flag & (MNT_UPDATE | MNT_ROOTFS))
146 return EOPNOTSUPP;
147
148 if (vfs_filteropt(mp->mnt_optnew, smbfs_opts)) {
149 vfs_mount_error(mp, "%s", "Invalid option");
150 return (EINVAL);
151 }
152
153 scred = smbfs_malloc_scred();
154 smb_makescred(scred, td, td->td_ucred);
153 if (1 != vfs_scanopt(mp->mnt_optnew, "dev", "%d", &v)) {
154 vfs_mount_error(mp, "No dev option");
155
156 /* Ask userspace of `fd`, the file descriptor of this session */
157 if (1 != vfs_scanopt(mp->mnt_optnew, "fd", "%d", &v)) {
158 vfs_mount_error(mp, "No fd option");
155 smbfs_free_scred(scred);
156 return (EINVAL);
157 }
159 smbfs_free_scred(scred);
160 return (EINVAL);
161 }
158 error = smb_dev2share(v, SMBM_EXEC, scred, &ssp);
162 error = smb_dev2share(v, SMBM_EXEC, scred, &ssp, &dev);
163 smp = malloc(sizeof(*smp), M_SMBFSDATA, M_WAITOK | M_ZERO);
159 if (error) {
160 printf("invalid device handle %d (%d)\n", v, error);
164 if (error) {
165 printf("invalid device handle %d (%d)\n", v, error);
161 vfs_mount_error(mp, "invalid device handle %d (%d)\n", v, error);
166 vfs_mount_error(mp, "invalid device handle %d %d\n", v, error);
162 smbfs_free_scred(scred);
167 smbfs_free_scred(scred);
168 free(smp, M_SMBFSDATA);
163 return error;
164 }
165 vcp = SSTOVC(ssp);
166 smb_share_unlock(ssp, 0);
167 mp->mnt_stat.f_iosize = SSTOVC(ssp)->vc_txmax;
169 return error;
170 }
171 vcp = SSTOVC(ssp);
172 smb_share_unlock(ssp, 0);
173 mp->mnt_stat.f_iosize = SSTOVC(ssp)->vc_txmax;
168
169 smp = malloc(sizeof(*smp), M_SMBFSDATA, M_WAITOK | M_ZERO);
170 mp->mnt_data = smp;
174 mp->mnt_data = smp;
171 smp->sm_share = ssp;
172 smp->sm_root = NULL;
175 smp->sm_share = ssp;
176 smp->sm_root = NULL;
177 smp->sm_dev = dev;
173 if (1 != vfs_scanopt(mp->mnt_optnew,
174 "caseopt", "%d", &smp->sm_caseopt)) {
175 vfs_mount_error(mp, "Invalid caseopt");
176 error = EINVAL;
177 goto bad;
178 }
179 if (1 != vfs_scanopt(mp->mnt_optnew, "uid", "%d", &v)) {
180 vfs_mount_error(mp, "Invalid uid");

--- 52 unchanged lines hidden (view full) ---

233#ifdef DIAGNOSTIC
234 SMBERROR("mp=%p\n", mp);
235#endif
236 smbfs_free_scred(scred);
237 return error;
238bad:
239 if (ssp)
240 smb_share_put(ssp, scred);
178 if (1 != vfs_scanopt(mp->mnt_optnew,
179 "caseopt", "%d", &smp->sm_caseopt)) {
180 vfs_mount_error(mp, "Invalid caseopt");
181 error = EINVAL;
182 goto bad;
183 }
184 if (1 != vfs_scanopt(mp->mnt_optnew, "uid", "%d", &v)) {
185 vfs_mount_error(mp, "Invalid uid");

--- 52 unchanged lines hidden (view full) ---

238#ifdef DIAGNOSTIC
239 SMBERROR("mp=%p\n", mp);
240#endif
241 smbfs_free_scred(scred);
242 return error;
243bad:
244 if (ssp)
245 smb_share_put(ssp, scred);
241 smbfs_free_scred(scred);
242 return error;
246 smbfs_free_scred(scred);
247 SMB_LOCK();
248 if (error && smp->sm_dev == dev) {
249 smp->sm_dev = NULL;
250 sdp_trydestroy(dev);
251 }
252 SMB_UNLOCK();
253 free(smp, M_SMBFSDATA);
254 return error;
243}
244
245/* Unmount the filesystem described by mp. */
246static int
247smbfs_unmount(struct mount *mp, int mntflags)
248{
249 struct thread *td;
250 struct smbmount *smp = VFSTOSMBFS(mp);
251 struct smb_cred *scred;
255}
256
257/* Unmount the filesystem described by mp. */
258static int
259smbfs_unmount(struct mount *mp, int mntflags)
260{
261 struct thread *td;
262 struct smbmount *smp = VFSTOSMBFS(mp);
263 struct smb_cred *scred;
264 struct smb_dev *dev;
252 int error, flags;
253
254 SMBVDEBUG("smbfs_unmount: flags=%04x\n", mntflags);
255 td = curthread;
256 flags = 0;
257 if (mntflags & MNT_FORCE)
258 flags |= FORCECLOSE;
259 /*

--- 12 unchanged lines hidden (view full) ---

272 if (error)
273 return error;
274 scred = smbfs_malloc_scred();
275 smb_makescred(scred, td, td->td_ucred);
276 error = smb_share_lock(smp->sm_share, LK_EXCLUSIVE);
277 if (error)
278 goto out;
279 smb_share_put(smp->sm_share, scred);
265 int error, flags;
266
267 SMBVDEBUG("smbfs_unmount: flags=%04x\n", mntflags);
268 td = curthread;
269 flags = 0;
270 if (mntflags & MNT_FORCE)
271 flags |= FORCECLOSE;
272 /*

--- 12 unchanged lines hidden (view full) ---

285 if (error)
286 return error;
287 scred = smbfs_malloc_scred();
288 smb_makescred(scred, td, td->td_ucred);
289 error = smb_share_lock(smp->sm_share, LK_EXCLUSIVE);
290 if (error)
291 goto out;
292 smb_share_put(smp->sm_share, scred);
293 SMB_LOCK();
294 dev = smp->sm_dev;
295 if (!dev)
296 panic("No private data for mount point");
297 sdp_trydestroy(dev);
280 mp->mnt_data = NULL;
298 mp->mnt_data = NULL;
299 SMB_UNLOCK();
281 free(smp, M_SMBFSDATA);
282 MNT_ILOCK(mp);
283 mp->mnt_flag &= ~MNT_LOCAL;
284 MNT_IUNLOCK(mp);
285out:
286 smbfs_free_scred(scred);
287 return error;
288}

--- 113 unchanged lines hidden ---
300 free(smp, M_SMBFSDATA);
301 MNT_ILOCK(mp);
302 mp->mnt_flag &= ~MNT_LOCAL;
303 MNT_IUNLOCK(mp);
304out:
305 smbfs_free_scred(scred);
306 return error;
307}

--- 113 unchanged lines hidden ---