Lines Matching refs:ie
194 static leVCN *ntfs_ie_get_vcn_addr(INDEX_ENTRY *ie) in ntfs_ie_get_vcn_addr() argument
196 return (leVCN *)((u8 *)ie + le16_to_cpu(ie->length) - sizeof(leVCN)); in ntfs_ie_get_vcn_addr()
202 VCN ntfs_ie_get_vcn(INDEX_ENTRY *ie) in ntfs_ie_get_vcn() argument
204 return sle64_to_cpup(ntfs_ie_get_vcn_addr(ie)); in ntfs_ie_get_vcn()
212 static INDEX_ENTRY *ntfs_ie_get_next(INDEX_ENTRY *ie) in ntfs_ie_get_next() argument
214 return (INDEX_ENTRY *)((char *)ie + le16_to_cpu(ie->length)); in ntfs_ie_get_next()
223 static int ntfs_ie_end(INDEX_ENTRY *ie) in ntfs_ie_end() argument
225 return ie->ie_flags & INDEX_ENTRY_END || !ie->length; in ntfs_ie_end()
231 static INDEX_ENTRY *ntfs_ie_get_last(INDEX_ENTRY *ie, char *ies_end) in ntfs_ie_get_last() argument
235 while ((char *)ie < ies_end && !ntfs_ie_end(ie)) in ntfs_ie_get_last()
236 ie = ntfs_ie_get_next(ie); in ntfs_ie_get_last()
238 return ie; in ntfs_ie_get_last()
243 INDEX_ENTRY *ie; in ntfs_ie_get_by_pos() local
247 ie = ntfs_ie_get_first(ih); in ntfs_ie_get_by_pos()
250 ie = ntfs_ie_get_next(ie); in ntfs_ie_get_by_pos()
252 return ie; in ntfs_ie_get_by_pos()
255 static INDEX_ENTRY *ntfs_ie_prev(INDEX_HEADER *ih, INDEX_ENTRY *ie) in ntfs_ie_prev() argument
264 while (tmp != ie) { in ntfs_ie_prev()
272 char *ntfs_ie_filename_get(INDEX_ENTRY *ie) in ntfs_ie_filename_get() argument
276 fn = (FILE_NAME_ATTR *)&ie->key; in ntfs_ie_filename_get()
280 void ntfs_ie_filename_dump(INDEX_ENTRY *ie) in ntfs_ie_filename_dump() argument
284 s = ntfs_ie_filename_get(ie); in ntfs_ie_filename_dump()
291 INDEX_ENTRY *ie; in ntfs_ih_filename_dump() local
295 ie = ntfs_ie_get_first(ih); in ntfs_ih_filename_dump()
296 while (!ntfs_ie_end(ie)) { in ntfs_ih_filename_dump()
297 ntfs_ie_filename_dump(ie); in ntfs_ih_filename_dump()
298 ie = ntfs_ie_get_next(ie); in ntfs_ih_filename_dump()
305 INDEX_ENTRY *ie; in ntfs_ih_numof_entries() local
311 ie = ntfs_ie_get_first(ih); in ntfs_ih_numof_entries()
312 for (n = 0; !ntfs_ie_end(ie) && (u8 *)ie < end; n++) in ntfs_ih_numof_entries()
313 ie = ntfs_ie_get_next(ie); in ntfs_ih_numof_entries()
327 static void ntfs_ie_delete(INDEX_HEADER *ih, INDEX_ENTRY *ie) in ntfs_ie_delete() argument
333 new_size = le32_to_cpu(ih->index_length) - le16_to_cpu(ie->length); in ntfs_ie_delete()
335 memmove(ie, (u8 *)ie + le16_to_cpu(ie->length), in ntfs_ie_delete()
336 new_size - ((u8 *)ie - (u8 *)ih)); in ntfs_ie_delete()
339 static void ntfs_ie_set_vcn(INDEX_ENTRY *ie, VCN vcn) in ntfs_ie_set_vcn() argument
341 *ntfs_ie_get_vcn_addr(ie) = cpu_to_sle64(vcn); in ntfs_ie_set_vcn()
347 static void ntfs_ie_insert(INDEX_HEADER *ih, INDEX_ENTRY *ie, INDEX_ENTRY *pos) in ntfs_ie_insert() argument
349 int ie_size = le16_to_cpu(ie->length); in ntfs_ie_insert()
356 memcpy(pos, ie, ie_size); in ntfs_ie_insert()
359 static INDEX_ENTRY *ntfs_ie_dup(INDEX_ENTRY *ie) in ntfs_ie_dup() argument
365 dup = ntfs_malloc(le16_to_cpu(ie->length)); in ntfs_ie_dup()
367 memcpy(dup, ie, le16_to_cpu(ie->length)); in ntfs_ie_dup()
372 static INDEX_ENTRY *ntfs_ie_dup_novcn(INDEX_ENTRY *ie) in ntfs_ie_dup_novcn() argument
375 int size = le16_to_cpu(ie->length); in ntfs_ie_dup_novcn()
379 if (ie->ie_flags & INDEX_ENTRY_NODE) in ntfs_ie_dup_novcn()
384 memcpy(dup, ie, size); in ntfs_ie_dup_novcn()
525 int ntfs_index_entry_inconsistent(const INDEX_ENTRY *ie, in ntfs_index_entry_inconsistent() argument
531 if (ie->key_length in ntfs_index_entry_inconsistent()
532 && ((le16_to_cpu(ie->key_length) + offsetof(INDEX_ENTRY, key)) in ntfs_index_entry_inconsistent()
533 > le16_to_cpu(ie->length))) { in ntfs_index_entry_inconsistent()
541 + ie->key.file_name.file_name_length in ntfs_index_entry_inconsistent()
543 > le16_to_cpu(ie->length)) { in ntfs_index_entry_inconsistent()
550 if (ie->data_length in ntfs_index_entry_inconsistent()
551 && ((le16_to_cpu(ie->data_offset) in ntfs_index_entry_inconsistent()
552 + le16_to_cpu(ie->data_length)) in ntfs_index_entry_inconsistent()
553 > le16_to_cpu(ie->length))) { in ntfs_index_entry_inconsistent()
579 INDEX_ENTRY *ie; in ntfs_ie_lookup() local
591 for (ie = ntfs_ie_get_first(ih); ; ie = ntfs_ie_get_next(ie)) { in ntfs_ie_lookup()
593 if ((u8 *)ie + sizeof(INDEX_ENTRY_HEADER) > index_end || in ntfs_ie_lookup()
594 (u8 *)ie + le16_to_cpu(ie->length) > index_end) { in ntfs_ie_lookup()
605 if (ntfs_ie_end(ie)) in ntfs_ie_lookup()
617 if (ntfs_index_entry_inconsistent(ie, icx->ir->collation_rule, in ntfs_ie_lookup()
623 &ie->key, le16_to_cpu(ie->key_length)); in ntfs_ie_lookup()
639 *ie_out = ie; in ntfs_ie_lookup()
652 if (!(ie->ie_flags & INDEX_ENTRY_NODE)) { in ntfs_ie_lookup()
654 *ie_out = ie; in ntfs_ie_lookup()
660 *vcn = ntfs_ie_get_vcn(ie); in ntfs_ie_lookup()
774 INDEX_ENTRY *ie; in ntfs_index_lookup() local
816 ret = ntfs_ie_lookup(key, key_len, icx, &ir->index, &vcn, &ie); in ntfs_index_lookup()
858 ret = ntfs_ie_lookup(key, key_len, icx, &ib->index, &vcn, &ie); in ntfs_index_lookup()
892 icx->entry = ie; in ntfs_index_lookup()
893 icx->data = (u8 *)ie + offsetof(INDEX_ENTRY, key); in ntfs_index_lookup()
894 icx->data_len = le16_to_cpu(ie->key_length); in ntfs_index_lookup()
940 INDEX_ENTRY *ie, *ie_start; in ntfs_ie_get_median() local
946 ie = ie_start = ntfs_ie_get_first(ih); in ntfs_ie_get_median()
949 while ((u8 *)ie < ie_end && !ntfs_ie_end(ie)) { in ntfs_ie_get_median()
950 ie = ntfs_ie_get_next(ie); in ntfs_ie_get_median()
960 for (i = 0, ie = ie_start; i <= median; i++) in ntfs_ie_get_median()
961 ie = ntfs_ie_get_next(ie); in ntfs_ie_get_median()
963 return ie; in ntfs_ie_get_median()
1172 INDEX_ENTRY *ie) in ntfs_ib_cut_tail() argument
1184 ntfs_ie_set_vcn(ie_last, ntfs_ie_get_vcn(ie)); in ntfs_ib_cut_tail()
1186 memcpy(ie, ie_last, le16_to_cpu(ie_last->length)); 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()
1224 INDEX_ENTRY *ie; in ntfs_ir_reparent() local
1264 ie = ntfs_ie_get_first(&ir->index); in ntfs_ir_reparent()
1265 ie->ie_flags |= INDEX_ENTRY_NODE; in ntfs_ir_reparent()
1266 ie->length = const_cpu_to_le16(sizeof(INDEX_ENTRY_HEADER) + sizeof(VCN)); in ntfs_ir_reparent()
1270 + le16_to_cpu(ie->length)); in ntfs_ir_reparent()
1301 ntfs_ie_set_vcn(ie, new_ib_vcn); in ntfs_ir_reparent()
1379 static int ntfs_ie_add_vcn(INDEX_ENTRY **ie) in ntfs_ie_add_vcn() argument
1381 INDEX_ENTRY *p, *old = *ie; in ntfs_ie_add_vcn()
1389 *ie = p; in ntfs_ie_add_vcn()
1397 INDEX_ENTRY *ie_node, *ie; in ntfs_ih_insert() local
1403 ie = ntfs_ie_dup(orig_ie); in ntfs_ih_insert()
1404 if (!ie) in ntfs_ih_insert()
1407 if (!(ie->ie_flags & INDEX_ENTRY_NODE)) in ntfs_ih_insert()
1408 if (ntfs_ie_add_vcn(&ie)) in ntfs_ih_insert()
1415 ntfs_ie_insert(ih, ie, ie_node); in ntfs_ih_insert()
1419 free(ie); in ntfs_ih_insert()
1470 static int ntfs_ib_insert(ntfs_index_context *icx, INDEX_ENTRY *ie, VCN new_vcn) in ntfs_ib_insert() argument
1491 if (idx_size + le16_to_cpu(ie->length) + sizeof(VCN) > allocated_size) { in ntfs_ib_insert()
1498 if (ntfs_ih_insert(&ib->index, ie, new_vcn, ntfs_icx_parent_pos(icx))) in ntfs_ib_insert()
1553 int ntfs_ie_add(ntfs_index_context *icx, INDEX_ENTRY *ie) in ntfs_ie_add() argument
1570 if (!ntfs_index_lookup(&ie->key, le16_to_cpu(ie->key_length), icx)) { in ntfs_ie_add()
1586 new_size = le32_to_cpu(ih->index_length) + le16_to_cpu(ie->length); in ntfs_ie_add()
1606 ntfs_ie_insert(ih, ie, icx->entry); in ntfs_ie_add()
1625 INDEX_ENTRY *ie; in ntfs_index_add_filename() local
1641 ie = ntfs_calloc(ie_size); in ntfs_index_add_filename()
1642 if (!ie) in ntfs_index_add_filename()
1645 ie->indexed_file = cpu_to_le64(mref); in ntfs_index_add_filename()
1646 ie->length = cpu_to_le16(ie_size); in ntfs_index_add_filename()
1647 ie->key_length = cpu_to_le16(fn_size); in ntfs_index_add_filename()
1648 memcpy(&ie->key, fn, fn_size); in ntfs_index_add_filename()
1654 ret = ntfs_ie_add(icx, ie); in ntfs_index_add_filename()
1659 free(ie); in ntfs_index_add_filename()
1664 INDEX_ENTRY *ie, INDEX_BLOCK *ib) in ntfs_ih_takeout() argument
1674 ie_roam = ntfs_ie_dup_novcn(ie); in ntfs_ih_takeout()
1678 ntfs_ie_delete(ih, ie); in ntfs_ih_takeout()
1710 INDEX_ENTRY *ie; in ntfs_ir_leafify() local
1714 ie = ntfs_ie_get_first(ih); in ntfs_ir_leafify()
1715 ie->ie_flags &= ~INDEX_ENTRY_NODE; in ntfs_ir_leafify()
1716 ie->length = cpu_to_le16(le16_to_cpu(ie->length) - sizeof(VCN)); in ntfs_ir_leafify()
1732 INDEX_ENTRY *ie, *ie_prev; in ntfs_ih_reparent_end() local
1736 ie = ntfs_ie_get_by_pos(ih, ntfs_icx_parent_pos(icx)); in ntfs_ih_reparent_end()
1737 ie_prev = ntfs_ie_prev(ih, ie); in ntfs_ih_reparent_end()
1739 ntfs_ie_set_vcn(ie, ntfs_ie_get_vcn(ie_prev)); in ntfs_ih_reparent_end()
1748 INDEX_ENTRY *ie; in ntfs_index_rm_leaf() local
1772 ie = ntfs_ie_get_by_pos(parent_ih, ntfs_icx_parent_pos(icx)); in ntfs_index_rm_leaf()
1773 if (!ntfs_ie_end(ie)) { in ntfs_index_rm_leaf()
1774 ret = ntfs_ih_takeout(icx, parent_ih, ie, ib); in ntfs_index_rm_leaf()
1803 INDEX_ENTRY *ie_succ, *ie, *entry = icx->entry; in ntfs_index_rm_node() local
1845 ie = ntfs_ie_dup(ie_succ); in ntfs_index_rm_node()
1846 if (!ie) in ntfs_index_rm_node()
1849 if (ntfs_ie_add_vcn(&ie)) in ntfs_index_rm_node()
1852 ntfs_ie_set_vcn(ie, ntfs_ie_get_vcn(icx->entry)); in ntfs_index_rm_node()
1859 delta = le16_to_cpu(ie->length) - le16_to_cpu(icx->entry->length); in ntfs_index_rm_node()
1880 ntfs_ie_insert(ih, ie, entry); in ntfs_index_rm_node()
1900 free(ie); in ntfs_index_rm_node()
2037 static INDEX_ENTRY *ntfs_index_walk_down(INDEX_ENTRY *ie, in ntfs_index_walk_down() argument
2043 entry = ie; in ntfs_index_walk_down()
2077 static INDEX_ENTRY *ntfs_index_walk_up(INDEX_ENTRY *ie, in ntfs_index_walk_up() argument
2083 entry = ie; in ntfs_index_walk_up()
2151 INDEX_ENTRY *ntfs_index_next(INDEX_ENTRY *ie, ntfs_index_context *ictx) in ntfs_index_next() argument
2162 if (ie->ie_flags & INDEX_ENTRY_END) in ntfs_index_next()
2163 next = ntfs_index_walk_up(ie, ictx); in ntfs_index_next()
2170 next = (INDEX_ENTRY*)((char*)ie + le16_to_cpu(ie->length)); in ntfs_index_next()