after blocks are free (for the cleaner)
SCCS-vsn: sys/ufs/lfs/lfs_inode.c 7.76
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)lfs_inode.c 7.75 (Berkeley) %G%
+ * @(#)lfs_inode.c 7.76 (Berkeley) %G%
*/
#include <sys/param.h>
*/
#include <sys/param.h>
#define UPDATE_SEGUSE \
if (lastseg != -1) { \
LFS_SEGENTRY(sup, fs, lastseg, sup_bp); \
#define UPDATE_SEGUSE \
if (lastseg != -1) { \
LFS_SEGENTRY(sup, fs, lastseg, sup_bp); \
+ if ((num << fs->lfs_bshift) > sup->su_nbytes) \
+ panic("lfs_truncate: negative bytes in segment %d\n", \
+ lastseg); \
sup->su_nbytes -= num << fs->lfs_bshift; \
LFS_UBWRITE(sup_bp); \
blocksreleased += num; \
sup->su_nbytes -= num << fs->lfs_bshift; \
LFS_UBWRITE(sup_bp); \
blocksreleased += num; \
- /* If truncating the file to 0, update the version number. */
- if (length == 0) {
- LFS_IENTRY(ifp, fs, ip->i_number, bp);
- ++ifp->if_version;
- LFS_UBWRITE(bp);
- }
-
/* If length is larger than the file, just update the times. */
if (ip->i_size <= length) {
ip->i_flag |= ICHG|IUPD;
/* If length is larger than the file, just update the times. */
if (ip->i_size <= length) {
ip->i_flag |= ICHG|IUPD;
+
+ /* If truncating the file to 0, update the version number. */
+ if (length == 0) {
+ LFS_IENTRY(ifp, fs, ip->i_number, bp);
+ ++ifp->if_version;
+ LFS_UBWRITE(bp);
+ }
+
ip->i_blocks -= btodb(blocksreleased << fs->lfs_bshift);
fs->lfs_bfree += btodb(blocksreleased << fs->lfs_bshift);
#ifdef DIAGNOSTIC
ip->i_blocks -= btodb(blocksreleased << fs->lfs_bshift);
fs->lfs_bfree += btodb(blocksreleased << fs->lfs_bshift);
#ifdef DIAGNOSTIC