⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fsckmeta.c

📁 在Linux内核从2.4升级到2.6时需要升级的软件包
💻 C
📖 第 1 页 / 共 5 页
字号:
				frcam_rc = FSCK_INTERNAL_ERROR_26;				fsck_send_msg(fsck_INTERNALERROR, frcam_rc, 0, 0, 0);			} else if (frcam_rc == FSCK_OK) {				frcam_rc =				    first_ref_check_inode(ino_ptr, ino_idx,							  inorec_ptr,							  msg_info_ptr);			}		} else {			/* couldn't read the inode!			 * (We read it successfully a little while ago)			 */			frcam_rc = FSCK_FAILED_BMAP_READ2;		}	}	if ((frcam_rc == FSCK_OK) && (agg_recptr->unresolved_1stref_count > 0)) {		/* no errors and still have 1st refs to resolve */		/* try for the journal inode */		ino_idx = LOG_I;		frcam_rc =		    inode_get(aggregate_inode, which_ait, ino_idx, &ino_ptr);		if (frcam_rc == FSCK_OK) {			/* got the journal inode */			msg_info_ptr->msg_inonum = ino_idx;			frcam_rc =			    get_inorecptr(aggregate_inode, alloc_ifnull,					  ino_idx, &inorec_ptr);			if ((frcam_rc == FSCK_OK) && (inorec_ptr == NULL)) {				frcam_rc = FSCK_INTERNAL_ERROR_23;				fsck_send_msg(fsck_INTERNALERROR, frcam_rc, 0, 0, 0);			} else if (frcam_rc == FSCK_OK) {				frcam_rc =				    first_ref_check_inode(ino_ptr, ino_idx,							  inorec_ptr,							  msg_info_ptr);			}		} else {			/* couldn't read the inode!			 * (We read it successfully a little while ago)			 */			frcam_rc = FSCK_FAILED_LOG_READ2;		}	}	if ((frcam_rc == FSCK_OK) && (agg_recptr->unresolved_1stref_count > 0)) {		/* no errors and still have 1st refs to resolve */		/* try for the bad block inode */		ino_idx = BADBLOCK_I;		frcam_rc =		    inode_get(aggregate_inode, which_ait, ino_idx, &ino_ptr);		if (frcam_rc == FSCK_OK) {			/* got the bad block inode */			msg_info_ptr->msg_inonum = ino_idx;			frcam_rc =			    get_inorecptr(aggregate_inode, alloc_ifnull,					  ino_idx, &inorec_ptr);			if ((frcam_rc == FSCK_OK) && (inorec_ptr == NULL)) {				frcam_rc = FSCK_INTERNAL_ERROR_58;				fsck_send_msg(fsck_INTERNALERROR, frcam_rc, 0, 0, 0);			} else if (frcam_rc == FSCK_OK) {				frcam_rc =				    first_ref_check_inode(ino_ptr, ino_idx,							  inorec_ptr,							  msg_info_ptr);			}		} else {			/* couldn't read the inode!			 * (We read it successfully a little while ago)			 */			frcam_rc = FSCK_FAILED_BADBLK_READ2;		}	}	/*	 * check ait part 2 inodes for first references	 */	(agg_recptr->primary_ait_4part2) ? (which_ait = fsck_primary)	    : (which_ait = fsck_secondary);	if ((frcam_rc == FSCK_OK) && (agg_recptr->unresolved_1stref_count > 0)) {		/* no errors and still have 1st refs to resolve */		/* read the aggregate inode */		ino_idx = FILESYSTEM_I;		frcam_rc =		    inode_get(aggregate_inode, which_ait, ino_idx, &ino_ptr);		if (frcam_rc == FSCK_OK) {			/* got the fileset inode */			msg_info_ptr->msg_inonum = ino_idx;			frcam_rc =			    get_inorecptr(aggregate_inode, alloc_ifnull,					  ino_idx, &inorec_ptr);			if ((frcam_rc == FSCK_OK) && (inorec_ptr == NULL)) {				frcam_rc = FSCK_INTERNAL_ERROR_28;				fsck_send_msg(fsck_INTERNALERROR, frcam_rc, 0, 0, 0);			} else if (frcam_rc == FSCK_OK) {				frcam_rc =				    first_ref_check_inode(ino_ptr, ino_idx,							  inorec_ptr,							  msg_info_ptr);			}		} else {			/* couldn't read the inode!			 * (We read it successfully a little while ago)			 */			frcam_rc = FSCK_FAILED_AGFS_READ3;		}	}	if ((frcam_rc == FSCK_OK) && (agg_recptr->unresolved_1stref_count > 0)) {		/* no errors and still have 1st refs to resolve */		frcam_rc = first_ref_check_other_ait();	}	return (frcam_rc);}/************************************************************************** * NAME: first_ref_check_fixed_metadata * * FUNCTION: Certain aggregate metadata is not described by any inode. *           This routine determines whether any of the blocks occupied *           by this aggregate are multiply-allocated and still have *           unresolved first reference. * * PARAMETERS:  none * * RETURNS: *      success: FSCK_OK *      failure: something else */int first_ref_check_fixed_metadata(){	int frcfm_rc = FSCK_OK;	int64_t start_block, end_block;	uint32_t length_in_agg_blocks;	int64_t wsp_blocks_described;	/*	 * the reserved space (at the beginning of the aggregate)	 */	start_block = 0;	length_in_agg_blocks = AGGR_RSVD_BYTES / sb_ptr->s_bsize;	end_block = start_block + length_in_agg_blocks - 1;	frcfm_rc = blkall_ref_check(start_block, end_block);	if (frcfm_rc || (agg_recptr->unresolved_1stref_count == 0))		return frcfm_rc;	/*	 * the superblocks	 */	length_in_agg_blocks = SIZE_OF_SUPER / sb_ptr->s_bsize;	/*	 * primary	 */	start_block = SUPER1_OFF / sb_ptr->s_bsize;	end_block = start_block + length_in_agg_blocks - 1;	frcfm_rc = blkall_ref_check(start_block, end_block);	if (frcfm_rc || (agg_recptr->unresolved_1stref_count == 0))		return frcfm_rc;	/*	 * secondary	 */	start_block = SUPER2_OFF / sb_ptr->s_bsize;	end_block = start_block + length_in_agg_blocks - 1;	frcfm_rc = blkall_ref_check(start_block, end_block);	if (frcfm_rc || (agg_recptr->unresolved_1stref_count == 0))		return frcfm_rc;	/*	 * note that the fsck workspace and journal log (at the end of the	 * aggregate) are not described by the block map (neither the	 * Aggregate Block Allocation Map nor the fsck Workspace Block Map)	 */	/*	 * the "phantom blocks" described by the last dmap page	 */	/*	 * the first page is a control page and scratch area.	 */	wsp_blocks_described = BITSPERBYTE *		(agg_recptr->ondev_wsp_byte_length - BYTESPERPAGE);	if (wsp_blocks_described > agg_recptr->sb_agg_fsblk_length) {		/*		 * the dmaps do describe more blocks than		 * actually exist		 */		/* since this is		 * the number of blocks and since blocks are		 * numbered starting at 0, this is the block		 * number of the first phantom block;		 */		start_block = agg_recptr->sb_agg_fsblk_length;		end_block = wsp_blocks_described - 1;		frcfm_rc = blkall_ref_check(start_block, end_block);	}	return (frcfm_rc);}/***************************************************************************** * NAME: first_ref_check_fs_metadata * * FUNCTION: Determine whether any blocks occupied by fileset metadata are *           are multiply-allocated and still have unresolved first *           reference. * * PARAMETERS:  none * * RETURNS: *      success: FSCK_OK *      failure: something else */int first_ref_check_fs_metadata(){	int frcfsm_rc = FSCK_OK;	uint32_t ino_idx;	struct dinode *ino_ptr;	int aggregate_inode = 0;	/* going for fileset inodes only */	int alloc_ifnull = 0;	int which_fsit;		/* which fileset? */	struct fsck_inode_record *inorec_ptr;	struct fsck_ino_msg_info ino_msg_info;	struct fsck_ino_msg_info *msg_info_ptr;	msg_info_ptr = &ino_msg_info;	msg_info_ptr->msg_inopfx = fsck_fset_inode;	/* all fileset owned */	msg_info_ptr->msg_inotyp = fsck_metadata;	/*	 * in release 1 there is exactly 1 fileset	 */	which_fsit = 0;	/* try for the fileset superinode extension */	ino_idx = FILESET_EXT_I;	frcfsm_rc = inode_get(aggregate_inode, which_fsit, ino_idx, &ino_ptr);	if (frcfsm_rc == FSCK_OK) {		/* got the inode  */		msg_info_ptr->msg_inonum = ino_idx;		frcfsm_rc =		    get_inorecptr(aggregate_inode, alloc_ifnull, ino_idx,				  &inorec_ptr);		if ((frcfsm_rc == FSCK_OK) && inorec_ptr) {			frcfsm_rc = first_ref_check_inode(ino_ptr, ino_idx,							  inorec_ptr,							  msg_info_ptr);		}	} else {		/* couldn't read the inode!		 * (We read it successfully a little while ago)		 */		frcfsm_rc = FSCK_FAILED_FSSIEXT_READ2;	}	if ((frcfsm_rc == FSCK_OK) && (agg_recptr->unresolved_1stref_count > 0)) {		/* no errors and still have 1st refs to resolve */		/* try for the root directory inode */		ino_idx = ROOT_I;		frcfsm_rc =		    inode_get(aggregate_inode, which_fsit, ino_idx, &ino_ptr);		if (frcfsm_rc == FSCK_OK) {			/* got the root dir inode */			msg_info_ptr->msg_inonum = ino_idx;			frcfsm_rc =			    get_inorecptr(aggregate_inode, alloc_ifnull,					  ino_idx, &inorec_ptr);			if ((frcfsm_rc == FSCK_OK) && (inorec_ptr == NULL)) {				frcfsm_rc = FSCK_INTERNAL_ERROR_29;				fsck_send_msg(fsck_INTERNALERROR, frcfsm_rc, 0, 0, 0);			} else if (frcfsm_rc == FSCK_OK) {				frcfsm_rc =				    first_ref_check_inode(ino_ptr, ino_idx,							  inorec_ptr,							  msg_info_ptr);			}			if ((frcfsm_rc == FSCK_OK)			    && (inorec_ptr->selected_to_rls)) {				/* routine doesn't				 * understand that the root directory is				 * the special case of a directory which				 * is also special metadata and might				 * flag it for release.				 */				inorec_ptr->selected_to_rls = 0;			}		} else {			/* couldn't read the inode!			 * (We read it successfully a little while ago)			 */			frcfsm_rc = FSCK_FAILED_FSRTDIR_READ2;		}	}	return (frcfsm_rc);}/************************************************************************** * NAME: first_ref_check_other_ait * * FUNCTION: Determine whether any blocks occupied by the "other ait" *           are multiply-allocated and still have unresolved first *           reference.  To be more specific, if the primary ait is *           being used for fsck processing, the secondary ait is the *           "other ait"...and vice versa. * * PARAMETERS:  none * * RETURNS: *      success: FSCK_OK *      failure: something else */int first_ref_check_other_ait(){	int frcoa_rc = FSCK_OK;	int64_t start_block, end_block;	uint32_t length_in_agg_blocks;	/*	 * first extent of the agg inode map	 */	if (agg_recptr->primary_ait_4part1) {		/* primary already recorded */		start_block = addressPXD(&(sb_ptr->s_aim2));		length_in_agg_blocks = lengthPXD(&(sb_ptr->s_aim2));	} else {		/* secondary already recorded */		start_block = AIMAP_OFF / sb_ptr->s_bsize;		length_in_agg_blocks =		    (AITBL_OFF - AIMAP_OFF) / sb_ptr->s_bsize;	}	end_block = start_block + length_in_agg_blocks - 1;	frcoa_rc = blkall_ref_check(start_block, end_block);	/*	 * first extent of the agg inode table	 */	if (agg_recptr->primary_ait_4part1) {		/* primary already recorded */		start_block = addressPXD(&(sb_ptr->s_ait2));		length_in_agg_blocks = lengthPXD(&(sb_ptr->s_ait2));	} else {		/* secondary already recorded */		start_block = AITBL_OFF / sb_ptr->s_bsize;		length_in_agg_blocks = INODE_EXTENT_SIZE / sb_ptr->s_bsize;	}	end_block = start_block + length_in_agg_blocks - 1;	frcoa_rc = blkall_ref_check(start_block, end_block);	return (frcoa_rc);}/***************************************************************************** * NAME: record_ait_part1_again * * FUNCTION:  Record, in the fsck workspace block map, all storage allocated *            to inodes in part 1 (inodes 0 through 15) of the specified *            (primary or secondary) aggregate inode table.  Do this with *            the knowledge that all these inodes have been verified *            completely correct. * * PARAMETERS: *      which_ait  - input - the Aggregate Inode Table on which to perform *                           the function.  { fsck_primary | fsck_secondary } * * NOTES:  o The caller to this routine must ensure that the *           calls made by record_ait_part1_again to inode_get() *           will not require device I/O. *           That is, the caller must ensure that the aggregate *           inode extent containing part1 of the target AIT *           resides in the fsck inode buffer before calling *           this routine.  (See inode_get() for more info) * * RETURNS: *      success: FSCK_OK *      failure: something else */int record_ait_part1_again(int which_ait){	int raitp1a_rc = FSCK_OK;	struct fsck_inode_record *inorecptr;	uint32_t ino_idx;	struct dinode *ino_ptr;	int aggregate_inode = -1;	/* going for aggregate inodes only */	int alloc_ifnull = 0;	struct fsck_ino_msg_info msg_info;	struct fsck_ino_msg_info *msg_info_ptr;	msg_info_ptr = &msg_info;	msg_info_ptr->msg_inopfx = fsck_aggr_inode;	msg_info_ptr->msg_inotyp = fsck_metadata;	/* try for the self inode */	ino_idx = AGGREGATE_I;	msg_info_ptr->msg_inonum = ino_idx;	raitp1a_rc = inode_get(aggregate_inode, which_ait, ino_idx, &ino_ptr);	if (raitp1a_rc == FSCK_OK) {		/* got the self inode  */		agg_recptr->inode_stamp = ino_ptr->di_inostamp;		raitp1a_rc =		    get_inorecptr(aggregate_inode, alloc_ifnull, ino_idx,				  &inorecptr);		if ((raitp1a_rc == FSCK_OK) && (inorecptr == NULL)) {			raitp1a_rc = FSCK_INTERNAL_ERROR_39;			fsck_send_msg(fsck_INTERNALERROR, raitp1a_rc, 0, 0, 0);		} else if (raitp1a_rc == FSCK_OK) {			inorecptr->in_use = 0;			inorecptr->selected_to_rls = 0;			inorecptr->crrct_link_count = 0;			inorecptr->crrct_prnt_inonum = 0;			inorecptr->adj_entries = 0;			inorecptr->cant_chkea = 0;			inorecptr->clr_ea_fld = 0;			inorecptr->clr_acl_fld = 0;			inorecptr->inlineea_on = 0;			inorecptr->inlineea_off = 0;			inorecptr->inline_data_err = 0;			inorecptr->ignore_alloc_blks = 0;			inorecptr->reconnect = 0;			inorecptr->unxpctd_prnts = 0;			inorecptr->badblk_inode = 0;			inorecptr->involved_in_dups = 0;			inorecptr->inode_type = metadata_inode;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -