Lines Matching refs:ib
83 static int ntfs_ib_write(ntfs_index_context *icx, INDEX_BLOCK *ib) in ntfs_ib_write() argument
85 s64 ret, vcn = sle64_to_cpu(ib->index_block_vcn); in ntfs_ib_write()
90 1, icx->block_size, ib); in ntfs_ib_write()
102 if (ntfs_ib_write(icx, icx->ib)) in ntfs_icx_ib_write()
155 ntfs_ib_write(icx, icx->ib); in ntfs_index_ctx_free()
157 free(icx->ib); in ntfs_index_ctx_free()
460 int ntfs_index_block_inconsistent(const INDEX_BLOCK *ib, u32 block_size, in ntfs_index_block_inconsistent() argument
463 u32 ib_size = (unsigned)le32_to_cpu(ib->index.allocated_size) in ntfs_index_block_inconsistent()
466 if (!ntfs_is_indx_record(ib->magic)) { in ntfs_index_block_inconsistent()
473 if (sle64_to_cpu(ib->index_block_vcn) != vcn) { in ntfs_index_block_inconsistent()
476 (long long)sle64_to_cpu(ib->index_block_vcn), in ntfs_index_block_inconsistent()
490 if (le32_to_cpu(ib->index.entries_offset) < sizeof(INDEX_HEADER)) { in ntfs_index_block_inconsistent()
495 if (le32_to_cpu(ib->index.index_length) in ntfs_index_block_inconsistent()
496 <= le32_to_cpu(ib->index.entries_offset)) { in ntfs_index_block_inconsistent()
501 if (le32_to_cpu(ib->index.allocated_size) in ntfs_index_block_inconsistent()
502 < le32_to_cpu(ib->index.index_length)) { in ntfs_index_block_inconsistent()
775 INDEX_BLOCK *ib = NULL; in ntfs_index_lookup() local
838 ib = ntfs_malloc(icx->block_size); in ntfs_index_lookup()
839 if (!ib) { in ntfs_index_lookup()
855 if (ntfs_ib_read(icx, vcn, ib)) in ntfs_index_lookup()
858 ret = ntfs_ie_lookup(key, key_len, icx, &ib->index, &vcn, &ie); in ntfs_index_lookup()
866 icx->ib = ib; in ntfs_index_lookup()
871 if ((ib->index.ih_flags & NODE_MASK) == LEAF_NODE) { in ntfs_index_lookup()
886 free(ib); in ntfs_index_lookup()
907 INDEX_BLOCK *ib; in ntfs_ib_alloc() local
912 ib = ntfs_calloc(ib_size); in ntfs_ib_alloc()
913 if (!ib) in ntfs_ib_alloc()
916 ib->magic = magic_INDX; in ntfs_ib_alloc()
917 ib->usa_ofs = const_cpu_to_le16(sizeof(INDEX_BLOCK)); in ntfs_ib_alloc()
918 ib->usa_count = cpu_to_le16(ib_size / NTFS_BLOCK_SIZE + 1); in ntfs_ib_alloc()
920 *(le16 *)((char *)ib + le16_to_cpu(ib->usa_ofs)) = const_cpu_to_le16(1); in ntfs_ib_alloc()
921 ib->lsn = const_cpu_to_sle64(0); in ntfs_ib_alloc()
923 ib->index_block_vcn = cpu_to_sle64(ib_vcn); in ntfs_ib_alloc()
925 ib->index.entries_offset = cpu_to_le32((ih_size + in ntfs_ib_alloc()
926 le16_to_cpu(ib->usa_count) * 2 + 7) & ~7); in ntfs_ib_alloc()
927 ib->index.index_length = const_cpu_to_le32(0); in ntfs_ib_alloc()
928 ib->index.allocated_size = cpu_to_le32(ib_size - in ntfs_ib_alloc()
930 ib->index.ih_flags = node_type; in ntfs_ib_alloc()
932 return ib; in ntfs_ib_alloc()
1094 INDEX_BLOCK *ib; in ntfs_ir_to_ib() local
1101 ib = ntfs_ib_alloc(ib_vcn, le32_to_cpu(ir->index_block_size), LEAF_NODE); in ntfs_ir_to_ib()
1102 if (!ib) in ntfs_ir_to_ib()
1113 memcpy(ntfs_ie_get_first(&ib->index), ies_start, i); in ntfs_ir_to_ib()
1115 ib->index.ih_flags = ir->index.ih_flags; in ntfs_ir_to_ib()
1116 ib->index.index_length = cpu_to_le32(i + in ntfs_ir_to_ib()
1117 le32_to_cpu(ib->index.entries_offset)); in ntfs_ir_to_ib()
1118 return ib; in ntfs_ir_to_ib()
1171 static int ntfs_ib_cut_tail(ntfs_index_context *icx, INDEX_BLOCK *ib, in ntfs_ib_cut_tail() argument
1179 ies_start = (char *)ntfs_ie_get_first(&ib->index); in ntfs_ib_cut_tail()
1180 ies_end = (char *)ntfs_ie_get_end(&ib->index); in ntfs_ib_cut_tail()
1188 ib->index.index_length = cpu_to_le32(((char *)ie - ies_start) + in ntfs_ib_cut_tail()
1189 le16_to_cpu(ie->length) + le32_to_cpu(ib->index.entries_offset)); in ntfs_ib_cut_tail()
1191 if (ntfs_ib_write(icx, ib)) in ntfs_ib_cut_tail()
1225 INDEX_BLOCK *ib = NULL; in ntfs_ir_reparent() local
1248 ib = ntfs_ir_to_ib(ir, new_ib_vcn); in ntfs_ir_reparent()
1249 if (ib == NULL) { in ntfs_ir_reparent()
1254 if (ntfs_ib_write(icx, ib)) in ntfs_ir_reparent()
1305 free(ib); in ntfs_ir_reparent()
1464 static int ntfs_ib_split(ntfs_index_context *icx, INDEX_BLOCK *ib);
1472 INDEX_BLOCK *ib; in ntfs_ib_insert() local
1479 ib = ntfs_malloc(icx->block_size); in ntfs_ib_insert()
1480 if (!ib) in ntfs_ib_insert()
1485 if (ntfs_ib_read(icx, old_vcn, ib)) in ntfs_ib_insert()
1488 idx_size = le32_to_cpu(ib->index.index_length); in ntfs_ib_insert()
1489 allocated_size = le32_to_cpu(ib->index.allocated_size); in ntfs_ib_insert()
1492 err = ntfs_ib_split(icx, ib); in ntfs_ib_insert()
1498 if (ntfs_ih_insert(&ib->index, ie, new_vcn, ntfs_icx_parent_pos(icx))) in ntfs_ib_insert()
1501 if (ntfs_ib_write(icx, ib)) in ntfs_ib_insert()
1506 free(ib); in ntfs_ib_insert()
1516 static int ntfs_ib_split(ntfs_index_context *icx, INDEX_BLOCK *ib) in ntfs_ib_split() argument
1527 median = ntfs_ie_get_median(&ib->index); in ntfs_ib_split()
1532 if (ntfs_ib_copy_tail(icx, ib, median, new_vcn)) { in ntfs_ib_split()
1547 ret = ntfs_ib_cut_tail(icx, ib, median); in ntfs_ib_split()
1583 ih = &icx->ib->index; in ntfs_ie_add()
1598 if (ntfs_ib_split(icx, icx->ib) == STATUS_ERROR) in ntfs_ie_add()
1664 INDEX_ENTRY *ie, INDEX_BLOCK *ib) in ntfs_ih_takeout() argument
1693 if (ntfs_ib_write(icx, ib)) in ntfs_ih_takeout()
1730 INDEX_BLOCK *ib) in ntfs_ih_reparent_end() argument
1741 return ntfs_ih_takeout(icx, ih, ie_prev, ib); in ntfs_ih_reparent_end()
1746 INDEX_BLOCK *ib = NULL; in ntfs_index_rm_leaf() local
1762 ib = ntfs_malloc(icx->block_size); in ntfs_index_rm_leaf()
1763 if (!ib) in ntfs_index_rm_leaf()
1766 if (ntfs_ib_read(icx, ntfs_icx_parent_vcn(icx), ib)) in ntfs_index_rm_leaf()
1769 parent_ih = &ib->index; in ntfs_index_rm_leaf()
1774 ret = ntfs_ih_takeout(icx, parent_ih, ie, ib); in ntfs_index_rm_leaf()
1789 if (ntfs_ih_reparent_end(icx, parent_ih, ib)) in ntfs_index_rm_leaf()
1794 free(ib); in ntfs_index_rm_leaf()
1802 INDEX_BLOCK *ib = NULL; in ntfs_index_rm_node() local
1816 ib = ntfs_malloc(icx->block_size); in ntfs_index_rm_node()
1817 if (!ib) in ntfs_index_rm_node()
1825 if (ntfs_ib_read(icx, vcn, ib)) in ntfs_index_rm_node()
1828 ie_succ = ntfs_ie_get_first(&ib->index); in ntfs_index_rm_node()
1836 if ((ib->index.ih_flags & NODE_MASK) == INDEX_NODE) in ntfs_index_rm_node()
1839 if (ntfs_ih_zero_entry(&ib->index)) { in ntfs_index_rm_node()
1857 ih = &icx->ib->index; in ntfs_index_rm_node()
1872 ret = ntfs_ib_split(icx, icx->ib); in ntfs_index_rm_node()
1889 ntfs_ie_delete(&ib->index, ie_succ); in ntfs_index_rm_node()
1891 if (ntfs_ih_zero_entry(&ib->index)) { in ntfs_index_rm_node()
1895 if (ntfs_ib_write(icx, ib)) in ntfs_index_rm_node()
1902 free(ib); in ntfs_index_rm_node()
1924 if (!icx || (!icx->ib && !icx->ir) || ntfs_ie_end(icx->entry)) { in ntfs_index_rm()
1932 ih = &icx->ib->index; in ntfs_index_rm()
2051 ictx->ib = (INDEX_BLOCK*)ntfs_malloc(ictx->block_size); in ntfs_index_walk_down()
2062 if (!ntfs_ib_read(ictx,vcn,ictx->ib)) { in ntfs_index_walk_down()
2063 ictx->entry = ntfs_ie_get_first(&ictx->ib->index); in ntfs_index_walk_down()
2091 free(ictx->ib); in ntfs_index_walk_up()
2092 ictx->ib = (INDEX_BLOCK*)NULL; in ntfs_index_walk_up()
2109 if (!ntfs_ib_read(ictx,vcn,ictx->ib)) { in ntfs_index_walk_up()
2111 &ictx->ib->index, in ntfs_index_walk_up()