useful-e2fsck-files/first-look-here/super.c
static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino,
				struct ext2_inode *inode, char *block_buf,
				struct problem_context *pctx)
{
	struct process_block_struct 	pb;
	ext2_filsys			fs = ctx->fs;
	errcode_t			retval;
	__u32				count;

	if (!ext2fs_inode_has_valid_blocks2(fs, inode))
		return 0;

	pb.buf = block_buf + 3 * ctx->fs->blocksize;
	pb.ctx = ctx;
	pb.abort = 0;
	pb.errcode = 0;
	pb.pctx = pctx;
	if (inode->i_links_count) {
		pb.truncating = 1;
		pb.truncate_block = (e2_blkcnt_t)
			((EXT2_I_SIZE(inode) + fs->blocksize - 1) /
			 fs->blocksize);
		pb.truncate_offset = inode->i_size % fs->blocksize;
	} else {
		pb.truncating = 0;
		pb.truncate_block = 0;
		pb.truncate_offset = 0;
	}
	pb.truncated_blocks = 0;
	retval = ext2fs_block_iterate3(fs, ino, BLOCK_FLAG_DEPTH_TRAVERSE,
				      block_buf, release_inode_block, &pb);
	if (retval) {
		com_err("release_inode_blocks", retval,
			_("while calling ext2fs_block_iterate for inode %d"),
			ino);
		return 1;
	}
	if (pb.abort)
		return 1;

	/* Refresh the inode since ext2fs_block_iterate may have changed it */
	e2fsck_read_inode(ctx, ino, inode, "release_inode_blocks");

	if (pb.truncated_blocks)
		ext2fs_iblk_sub_blocks(fs, inode, pb.truncated_blocks);

	if (ext2fs_file_acl_block(fs, inode)) {
		retval = ext2fs_adjust_ea_refcount2(fs,
					ext2fs_file_acl_block(fs, inode),
					block_buf, -1, &count);
		if (retval == EXT2_ET_BAD_EA_BLOCK_NUM) {
			retval = 0;
			count = 1;
		}
		if (retval) {
			com_err("release_inode_blocks", retval,
		_("while calling ext2fs_adjust_ea_refcount2 for inode %d"),
				ino);
			return 1;
		}
		if (count == 0) {
			ext2fs_block_alloc_stats2(fs,
					ext2fs_file_acl_block(fs, inode), -1);
			ctx->free_blocks++;
		}
		ext2fs_file_acl_block_set(fs, inode, 0);
	}
	return 0;
}
/*
 * This function releases an inode.  Returns 1 if an inconsistency was
 * found.  If the inode has a link count, then it is being truncated and
 * not deleted.
 */
