diff options
author | peter <peter@FreeBSD.org> | 1998-05-30 16:33:58 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1998-05-30 16:33:58 +0000 |
commit | aa33f209931229b1ec794891bd3a69a8eff05835 (patch) | |
tree | 5c600b7c603c70dd7c1f21b9426387f4c7902f04 /sys/nfs/nfs_bio.c | |
parent | 0d948cca0487b241fec6cc5211d55dc5ffabb72c (diff) | |
download | FreeBSD-src-aa33f209931229b1ec794891bd3a69a8eff05835.zip FreeBSD-src-aa33f209931229b1ec794891bd3a69a8eff05835.tar.gz |
When using NFSv3, use the remote server's idea of the maximum file size
rather than assuming 2^64. It may not like files that big. :-)
On the nfs server, calculate and report the max file size as the point
that the block numbers in the cache would turn negative.
(ie: 1099511627775 bytes (1TB)).
One of the things I'm worried about however, is that directory offsets
are really cookies on a NFSv3 server and can be rather large, especially
when/if the server generates the opaque directory cookies by using a local
filesystem offset in what comes out as the upper 32 bits of the 64 bit
cookie. (a server is free to do this, it could save byte swapping
depending on the native 64 bit byte order)
Obtained from: NetBSD
Diffstat (limited to 'sys/nfs/nfs_bio.c')
-rw-r--r-- | sys/nfs/nfs_bio.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/nfs/nfs_bio.c b/sys/nfs/nfs_bio.c index d16bf1a..d98bc7f 100644 --- a/sys/nfs/nfs_bio.c +++ b/sys/nfs/nfs_bio.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. * * @(#)nfs_bio.c 8.9 (Berkeley) 3/30/95 - * $Id: nfs_bio.c,v 1.55 1998/05/19 07:11:22 peter Exp $ + * $Id: nfs_bio.c,v 1.56 1998/05/20 08:02:23 peter Exp $ */ @@ -254,12 +254,15 @@ nfs_bioread(vp, uio, ioflag, cred, getpages) #endif if (uio->uio_resid == 0) return (0); - if (uio->uio_offset < 0) + if (uio->uio_offset < 0) /* XXX VDIR cookies can be negative */ return (EINVAL); p = uio->uio_procp; if ((nmp->nm_flag & NFSMNT_NFSV3) != 0 && (nmp->nm_state & NFSSTA_GOTFSINFO) == 0) (void)nfs_fsinfo(nmp, vp, cred, p); + if (vp->v_type != VDIR && + (uio->uio_offset + uio->uio_resid) > nmp->nm_maxfilesize) + return (EFBIG); biosize = vp->v_mount->mnt_stat.f_iosize; /* * For nfs, cache consistency can only be maintained approximately. @@ -657,6 +660,8 @@ nfs_write(ap) } if (uio->uio_offset < 0) return (EINVAL); + if ((uio->uio_offset + uio->uio_resid) > nmp->nm_maxfilesize) + return (EFBIG); if (uio->uio_resid == 0) return (0); /* |