FreeBSD/sbin/fsck_ffs/gjournal.c
/*
 * Recursively free all indirect blocks.
 */
Recursively free all indirect blocks.
Recursively free all indirect blocks .
static void
freeindir(ufs2_daddr_t blk, int level)
{
	char sblks[MAXBSIZE];
	ufs2_daddr_t *blks;
	int i;
	if (bread(disk, fsbtodb(fs, blk), (void *)&sblks, (size_t)fs->fs_bsize) == -1)
		err(1, "bread: %s", disk->d_error);
	blks = (ufs2_daddr_t *)&sblks;
	for (i = 0; i < NINDIR(fs); i++) {
		if (blks[i] == 0)
			break;
		if (level == 0)
			blkfree(blks[i], fs->fs_bsize);
		else
			freeindir(blks[i], level - 1);
	}
	blkfree(blk, fs->fs_bsize);
}
static void freeindir ( ufs2_daddr_t blk , int level ) { char sblks [ MAXBSIZE ] ; ufs2_daddr_t * blks ; int i ; if ( bread ( disk , fsbtodb ( fs , blk ) , ( void * ) & sblks , ( size_t ) fs -> fs_bsize ) == -1 ) err ( 1 , " " , disk -> d_error ) ; blks = ( ufs2_daddr_t * ) & sblks ; for ( i = 0 ; i < NINDIR ( fs ) ; i ++ ) { if ( blks [ i ] == 0 ) break ; if ( level == 0 ) blkfree ( blks [ i ] , fs -> fs_bsize ) ; else freeindir ( blks [ i ] , level - 1 ) ; } blkfree ( blk , fs -> fs_bsize ) ; }
Recursively free all indirect blocks.
Recursively free all indirect blocks .