This function releases an inode.  Returns 1 if an inconsistency was
found.  If the inode has a link count, then it is being truncated and
not deleted.
This function releases an inode . Returns 1 if an inconsistency was found . If the inode has a link count then it is being truncated and not deleted .
static int release_inode_blocks(e2fsck_t ctx, ext2_ino_t ino,
				struct ext2_inode *inode, char *block_buf,
				struct problem_context *pctx)
{
	struct process_block_struct 	pb;
	ext2_filsys			fs = ctx->fs;
	errcode_t			retval;
	__u32				count;
	if (!ext2fs_inode_has_valid_blocks2(fs, inode))
		return 0;
	pb.buf = block_buf + 3 * ctx->fs->blocksize;
	pb.ctx = ctx;
	pb.abort = 0;
	pb.errcode = 0;
	pb.pctx = pctx;
	if (inode->i_links_count) {
		pb.truncating = 1;
		pb.truncate_block = (e2_blkcnt_t)
			((EXT2_I_SIZE(inode) + fs->blocksize - 1) /
			 fs->blocksize);
		pb.truncate_offset = inode->i_size % fs->blocksize;
	} else {
		pb.truncating = 0;
		pb.truncate_block = 0;
		pb.truncate_offset = 0;
	}
	pb.truncated_blocks = 0;
	retval = ext2fs_block_iterate3(fs, ino, BLOCK_FLAG_DEPTH_TRAVERSE,
				      block_buf, release_inode_block, &pb);
	if (retval) {
		com_err("release_inode_blocks", retval,
			_("while calling ext2fs_block_iterate for inode %d"),
			ino);
		return 1;
	}
	if (pb.abort)
		return 1;
	e2fsck_read_inode(ctx, ino, inode, "release_inode_blocks");
	if (pb.truncated_blocks)
		ext2fs_iblk_sub_blocks(fs, inode, pb.truncated_blocks);
	if (ext2fs_file_acl_block(fs, inode)) {
		retval = ext2fs_adjust_ea_refcount2(fs,
					ext2fs_file_acl_block(fs, inode),
					block_buf, -1, &count);
		if (retval == EXT2_ET_BAD_EA_BLOCK_NUM) {
			retval = 0;
			count = 1;
		}
		if (retval) {
			com_err("release_inode_blocks", retval,
		_("while calling ext2fs_adjust_ea_refcount2 for inode %d"),
				ino);
			return 1;
		}
		if (count == 0) {
			ext2fs_block_alloc_stats2(fs,
					ext2fs_file_acl_block(fs, inode), -1);
			ctx->free_blocks++;
		}
		ext2fs_file_acl_block_set(fs, inode, 0);
	}
	return 0;
}
static int release_inode_blocks ( e2fsck_t ctx , ext2_ino_t ino , struct ext2_inode * inode , char * block_buf , struct problem_context * pctx ) { struct process_block_struct pb ; ext2_filsys fs = ctx -> fs ; errcode_t retval ; __u32 count ; if ( ! ext2fs_inode_has_valid_blocks2 ( fs , inode ) ) return 0 ; pb . buf = block_buf + 3 * ctx -> fs -> blocksize ; pb . ctx = ctx ; pb . abort = 0 ; pb . errcode = 0 ; pb . pctx = pctx ; if ( inode -> i_links_count ) { pb . truncating = 1 ; pb . truncate_block = ( e2_blkcnt_t ) ( ( EXT2_I_SIZE ( inode ) + fs -> blocksize - 1 ) / fs -> blocksize ) ; pb . truncate_offset = inode -> i_size % fs -> blocksize ; } else { pb . truncating = 0 ; pb . truncate_block = 0 ; pb . truncate_offset = 0 ; } pb . truncated_blocks = 0 ; retval = ext2fs_block_iterate3 ( fs , ino , BLOCK_FLAG_DEPTH_TRAVERSE , block_buf , release_inode_block , & pb ) ; if ( retval ) { com_err ( " " , retval , _ ( " " ) , ino ) ; return 1 ; } if ( pb . abort ) return 1 ; e2fsck_read_inode ( ctx , ino , inode , " " ) ; if ( pb . truncated_blocks ) ext2fs_iblk_sub_blocks ( fs , inode , pb . truncated_blocks ) ; if ( ext2fs_file_acl_block ( fs , inode ) ) { retval = ext2fs_adjust_ea_refcount2 ( fs , ext2fs_file_acl_block ( fs , inode ) , block_buf , -1 , & count ) ; if ( retval == EXT2_ET_BAD_EA_BLOCK_NUM ) { retval = 0 ; count = 1 ; } if ( retval ) { com_err ( " " , retval , _ ( " " ) , ino ) ; return 1 ; } if ( count == 0 ) { ext2fs_block_alloc_stats2 ( fs , ext2fs_file_acl_block ( fs , inode ) , -1 ) ; ctx -> free_blocks ++ ; } ext2fs_file_acl_block_set ( fs , inode , 0 ) ; } return 0 ; }
This function releases an inode.
This function releases an inode .
/* Refresh the inode since ext2fs_block_iterate may have changed it */