| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: smbfs_io.c,v 1.32 2009/03/18 16:00:21 cegger Exp $ */ | | 1 | /* $NetBSD: smbfs_io.c,v 1.33 2009/06/22 21:13:50 njoly Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2000-2001, Boris Popov | | 4 | * Copyright (c) 2000-2001, Boris Popov |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -26,27 +26,27 @@ | | | @@ -26,27 +26,27 @@ |
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
32 | * SUCH DAMAGE. | | 32 | * SUCH DAMAGE. |
33 | * | | 33 | * |
34 | * FreeBSD: src/sys/fs/smbfs/smbfs_io.c,v 1.7 2001/12/02 08:56:58 bp Exp | | 34 | * FreeBSD: src/sys/fs/smbfs/smbfs_io.c,v 1.7 2001/12/02 08:56:58 bp Exp |
35 | * | | 35 | * |
36 | */ | | 36 | */ |
37 | | | 37 | |
38 | #include <sys/cdefs.h> | | 38 | #include <sys/cdefs.h> |
39 | __KERNEL_RCSID(0, "$NetBSD: smbfs_io.c,v 1.32 2009/03/18 16:00:21 cegger Exp $"); | | 39 | __KERNEL_RCSID(0, "$NetBSD: smbfs_io.c,v 1.33 2009/06/22 21:13:50 njoly Exp $"); |
40 | | | 40 | |
41 | #include <sys/param.h> | | 41 | #include <sys/param.h> |
42 | #include <sys/systm.h> | | 42 | #include <sys/systm.h> |
43 | #include <sys/resourcevar.h> /* defines plimit structure in proc struct */ | | 43 | #include <sys/resourcevar.h> /* defines plimit structure in proc struct */ |
44 | #include <sys/kernel.h> | | 44 | #include <sys/kernel.h> |
45 | #include <sys/proc.h> | | 45 | #include <sys/proc.h> |
46 | #include <sys/fcntl.h> | | 46 | #include <sys/fcntl.h> |
47 | #include <sys/buf.h> | | 47 | #include <sys/buf.h> |
48 | #include <sys/mount.h> | | 48 | #include <sys/mount.h> |
49 | #include <sys/malloc.h> | | 49 | #include <sys/malloc.h> |
50 | #include <sys/namei.h> | | 50 | #include <sys/namei.h> |
51 | #include <sys/vnode.h> | | 51 | #include <sys/vnode.h> |
52 | #include <sys/dirent.h> | | 52 | #include <sys/dirent.h> |
| @@ -244,27 +244,27 @@ smbfs_writevnode(struct vnode *vp, struc | | | @@ -244,27 +244,27 @@ smbfs_writevnode(struct vnode *vp, struc |
244 | { | | 244 | { |
245 | struct smbmount *smp = VTOSMBFS(vp); | | 245 | struct smbmount *smp = VTOSMBFS(vp); |
246 | struct smbnode *np = VTOSMB(vp); | | 246 | struct smbnode *np = VTOSMB(vp); |
247 | struct smb_cred scred; | | 247 | struct smb_cred scred; |
248 | struct lwp *l = curlwp; | | 248 | struct lwp *l = curlwp; |
249 | struct proc *p = l->l_proc; | | 249 | struct proc *p = l->l_proc; |
250 | int error = 0; | | 250 | int error = 0; |
251 | int extended = 0; | | 251 | int extended = 0; |
252 | size_t resid = uiop->uio_resid; | | 252 | size_t resid = uiop->uio_resid; |
253 | | | 253 | |
254 | /* vn types other than VREG unsupported */ | | 254 | /* vn types other than VREG unsupported */ |
255 | KASSERT(vp->v_type == VREG); | | 255 | KASSERT(vp->v_type == VREG); |
256 | | | 256 | |
257 | SMBVDEBUG("ofs=%lld,resid=%d\n", | | 257 | SMBVDEBUG("ofs=%lld,resid=%zu\n", |
258 | (long long int) uiop->uio_offset, | | 258 | (long long int) uiop->uio_offset, |
259 | uiop->uio_resid); | | 259 | uiop->uio_resid); |
260 | if (uiop->uio_offset < 0) | | 260 | if (uiop->uio_offset < 0) |
261 | return EINVAL; | | 261 | return EINVAL; |
262 | /* if (uiop->uio_offset + uiop->uio_resid > smp->nm_maxfilesize) | | 262 | /* if (uiop->uio_offset + uiop->uio_resid > smp->nm_maxfilesize) |
263 | return (EFBIG);*/ | | 263 | return (EFBIG);*/ |
264 | if (ioflag & (IO_APPEND | IO_SYNC)) { | | 264 | if (ioflag & (IO_APPEND | IO_SYNC)) { |
265 | if (np->n_flag & NMODIFIED) { | | 265 | if (np->n_flag & NMODIFIED) { |
266 | smbfs_attr_cacheremove(vp); | | 266 | smbfs_attr_cacheremove(vp); |
267 | error = smbfs_vinvalbuf(vp, V_SAVE, cred, l, 1); | | 267 | error = smbfs_vinvalbuf(vp, V_SAVE, cred, l, 1); |
268 | if (error) | | 268 | if (error) |
269 | return error; | | 269 | return error; |
270 | } | | 270 | } |
| @@ -281,27 +281,28 @@ smbfs_writevnode(struct vnode *vp, struc | | | @@ -281,27 +281,28 @@ smbfs_writevnode(struct vnode *vp, struc |
281 | uiop->uio_offset = np->n_size; | | 281 | uiop->uio_offset = np->n_size; |
282 | } | | 282 | } |
283 | } | | 283 | } |
284 | if (uiop->uio_resid == 0) | | 284 | if (uiop->uio_resid == 0) |
285 | return 0; | | 285 | return 0; |
286 | if (p && uiop->uio_offset + uiop->uio_resid > p->p_rlimit[RLIMIT_FSIZE].rlim_cur) { | | 286 | if (p && uiop->uio_offset + uiop->uio_resid > p->p_rlimit[RLIMIT_FSIZE].rlim_cur) { |
287 | mutex_enter(proc_lock); | | 287 | mutex_enter(proc_lock); |
288 | psignal(p, SIGXFSZ); | | 288 | psignal(p, SIGXFSZ); |
289 | mutex_exit(proc_lock); | | 289 | mutex_exit(proc_lock); |
290 | return EFBIG; | | 290 | return EFBIG; |
291 | } | | 291 | } |
292 | smb_makescred(&scred, l, cred); | | 292 | smb_makescred(&scred, l, cred); |
293 | error = smb_write(smp->sm_share, np->n_fid, uiop, &scred); | | 293 | error = smb_write(smp->sm_share, np->n_fid, uiop, &scred); |
294 | SMBVDEBUG("after: ofs=%lld,resid=%d,err=%d\n",(long long int)uiop->uio_offset, uiop->uio_resid, error); | | 294 | SMBVDEBUG("after: ofs=%lld,resid=%zu,err=%d\n", |
| | | 295 | (long long int)uiop->uio_offset, uiop->uio_resid, error); |
295 | if (!error) { | | 296 | if (!error) { |
296 | if (uiop->uio_offset > np->n_size) { | | 297 | if (uiop->uio_offset > np->n_size) { |
297 | np->n_size = uiop->uio_offset; | | 298 | np->n_size = uiop->uio_offset; |
298 | uvm_vnp_setsize(vp, np->n_size); | | 299 | uvm_vnp_setsize(vp, np->n_size); |
299 | extended = 1; | | 300 | extended = 1; |
300 | } | | 301 | } |
301 | | | 302 | |
302 | } | | 303 | } |
303 | if (resid > uiop->uio_resid) | | 304 | if (resid > uiop->uio_resid) |
304 | VN_KNOTE(vp, NOTE_WRITE | (extended ? NOTE_EXTEND : 0)); | | 305 | VN_KNOTE(vp, NOTE_WRITE | (extended ? NOTE_EXTEND : 0)); |
305 | return error; | | 306 | return error; |
306 | } | | 307 | } |
307 | | | 308 | |