FreeBSD/sbin/fsck_ffs/gjournal.c
/*
 * Free all blocks associated with the given inode.
 */
Free all blocks associated with the given inode.
Free all blocks associated with the given inode .
static void
clear_inode(struct ufs2_dinode *dino)
{
	ufs2_daddr_t bn;
	int extblocks, i, level;
	off_t osize;
	long bsize;
	extblocks = 0;
	if (fs->fs_magic == FS_UFS2_MAGIC && dino->di_extsize > 0)
		extblocks = btodb(fragroundup(fs, dino->di_extsize));
	if (extblocks > 0) {
		osize = dino->di_extsize;
		dino->di_blocks -= extblocks;
		dino->di_extsize = 0;
		for (i = 0; i < NXADDR; i++) {
			if (dino->di_extb[i] == 0)
				continue;
			blkfree(dino->di_extb[i], sblksize(fs, osize, i));
		}
	}
#define	SINGLE	0	/* index of single indirect block */
#define	DOUBLE	1	/* index of double indirect block */
#define	TRIPLE	2	/* index of triple indirect block */
	for (level = SINGLE; level <= TRIPLE; level++) {
		if (dino->di_ib[level] == 0)
			break;
		freeindir(dino->di_ib[level], level);
	}
	for (i = 0; i < NDADDR; i++) {
		bn = dino->di_db[i];
		if (bn == 0)
			continue;
		bsize = dblksize(fs, dino, i);
		blkfree(bn, bsize);
	}
}
static void clear_inode ( struct ufs2_dinode * dino ) { ufs2_daddr_t bn ; int extblocks , i , level ; off_t osize ; long bsize ; extblocks = 0 ; if ( fs -> fs_magic == FS_UFS2_MAGIC && dino -> di_extsize > 0 ) extblocks = btodb ( fragroundup ( fs , dino -> di_extsize ) ) ; if ( extblocks > 0 ) { osize = dino -> di_extsize ; dino -> di_blocks -= extblocks ; dino -> di_extsize = 0 ; for ( i = 0 ; i < NXADDR ; i ++ ) { if ( dino -> di_extb [ i ] == 0 ) continue ; blkfree ( dino -> di_extb [ i ] , sblksize ( fs , osize , i ) ) ; } } #define SINGLE 	0	/* index of single indirect block */ #define DOUBLE 	1	/* index of double indirect block */ #define TRIPLE 	2	/* index of triple indirect block */ for ( level = SINGLE ; level <= TRIPLE ; level ++ ) { if ( dino -> di_ib [ level ] == 0 ) break ; freeindir ( dino -> di_ib [ level ] , level ) ; } for ( i = 0 ; i < NDADDR ; i ++ ) { bn = dino -> di_db [ i ] ; if ( bn == 0 ) continue ; bsize = dblksize ( fs , dino , i ) ; blkfree ( bn , bsize ) ; } }
Free all blocks associated with the given inode.
Free all blocks associated with the given inode .
/* deallocate external attributes blocks */ /* deallocate indirect blocks */ /* deallocate direct blocks and fragments */