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

📄 fsckwsp.c

📁 在Linux内核从2.4升级到2.6时需要升级的软件包
💻 C
📖 第 1 页 / 共 5 页
字号:
 *      first_block  - input - ordinal number of the first filesystem block *      last_block  - input - ordinal number of the last filesystem block * * NOTES:  The duplicate allocation list is described in the aggregate record, *         field: dup_alloc_lst * * RETURNS: *      success: record found *      failure: NULL */struct dupall_blkrec *dupall_find_blkrec(int64_t first_block,					 int64_t last_block){	struct dupall_blkrec *this_blkrec;	for (this_blkrec = agg_recptr->dup_alloc_lst;	     this_blkrec && this_blkrec->first_blk <= last_block;	     this_blkrec = this_blkrec->next) {		if (this_blkrec->last_blk >= first_block)			return this_blkrec;	}	return NULL;}/**************************************************************************** * NAME: dupall_get_blkrec * * FUNCTION: Allocates workspace storage for a duplicate allocation *           block record. * * PARAMETERS: *      none * * RETURNS: *      success: address of record *      failure: NULL */struct dupall_blkrec *dupall_get_blkrec(void){	struct dupall_blkrec *addr_blkrec_ptr;	int dgb_rc = FSCK_OK;	if (agg_recptr->free_dupall_blkrec != NULL) {		/* free list isn't empty */		addr_blkrec_ptr = agg_recptr->free_dupall_blkrec;		agg_recptr->free_dupall_blkrec = addr_blkrec_ptr->next;	} else {		/* else the free list is empty */		dgb_rc = alloc_wrksp(dupall_blkrec_length, dynstg_dupall_blkrec,				     0, (void **) &addr_blkrec_ptr);	}	if (dgb_rc == FSCK_OK)		return addr_blkrec_ptr;	return NULL;}/***************************************************************************** * NAME: dupall_insert_blkrec * * FUNCTION: Allocate a duplicate allocation record for the given blocks and *           insert it into the sorted, doubly-linked list of duplicate *           allocation records. * * PARAMETERS: *      first_block - input - the first block number for which the record is *                            to be allocated. *      last_block - input - the last block number for which the record is *                           to be allocated. * * NOTES:  The duplicate allocation list is described in the aggregate record, *         field: dup_alloc_lst * * RETURNS: *      success: FSCK_OK *      failure: something else */int dupall_insert_blkrec(int64_t first_block, int64_t last_block,			 struct dupall_blkrec **blkrec){	struct dupall_blkrec *new_blkrec;	struct dupall_blkrec *prev_blkrec;	struct dupall_blkrec *this_blkrec;	int dib_done = 0;	new_blkrec = dupall_get_blkrec();	if (new_blkrec == NULL)		return FSCK_FAILED_DYNSTG_EXHAUST1;	if (blkrec)		*blkrec = new_blkrec;	/* got a block record */	new_blkrec->first_blk = first_block;	new_blkrec->last_blk = last_block;	new_blkrec->owner_count = 2;	if (agg_recptr->dup_alloc_lst == NULL) {		/* list now empty */		new_blkrec->next = NULL;		new_blkrec->prev = NULL;		agg_recptr->dup_alloc_lst = new_blkrec;		return FSCK_OK;	}	/* list not empty */	if (agg_recptr->dup_alloc_lst->first_blk > first_block) {		/*		 * goes at front		 */		new_blkrec->next = agg_recptr->dup_alloc_lst;		new_blkrec->prev = NULL;		agg_recptr->dup_alloc_lst = new_blkrec;		return FSCK_OK;	}	/* doesn't go at the front */	prev_blkrec = agg_recptr->dup_alloc_lst;	this_blkrec = agg_recptr->dup_alloc_lst->next;	while (!dib_done) {		if (this_blkrec == NULL) {			/* goes at the end */			new_blkrec->next = NULL;			new_blkrec->prev = prev_blkrec;			prev_blkrec->next = new_blkrec;			dib_done = 1;		} else if (this_blkrec->first_blk > first_block) {			/*			 * goes in front of this one			 */			new_blkrec->next = this_blkrec;			new_blkrec->prev = prev_blkrec;			prev_blkrec->next = new_blkrec;			this_blkrec->prev = new_blkrec;			dib_done = 1;		} else {			/* try the next one */			prev_blkrec = this_blkrec;			this_blkrec = this_blkrec->next;		}	}	return FSCK_OK;}/**************************************************************************** * NAME: establish_agg_workspace * * FUNCTION: Obtain storage for and initialize the fsck aggregate workspace. * * PARAMETERS:  none * * NOTES: The various parts of the workspace are described in the aggregate *        record. * * RETURNS: *      success: FSCK_OK *      failure: something else */int establish_agg_workspace(){	int eaw_rc = FSCK_OK;	uint32_t mapsize_bytes;	int I_am_logredo = 0;	/*	 * establish the fsck workspace block map	 */	eaw_rc = establish_wsp_block_map();	if (eaw_rc == FSCK_OK) {		/* block map has been established */		agg_recptr->agg_imap.num_iags = 1;		agg_recptr->agg_imap.bkd_inodes = INOSPEREXT;		agg_recptr->agg_imap.unused_bkd_inodes = INOSPEREXT - 4;		/* in release 1 there is always		 * exactly one extent of inodes allocated		 * for the aggregate		 */		agg_recptr->inode_count = INOSPEREXT;		/*		 * now establish the fsck aggregate imap workspace		 */		mapsize_bytes =		    agg_recptr->agg_imap.num_iags *		    sizeof (struct fsck_iag_record);		eaw_rc =		    alloc_wrksp(mapsize_bytes, dynstg_agg_iagtbl, I_am_logredo,				(void **) &(agg_recptr->agg_imap.iag_tbl));		if (eaw_rc == FSCK_OK) {			/* AIM workspace established */			/*			 * now establish the fsck aggregate inode table workspace			 *			 * (since there is always exactly one inode extent, we don't			 * bother with an IAG table of pointers to extent address tables			 * or with an extent address table of pointers to inode record			 * address tables.)			 */			eaw_rc =			    alloc_wrksp(inode_tbl_length, dynstg_ait_inotbl,					I_am_logredo,					(void **) &(agg_recptr->AIT_ext0_tbl));			memcpy((void *) &(agg_recptr->AIT_ext0_tbl->eyecatcher),			       (void *) "InodeTbl", 8);		}	}	return (eaw_rc);}/**************************************************************************** * NAME: establish_ea_iobuf * * FUNCTION: 	Make use of the VeryLarge Multi-Use Buffer *		for reading and validating EA data. * * PARAMETERS:  none * * NOTES:  	The ea I/O buffer is the only user of the VeryLarge Buffer *		during Phase 1 processing. * * RETURNS: *      success: FSCK_OK *      failure: something else */int establish_ea_iobuf(){	int eei_rc = FSCK_OK;	agg_recptr->vlarge_current_use = USED_FOR_EA_BUF;	agg_recptr->ea_buf_ptr = agg_recptr->vlarge_buf_ptr;	wsp_dynstg_action = dynstg_initialization;	memset((void *) (agg_recptr->ea_buf_ptr), '\0', EA_IO_BUFSIZE);	agg_recptr->ea_buf_length = agg_recptr->vlarge_buf_length;	agg_recptr->ea_buf_data_len = 0;	agg_recptr->ea_agg_offset = 0;	return (eei_rc);}/**************************************************************************** * NAME: establish_fs_workspace * * FUNCTION: Obtain storage for and initialize the fsck file sets workspace. * * PARAMETERS:  none * * NOTES: The various parts of the workspace are described in the aggregate *        record. * * RETURNS: *      success: FSCK_OK *      failure: something else */int establish_fs_workspace(){	int efsw_rc = FSCK_OK;	uint32_t mapsize_bytes;	uint32_t buffer_size;	int aggregate_inode, which_ait = 0;	uint32_t inoidx;	struct dinode *inoptr;	int I_am_logredo = 0;	struct IAG_tbl_t *IAGtbl;	struct inode_ext_tbl_t *inoexttbl;	struct inode_tbl_t *inotbl;	/*	 * allocate a buffer in which path names can be constructed	 */	buffer_size = (JFS_PATH_MAX + 2) * sizeof (char);	efsw_rc = alloc_wrksp(buffer_size, dynstg_fsit_map,			      I_am_logredo,			      (void **) &(agg_recptr->path_buffer));	if (efsw_rc == FSCK_OK) {		/* got it */		agg_recptr->path_buffer_length = buffer_size;		/*		 * Figure out how many IAGs have been allocated for the fileset.		 * (Note that in release 1 there is always exactly 1 fileset in the		 * aggregate)		 *		 * At this point the aggregate inode describing the fileset has been		 * validated.  The data described by that inode is 1 page of control		 * information plus some number of IAGs.  di_size is the number of		 * bytes allocated for that data.		 */		if (agg_recptr->primary_ait_4part2) {			which_ait = fsck_primary;			efsw_rc = ait_special_read_ext1(fsck_primary);			if (efsw_rc != FSCK_OK) {				/* read failed */				report_readait_error(efsw_rc,						     FSCK_FAILED_CANTREADAITEXTC,						     fsck_primary);				efsw_rc = FSCK_FAILED_CANTREADAITEXTC;			}		} else {			which_ait = fsck_secondary;			efsw_rc = ait_special_read_ext1(fsck_secondary);			if (efsw_rc != FSCK_OK) {				/* read failed */				report_readait_error(efsw_rc,						     FSCK_FAILED_CANTREADAITEXTD,						     fsck_secondary);				efsw_rc = FSCK_FAILED_CANTREADAITEXTD;			}		}	}	if (efsw_rc != FSCK_OK)		goto efsw_exit;	/* got the first AIT extent */	aggregate_inode = -1;	inoidx = FILESYSTEM_I;	efsw_rc = inode_get(aggregate_inode, which_ait, inoidx, &inoptr);	if (efsw_rc != FSCK_OK)		goto efsw_exit;	/* got the fileset IT inode */	agg_recptr->fset_imap.num_iags =	    (inoptr->di_size / SIZE_OF_MAP_PAGE) - 1;	/*	 * a high estimate of the inodes	 * allocated for the fileset	 */	agg_recptr->fset_inode_count =	    agg_recptr->fset_imap.num_iags * INOSPERIAG;	/*	 * now establish the fsck fileset imap workspace	 */	if (efsw_rc != FSCK_OK)		goto efsw_exit;	/* inode map established */	mapsize_bytes = agg_recptr->fset_imap.num_iags *	    sizeof (struct fsck_iag_record);	efsw_rc = alloc_wrksp(mapsize_bytes, dynstg_agg_iagtbl, I_am_logredo,			      (void **) &(agg_recptr->fset_imap.iag_tbl));	if (efsw_rc != FSCK_OK)		goto efsw_exit;	/* inode map workspace allocated */	/*	 * now establish the fsck fileset imap workspace	 *	 * We start out knowing that IAG 0, extent 0 is allocated and	 * has an inode in use.  We'll allocate enough to cover that.	 */	mapsize_bytes = 8 + agg_recptr->fset_imap.num_iags *	    sizeof (struct inode_ext_tbl_t *);	efsw_rc = alloc_wrksp(mapsize_bytes, dynstg_fsit_iagtbl,			      I_am_logredo, (void **) &IAGtbl);	if (efsw_rc != FSCK_OK)		goto efsw_exit;	/* we got the IAG table */	memcpy((void *)&(IAGtbl->eyecatcher), (void *) "FSAITIAG", 8);	agg_recptr->FSIT_IAG_tbl = IAGtbl;	efsw_rc = alloc_wrksp(inode_ext_tbl_length, dynstg_fsit_inoexttbl,			      I_am_logredo, (void **) &inoexttbl);	if (efsw_rc != FSCK_OK)		goto efsw_exit;	/* we got the inode extent table */	memcpy((void *)&(inoexttbl->eyecatcher), (void *)"FSAITEXT", 8);	IAGtbl->inoext_tbl[0] = inoexttbl;	efsw_rc = alloc_wrksp(inode_tbl_length, dynstg_fsit_inotbl,			      I_am_logredo, (void **) &inotbl);	if (efsw_rc == FSCK_OK) {		/* we got the inode table */		memcpy((void *)&(inotbl->eyecatcher), (void *)"FSAITINO", 8);		inoexttbl->inotbl[0] = inotbl;	}      efsw_exit:	return (efsw_rc);}/**************************************************************************** * NAME: establish_io_buffers * * FUNCTION:  Allocate storage for dedicated I/O buffers. * * PARAMETERS:  none * * NOTES:  The I/O buffers are described in the aggregate record. * * RETURNS: *      success: FSCK_OK *      failure: something else */int establish_io_buffers(){	int eiob_rc = FSCK_OK;	int I_am_logredo = 0;	eiob_rc = alloc_wrksp(IAG_IO_BUFSIZE, dynstg_iobufs,			      I_am_logredo,			      (void **) &(agg_recptr->iag_buf_ptr));	if (eiob_rc == FSCK_OK) {		/* successful IAG allocation */		agg_recptr->iag_buf_length = sizeof (struct iag);		agg_recptr->iag_buf_data_len = 0;		agg_recptr->iag_agg_offset = 0;		agg_recptr->iag_buf_write = 0;		agg_recptr->bmapdm_buf_ptr = agg_recptr->iag_buf_ptr;		agg_recptr->bmapdm_buf_length = IAG_IO_BUFSIZE;		agg_recptr->bmapdm_buf_data_len = 0;		agg_recptr->bmapdm_agg_offset = 0;		agg_recptr->bmapdm_buf_write = 0;	}	if (eiob_rc == FSCK_OK) {

⌨️ 快捷键说明

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