fsckxtre.c
来自「在Linux内核从2.4升级到2.6时需要升级的软件包」· C语言 代码 · 共 1,473 行 · 第 1/4 页
C
1,473 行
if ((highidx == lowidx) || ((highidx - lowidx) == 1)) { /* at most 1 apart */ if (given_offset < offsetXAD(&xtpg_ptr->xad[highidx])) { *selected_idx = lowidx; *xad_selected = -1; } else { *selected_idx = highidx; *xad_selected = -1; } } else { /* far enough apart to continue algorithm */ mididx = ((highidx - lowidx) >> 1) + lowidx; this_offset = offsetXAD(&(xtpg_ptr->xad[mididx])); if (given_offset == this_offset) { /* it's a match */ *selected_idx = mididx; *xad_selected = -1; } else if (given_offset < this_offset) { /* this one is greater */ if (given_offset > offsetXAD(&(xtpg_ptr->xad[mididx - 1]))) { /* the one before this one is less */ *selected_idx = mididx - 1; *xad_selected = -1; } else { /* the one before is not less */ /* reset the range */ highidx = mididx; } } else { /* this one is less */ if (given_offset < offsetXAD(&(xtpg_ptr->xad[mididx + 1]))) { /* the one after this one is greater */ *selected_idx = mididx; *xad_selected = -1; } else { /* the one after is not greater */ /* reset the range */ lowidx = mididx; } } } } return (xbp_rc);}/***************************************************************************** * NAME: xTree_node_first_key * * FUNCTION: Helper routine for xTree_processing * * PARAMETERS: * xtiptr - input - pointer to an fsck record describing the * xTree * inorecptr - input - pointer to the fsck inode record describing * the inode in which the xTree is rooted * msg_info_ptr - input - pointer to data needed for messages about * the inode in which the xTree is rooted * desired_action - input - { FSCK_RECORD | FSCK_RECORD_DUPCHECK | * FSCK_UNRECORD | FSCK_QUERY } * * RETURNS: * success: FSCK_OK * failure: something else */int xTree_node_first_key(struct fsck_Xtree_info *xtiptr, struct fsck_inode_record *inorecptr, struct fsck_ino_msg_info *msg_info_ptr, int desired_action){ int xnfk_rc = FSCK_OK; /* * the key in the 1st xad must match the key in the parent * node's xad describing this node */ if (xtiptr->this_Qel->node_first_offset && (xtiptr->this_key != xtiptr->this_Qel->node_first_offset)) { /* invalid key in 1st xad */ inorecptr->ignore_alloc_blks = 1; if (desired_action == FSCK_RECORD_DUPCHECK) { /* not reported yet */ fsck_send_msg(fsck_BADKEYS, fsck_ref_msg(msg_info_ptr->msg_inotyp), fsck_ref_msg(msg_info_ptr->msg_inopfx), msg_info_ptr->msg_inonum, 5); } goto out; } /* 1st xad might be ok */ if (xtiptr->last_level != xtiptr->this_Qel->node_level) goto out; /* not 1st in level */ if ((xtiptr->dense_file) && (xtiptr->xtp_ptr->header.flag & BT_LEAF)) { /* a leaf node in a dense file */ if (xtiptr->this_key != (xtiptr->last_key + 1)) { /* a gap in a dense file */ inorecptr->ignore_alloc_blks = 1; if (desired_action == FSCK_RECORD_DUPCHECK) { /* not reported yet */ fsck_send_msg(fsck_BADINOINTERNGAP, fsck_ref_msg(msg_info_ptr->msg_inopfx), msg_info_ptr->msg_inonum, (long long) xtiptr->last_key); } } } else { /* not a leaf node in a dense file */ if (xtiptr->this_key <= xtiptr->last_key) { /* the extents overlap! */ inorecptr->ignore_alloc_blks = 1; if (desired_action == FSCK_RECORD_DUPCHECK) { /* not reported yet */ fsck_send_msg(fsck_BADKEYS, fsck_ref_msg(msg_info_ptr->msg_inotyp), fsck_ref_msg(msg_info_ptr->msg_inopfx), msg_info_ptr->msg_inonum, 6); } } } out: return (xnfk_rc);}/***************************************************************************** * NAME: xTree_node_first_in_level * * FUNCTION: Helper routine for xTree_processing * * PARAMETERS: * xtiptr - input - pointer to an fsck record describing the * xTree * inorecptr - input - pointer to the fsck inode record describing * the inode in which the xTree is rooted * msg_info_ptr - input - pointer to data needed for messages about * the inode in which the xTree is rooted * desired_action - input - { FSCK_RECORD | FSCK_RECORD_DUPCHECK | * FSCK_UNRECORD | FSCK_QUERY } * * RETURNS: * success: FSCK_OK * failure: something else */int xTree_node_first_in_level(struct fsck_Xtree_info *xtiptr, struct fsck_inode_record *inorecptr, struct fsck_ino_msg_info *msg_info_ptr, int desired_action){ int xnfil_rc = FSCK_OK; if (xtiptr->xtp_ptr->header.prev != 0) { /* bad back ptr! */ inorecptr->ignore_alloc_blks = 1; if (desired_action == FSCK_RECORD_DUPCHECK) { /* not reported yet */ fsck_send_msg(fsck_BADBSBLCHN, fsck_ref_msg(msg_info_ptr->msg_inotyp), fsck_ref_msg(msg_info_ptr->msg_inopfx), msg_info_ptr->msg_inonum); } } return (xnfil_rc);}/***************************************************************************** * NAME: xTree_node_last_in_level * * FUNCTION: Helper routine for xTree_processing * * PARAMETERS: * xtiptr - input - pointer to an fsck record describing the * xTree * inorecptr - input - pointer to the fsck inode record describing * the inode in which the xTree is rooted * msg_info_ptr - input - pointer to data needed for messages about * the inode in which the xTree is rooted * desired_action - input - { FSCK_RECORD | FSCK_RECORD_DUPCHECK | * FSCK_UNRECORD | FSCK_QUERY } * * RETURNS: * success: FSCK_OK * failure: something else */int xTree_node_last_in_level(struct fsck_Xtree_info *xtiptr, struct fsck_inode_record *inorecptr, struct fsck_ino_msg_info *msg_info_ptr, int desired_action){ int xnlil_rc = FSCK_OK; if (xtiptr->xtp_ptr->header.next != 0) { /* bad forward ptr! */ inorecptr->ignore_alloc_blks = 1; if (desired_action == FSCK_RECORD_DUPCHECK) { /* not reported yet */ fsck_send_msg(fsck_BADFSBLCHN, fsck_ref_msg(msg_info_ptr->msg_inotyp), fsck_ref_msg(msg_info_ptr->msg_inopfx), msg_info_ptr->msg_inonum); } } return (xnlil_rc);}/***************************************************************************** * NAME: xTree_node_not_first_in_level * * FUNCTION: Helper routine for xTree_processing * * PARAMETERS: * xtiptr - input - pointer to an fsck record describing the * xTree * inorecptr - input - pointer to the fsck inode record describing * the inode in which the xTree is rooted * msg_info_ptr - input - pointer to data needed for messages about * the inode in which the xTree is rooted * desired_action - input - { FSCK_RECORD | FSCK_RECORD_DUPCHECK | * FSCK_UNRECORD | FSCK_QUERY } * * RETURNS: * success: FSCK_OK * failure: something else */int xTree_node_not_first_in_level(struct fsck_Xtree_info *xtiptr, struct fsck_inode_record *inorecptr, struct fsck_ino_msg_info *msg_info_ptr, int desired_action){ int xnnfil_rc = FSCK_OK; if (xtiptr->xtp_ptr->header.prev != xtiptr->last_node_addr) { /* bad back ptr! */ inorecptr->ignore_alloc_blks = 1; if (desired_action == FSCK_RECORD_DUPCHECK) { /* not reported yet */ fsck_send_msg(fsck_BADBSBLCHN, fsck_ref_msg(msg_info_ptr->msg_inotyp), fsck_ref_msg(msg_info_ptr->msg_inopfx), msg_info_ptr->msg_inonum); } } return (xnnfil_rc);}/***************************************************************************** * NAME: xTree_node_not_last_in_level * * FUNCTION: Helper routine for xTree_processing * * PARAMETERS: * xtiptr - input - pointer to an fsck record describing the * xTree * inorecptr - input - pointer to the fsck inode record describing * the inode in which the xTree is rooted * msg_info_ptr - input - pointer to data needed for messages about * the inode in which the xTree is rooted * desired_action - input - { FSCK_RECORD | FSCK_RECORD_DUPCHECK | * FSCK_UNRECORD | FSCK_QUERY } * * RETURNS: * success: FSCK_OK * failure: something else */int xTree_node_not_last_in_level(struct fsck_Xtree_info *xtiptr, struct fsck_inode_record *inorecptr, struct fsck_ino_msg_info *msg_info_ptr, int desired_action){ int xnnlil_rc = FSCK_OK; if (xtiptr->xtp_ptr->header.next != xtiptr->next_Qel->node_addr) { /* bad forward ptr! */ inorecptr->ignore_alloc_blks = 1; if (desired_action == FSCK_RECORD_DUPCHECK) { /* not reported yet */ fsck_send_msg(fsck_BADFSBLCHN, fsck_ref_msg(msg_info_ptr->msg_inotyp), fsck_ref_msg(msg_info_ptr->msg_inopfx), msg_info_ptr->msg_inonum); } } else { /* forward sibling pointer is correct */ if (xtiptr->this_Qel->last_ext_uneven) { /* last extent described * by this node is not an even number of * 4096 pages but it can't be the last extent * allocated to the inode */ inorecptr->ignore_alloc_blks = 1; if (desired_action == FSCK_RECORD_DUPCHECK) { /* not reported yet */ xtiptr->xad_ptr = &(xtiptr-> xtp_ptr->xad[xtiptr->xtp_ptr->header. nextindex - 1]); xtiptr->this_key = offsetXAD(xtiptr->xad_ptr); xtiptr->ext_length = lengthXAD(xtiptr->xad_ptr); fsck_send_msg(fsck_BADINOODDINTRNEXT, fsck_ref_msg(msg_info_ptr->msg_inotyp), fsck_ref_msg(msg_info_ptr->msg_inopfx), msg_info_ptr->msg_inonum, (long long) xtiptr->this_key, xtiptr->ext_length); } } } return (xnnlil_rc);}/***************************************************************************** * NAME: xTree_process_internal_extents * * FUNCTION: Helper routine for xTree_processing * * PARAMETERS: * xtpg_ptr - input - pointer to the internal node in an fsck * buffer * ino_recptr - input - pointer to the fsck inode record describing * the inode in which the xTree is rooted * Q_elptr - input - address of an fsck Q element pointer * describing the internal node * msg_info_ptr - input - pointer to data needed for messages about * the inode in which the xTree is rooted * desired_action - input - { FSCK_RECORD | FSCK_RECORD_DUPCHECK | * FSCK_UNRECORD | FSCK_QUERY } * * RETURNS: * success: FSCK_OK * failure: something else */int xTree_process_internal_extents(xtpage_t * xtpg_ptr, struct fsck_inode_record *ino_recptr, struct treeQelem *Q_elptr, struct fsck_ino_msg_info *msg_info_ptr, int desired_action){ int xpie_rc = FSCK_OK; int64_t last_key, this_key; uint32_t xadidx; struct treeQelem *new_Qelptr; uint32_t ext_length, adjusted_length; int64_t ext_addr; int8_t ext_ok; int8_t is_EA = 0; int8_t is_ACL = 0; xad_t *xad_ptr; uint8_t flag_mask; flag_mask = ~(XAD_NEW | XAD_EXTENDED | XAD_COMPRESSED | XAD_NOTRECORDED | XAD_COW); last_key = -1; for (xadidx = XTENTRYSTART; ((xadidx < xtpg_ptr->header.nextindex) && (xpie_rc == FSCK_OK) && (!ino_recptr->ignore_alloc_blks)); xadidx++) { xad_ptr = &(xtpg_ptr->xad[xadidx]);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?