Restrict fs_maxfilesize to 2^40, and check against this in ffs_truncate().
This is part of a bug fix from Kirk McKusick to work around problems in FFS related to the blkno of a 64bit offset not fitting into an int. Note the proper solution would be to deal with 64bit block numbers, but doing this would require sweeping changes; some other day perhaps. Submitted by: Marshall Kirk McKusick
This commit is contained in:
parent
a3189e21e6
commit
901ba606c5
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)ffs_inode.c 8.5 (Berkeley) 12/30/93
|
||||
* $Id: ffs_inode.c,v 1.7 1994/09/02 10:24:55 davidg Exp $
|
||||
* $Id: ffs_inode.c,v 1.8 1994/10/10 01:04:37 phk Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -163,9 +163,10 @@ ffs_truncate(ap)
|
||||
int aflags, error, allerror;
|
||||
off_t osize;
|
||||
|
||||
if (length < 0)
|
||||
panic("ffs_truncate: invalid length");
|
||||
oip = VTOI(ovp);
|
||||
fs = oip->i_fs;
|
||||
if (length < 0 || length > fs->fs_maxfilesize)
|
||||
return (EINVAL);
|
||||
tv = time;
|
||||
if (ovp->v_type == VLNK &&
|
||||
(oip->i_size < ovp->v_mount->mnt_maxsymlinklen || oip->i_din.di_blocks == 0)) {
|
||||
@ -188,7 +189,6 @@ ffs_truncate(ap)
|
||||
return (error);
|
||||
#endif
|
||||
vnode_pager_setsize(ovp, (u_long)length);
|
||||
fs = oip->i_fs;
|
||||
osize = oip->i_size;
|
||||
/*
|
||||
* Lengthen the size of the file. We must ensure that the
|
||||
|
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)ffs_vfsops.c 8.8 (Berkeley) 4/18/94
|
||||
* $Id: ffs_vfsops.c,v 1.8 1994/10/08 06:20:06 phk Exp $
|
||||
* $Id: ffs_vfsops.c,v 1.9 1994/10/10 01:04:39 phk Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -490,11 +490,14 @@ ffs_oldfscompat(fs)
|
||||
if (fs->fs_inodefmt < FS_44INODEFMT) { /* XXX */
|
||||
quad_t sizepb = fs->fs_bsize; /* XXX */
|
||||
/* XXX */
|
||||
#if 0
|
||||
fs->fs_maxfilesize = fs->fs_bsize * NDADDR - 1; /* XXX */
|
||||
for (i = 0; i < NIADDR; i++) { /* XXX */
|
||||
sizepb *= NINDIR(fs); /* XXX */
|
||||
fs->fs_maxfilesize += sizepb; /* XXX */
|
||||
} /* XXX */
|
||||
#endif
|
||||
fs->fs_maxfilesize = (u_quad_t) 1 << 39;
|
||||
fs->fs_qbmask = ~fs->fs_bmask; /* XXX */
|
||||
fs->fs_qfmask = ~fs->fs_fmask; /* XXX */
|
||||
} /* XXX */
|
||||
|
Loading…
x
Reference in New Issue
Block a user