Lines Matching refs:ni
59 ntfs_inode *ntfs_inode_base(ntfs_inode *ni) in ntfs_inode_base() argument
61 if (ni->nr_extents == -1) in ntfs_inode_base()
62 return ni->base_ni; in ntfs_inode_base()
63 return ni; in ntfs_inode_base()
76 void ntfs_inode_mark_dirty(ntfs_inode *ni) in ntfs_inode_mark_dirty() argument
78 NInoSetDirty(ni); in ntfs_inode_mark_dirty()
79 if (ni->nr_extents == -1) in ntfs_inode_mark_dirty()
80 NInoSetDirty(ni->base_ni); in ntfs_inode_mark_dirty()
93 ntfs_inode *ni; in __ntfs_inode_allocate() local
95 ni = (ntfs_inode*)ntfs_calloc(sizeof(ntfs_inode)); in __ntfs_inode_allocate()
96 if (ni) in __ntfs_inode_allocate()
97 ni->vol = vol; in __ntfs_inode_allocate()
98 return ni; in __ntfs_inode_allocate()
122 static void __ntfs_inode_release(ntfs_inode *ni) in __ntfs_inode_release() argument
124 if (NInoDirty(ni)) in __ntfs_inode_release()
126 (long long)ni->mft_no); in __ntfs_inode_release()
127 if (NInoAttrList(ni) && ni->attr_list) in __ntfs_inode_release()
128 free(ni->attr_list); in __ntfs_inode_release()
129 free(ni->mrec); in __ntfs_inode_release()
130 free(ni); in __ntfs_inode_release()
160 ntfs_inode *ni = NULL; in ntfs_inode_real_open() local
171 ni = __ntfs_inode_allocate(vol); in ntfs_inode_real_open()
172 if (!ni) in ntfs_inode_real_open()
174 if (ntfs_file_record_read(vol, mref, &ni->mrec, NULL)) in ntfs_inode_real_open()
176 if (!(ni->mrec->flags & MFT_RECORD_IN_USE)) { in ntfs_inode_real_open()
180 ni->mft_no = MREF(mref); in ntfs_inode_real_open()
181 ctx = ntfs_attr_get_search_ctx(ni, NULL); in ntfs_inode_real_open()
187 if (!ni->mrec->base_mft_record) in ntfs_inode_real_open()
201 ni->flags = std_info->file_attributes; in ntfs_inode_real_open()
202 ni->creation_time = std_info->creation_time; in ntfs_inode_real_open()
203 ni->last_data_change_time = std_info->last_data_change_time; in ntfs_inode_real_open()
204 ni->last_mft_change_time = std_info->last_mft_change_time; in ntfs_inode_real_open()
205 ni->last_access_time = std_info->last_access_time; in ntfs_inode_real_open()
209 set_nino_flag(ni, v3_Extensions); in ntfs_inode_real_open()
210 ni->owner_id = std_info->owner_id; in ntfs_inode_real_open()
211 ni->security_id = std_info->security_id; in ntfs_inode_real_open()
212 ni->quota_charged = std_info->quota_charged; in ntfs_inode_real_open()
213 ni->usn = std_info->usn; in ntfs_inode_real_open()
215 clear_nino_flag(ni, v3_Extensions); in ntfs_inode_real_open()
216 ni->owner_id = const_cpu_to_le32(0); in ntfs_inode_real_open()
217 ni->security_id = const_cpu_to_le32(0); in ntfs_inode_real_open()
230 NInoSetAttrList(ni); in ntfs_inode_real_open()
240 ni->attr_list_size = l; in ntfs_inode_real_open()
241 ni->attr_list = ntfs_malloc(ni->attr_list_size); in ntfs_inode_real_open()
242 if (!ni->attr_list) in ntfs_inode_real_open()
244 l = ntfs_get_attribute_value(vol, ctx->attr, ni->attr_list); in ntfs_inode_real_open()
247 if (l != ni->attr_list_size) { in ntfs_inode_real_open()
250 "%lld", (long long)l, ni->attr_list_size, in ntfs_inode_real_open()
262 ni->data_size = ni->allocated_size = 0; in ntfs_inode_real_open()
265 ni->data_size = sle64_to_cpu(ctx->attr->data_size); in ntfs_inode_real_open()
268 ni->allocated_size = sle64_to_cpu( in ntfs_inode_real_open()
271 ni->allocated_size = sle64_to_cpu( in ntfs_inode_real_open()
274 ni->data_size = le32_to_cpu(ctx->attr->value_length); in ntfs_inode_real_open()
275 ni->allocated_size = (ni->data_size + 7) & ~7; in ntfs_inode_real_open()
277 set_nino_flag(ni,KnownSize); in ntfs_inode_real_open()
282 return ni; in ntfs_inode_real_open()
287 __ntfs_inode_release(ni); in ntfs_inode_real_open()
288 ni = NULL; in ntfs_inode_real_open()
317 int ntfs_inode_real_close(ntfs_inode *ni) in ntfs_inode_real_close() argument
321 if (!ni) in ntfs_inode_real_close()
324 ntfs_log_enter("Entering for inode %lld\n", (long long)ni->mft_no); in ntfs_inode_real_close()
327 if (NInoDirty(ni) || NInoAttrListDirty(ni)) { in ntfs_inode_real_close()
328 if (ntfs_inode_sync(ni)) { in ntfs_inode_real_close()
335 if (ni->nr_extents > 0) { in ntfs_inode_real_close()
336 while (ni->nr_extents > 0) { in ntfs_inode_real_close()
337 if (ntfs_inode_real_close(ni->extent_nis[0])) { in ntfs_inode_real_close()
343 } else if (ni->nr_extents == -1) { in ntfs_inode_real_close()
352 base_ni = ni->base_ni; in ntfs_inode_real_close()
355 if (tmp_nis[i] != ni) in ntfs_inode_real_close()
392 (long long)ni->mft_no); in ntfs_inode_real_close()
395 __ntfs_inode_release(ni); in ntfs_inode_real_close()
411 ntfs_inode_real_close(((const struct CACHED_NIDATA*)cached)->ni); in ntfs_inode_nidata_free()
446 item.ni = (ntfs_inode*)NULL; in ntfs_inode_invalidate()
467 ntfs_inode *ni; in ntfs_inode_open() local
480 ni = cached->ni; in ntfs_inode_open()
485 ni = ntfs_inode_real_open(vol, mref); in ntfs_inode_open()
487 if (!ni) { in ntfs_inode_open()
491 ni = ntfs_inode_real_open(vol, mref); in ntfs_inode_open()
493 return (ni); in ntfs_inode_open()
506 int ntfs_inode_close(ntfs_inode *ni) in ntfs_inode_close() argument
513 if (ni) { in ntfs_inode_close()
514 debug_double_inode(ni->mft_no,0); in ntfs_inode_close()
516 if (ni->vol && ni->vol->nidata_cache in ntfs_inode_close()
517 && ((ni->mft_no == FILE_root) in ntfs_inode_close()
518 || ((ni->mft_no >= FILE_first_user) in ntfs_inode_close()
519 && !(ni->mrec->flags & MFT_RECORD_IS_4)))) { in ntfs_inode_close()
521 dirty = NInoDirty(ni) || NInoAttrListDirty(ni); in ntfs_inode_close()
523 res = ntfs_inode_sync(ni); in ntfs_inode_close()
526 ntfs_inode_real_close(ni); in ntfs_inode_close()
532 item.inum = ni->mft_no; in ntfs_inode_close()
533 item.ni = ni; in ntfs_inode_close()
536 debug_cached_inode(ni); in ntfs_inode_close()
537 ntfs_enter_cache(ni->vol->nidata_cache, in ntfs_inode_close()
542 res = ntfs_inode_real_close(ni); in ntfs_inode_close()
547 res = ntfs_inode_real_close(ni); in ntfs_inode_close()
583 ntfs_inode *ni = NULL; in ntfs_extent_inode_open() local
623 ni = (ntfs_inode*)NULL; in ntfs_extent_inode_open()
634 ni = extent_nis[i]; in ntfs_extent_inode_open()
635 if (mft_no != ni->mft_no) in ntfs_extent_inode_open()
640 ni->mrec->sequence_number)) { in ntfs_extent_inode_open()
644 (long long)ni->mft_no); in ntfs_extent_inode_open()
651 ni = __ntfs_inode_allocate(base_ni->vol); in ntfs_extent_inode_open()
652 if (!ni) in ntfs_extent_inode_open()
654 if (ntfs_file_record_read(base_ni->vol, le64_to_cpu(mref), &ni->mrec, NULL)) in ntfs_extent_inode_open()
656 ni->mft_no = mft_no; in ntfs_extent_inode_open()
657 ni->nr_extents = -1; in ntfs_extent_inode_open()
658 ni->base_ni = base_ni; in ntfs_extent_inode_open()
673 base_ni->extent_nis[base_ni->nr_extents++] = ni; in ntfs_extent_inode_open()
676 return ni; in ntfs_extent_inode_open()
678 __ntfs_inode_release(ni); in ntfs_extent_inode_open()
679 ni = NULL; in ntfs_extent_inode_open()
689 int ntfs_inode_attach_all_extents(ntfs_inode *ni) in ntfs_inode_attach_all_extents() argument
694 if (!ni) { in ntfs_inode_attach_all_extents()
700 if (ni->nr_extents == -1) in ntfs_inode_attach_all_extents()
701 ni = ni->base_ni; in ntfs_inode_attach_all_extents()
703 ntfs_log_trace("Entering for inode 0x%llx.\n", (long long) ni->mft_no); in ntfs_inode_attach_all_extents()
706 if (!NInoAttrList(ni)) in ntfs_inode_attach_all_extents()
709 if (!ni->attr_list) { in ntfs_inode_attach_all_extents()
717 ale = (ATTR_LIST_ENTRY *)ni->attr_list; in ntfs_inode_attach_all_extents()
718 while ((u8*)ale < ni->attr_list + ni->attr_list_size) { in ntfs_inode_attach_all_extents()
719 if (ni->mft_no != MREF_LE(ale->mft_reference) && in ntfs_inode_attach_all_extents()
721 if (!ntfs_extent_inode_open(ni, ale->mft_reference)) { in ntfs_inode_attach_all_extents()
738 static int ntfs_inode_sync_standard_information(ntfs_inode *ni) in ntfs_inode_sync_standard_information() argument
745 ntfs_log_trace("Entering for inode %lld\n", (long long)ni->mft_no); in ntfs_inode_sync_standard_information()
747 ctx = ntfs_attr_get_search_ctx(ni, NULL); in ntfs_inode_sync_standard_information()
753 (long long)ni->mft_no); in ntfs_inode_sync_standard_information()
759 std_info->file_attributes = ni->flags; in ntfs_inode_sync_standard_information()
760 if (!test_nino_flag(ni, TimesSet)) { in ntfs_inode_sync_standard_information()
761 std_info->creation_time = ni->creation_time; in ntfs_inode_sync_standard_information()
762 std_info->last_data_change_time = ni->last_data_change_time; in ntfs_inode_sync_standard_information()
763 std_info->last_mft_change_time = ni->last_mft_change_time; in ntfs_inode_sync_standard_information()
764 std_info->last_access_time = ni->last_access_time; in ntfs_inode_sync_standard_information()
771 if (test_nino_flag(ni, v3_Extensions) in ntfs_inode_sync_standard_information()
776 std_info->owner_id = ni->owner_id; in ntfs_inode_sync_standard_information()
777 std_info->security_id = ni->security_id; in ntfs_inode_sync_standard_information()
778 std_info->quota_charged = ni->quota_charged; in ntfs_inode_sync_standard_information()
779 std_info->usn = ni->usn; in ntfs_inode_sync_standard_information()
794 static int ntfs_inode_sync_file_name(ntfs_inode *ni, ntfs_inode *dir_ni) in ntfs_inode_sync_file_name() argument
805 ntfs_log_trace("Entering for inode %lld\n", (long long)ni->mft_no); in ntfs_inode_sync_file_name()
807 ctx = ntfs_attr_get_search_ctx(ni, NULL); in ntfs_inode_sync_file_name()
814 if (ni->flags & FILE_ATTR_REPARSE_POINT) { in ntfs_inode_sync_file_name()
827 if (MREF_LE(fn->parent_directory) == ni->mft_no) { in ntfs_inode_sync_file_name()
835 index_ni = ni; in ntfs_inode_sync_file_name()
840 index_ni = ntfs_inode_open(ni->vol, in ntfs_inode_sync_file_name()
855 if ((ni != index_ni) && !dir_ni in ntfs_inode_sync_file_name()
870 if (ni != index_ni && ntfs_inode_close(index_ni) && !err) in ntfs_inode_sync_file_name()
878 (ni->flags & FILE_ATTR_VALID_FLAGS); in ntfs_inode_sync_file_name()
879 if (ni->mrec->flags & MFT_RECORD_IS_DIRECTORY) in ntfs_inode_sync_file_name()
883 fnx->allocated_size = cpu_to_sle64(ni->allocated_size); in ntfs_inode_sync_file_name()
884 fnx->data_size = cpu_to_sle64(ni->data_size); in ntfs_inode_sync_file_name()
894 if (!test_nino_flag(ni, TimesSet)) { in ntfs_inode_sync_file_name()
895 fnx->creation_time = ni->creation_time; in ntfs_inode_sync_file_name()
896 fnx->last_data_change_time = ni->last_data_change_time; in ntfs_inode_sync_file_name()
897 fnx->last_mft_change_time = ni->last_mft_change_time; in ntfs_inode_sync_file_name()
898 fnx->last_access_time = ni->last_access_time; in ntfs_inode_sync_file_name()
907 if ((ni != index_ni) && !dir_ni in ntfs_inode_sync_file_name()
915 (long long)ni->mft_no); in ntfs_inode_sync_file_name()
950 static int ntfs_inode_sync_in_dir(ntfs_inode *ni, ntfs_inode *dir_ni) in ntfs_inode_sync_in_dir() argument
954 if (!ni) { in ntfs_inode_sync_in_dir()
960 ntfs_log_enter("Entering for inode %lld\n", (long long)ni->mft_no); in ntfs_inode_sync_in_dir()
963 if ((ni->mrec->flags & MFT_RECORD_IN_USE) && ni->nr_extents != -1 && in ntfs_inode_sync_in_dir()
964 ntfs_inode_sync_standard_information(ni)) { in ntfs_inode_sync_in_dir()
973 if ((ni->mrec->flags & MFT_RECORD_IN_USE) && ni->nr_extents != -1 && in ntfs_inode_sync_in_dir()
974 NInoFileNameTestAndClearDirty(ni) && in ntfs_inode_sync_in_dir()
975 ntfs_inode_sync_file_name(ni, dir_ni)) { in ntfs_inode_sync_in_dir()
982 (long long)ni->mft_no); in ntfs_inode_sync_in_dir()
983 NInoFileNameSetDirty(ni); in ntfs_inode_sync_in_dir()
987 if ((ni->mrec->flags & MFT_RECORD_IN_USE) && ni->nr_extents != -1 && in ntfs_inode_sync_in_dir()
988 NInoAttrList(ni) && NInoAttrListTestAndClearDirty(ni)) { in ntfs_inode_sync_in_dir()
991 na = ntfs_attr_open(ni, AT_ATTRIBUTE_LIST, AT_UNNAMED, 0); in ntfs_inode_sync_in_dir()
999 (long long)ni->mft_no); in ntfs_inode_sync_in_dir()
1001 NInoAttrListSetDirty(ni); in ntfs_inode_sync_in_dir()
1005 if (na->data_size == ni->attr_list_size) { in ntfs_inode_sync_in_dir()
1006 if (ntfs_attr_pwrite(na, 0, ni->attr_list_size, in ntfs_inode_sync_in_dir()
1007 ni->attr_list) != ni->attr_list_size) { in ntfs_inode_sync_in_dir()
1014 (long long)ni->mft_no); in ntfs_inode_sync_in_dir()
1016 NInoAttrListSetDirty(ni); in ntfs_inode_sync_in_dir()
1021 "inode %lld)\n", (long long)ni->mft_no); in ntfs_inode_sync_in_dir()
1022 NInoAttrListSetDirty(ni); in ntfs_inode_sync_in_dir()
1029 if (NInoTestAndClearDirty(ni)) { in ntfs_inode_sync_in_dir()
1030 if (ntfs_mft_record_write(ni->vol, ni->mft_no, ni->mrec)) { in ntfs_inode_sync_in_dir()
1036 NInoSetDirty(ni); in ntfs_inode_sync_in_dir()
1038 (long long)ni->mft_no); in ntfs_inode_sync_in_dir()
1043 if (ni->nr_extents > 0) { in ntfs_inode_sync_in_dir()
1046 for (i = 0; i < ni->nr_extents; ++i) { in ntfs_inode_sync_in_dir()
1049 eni = ni->extent_nis[i]; in ntfs_inode_sync_in_dir()
1063 (long long)ni->mft_no, in ntfs_inode_sync_in_dir()
1078 int ntfs_inode_sync(ntfs_inode *ni) in ntfs_inode_sync() argument
1080 return (ntfs_inode_sync_in_dir(ni, (ntfs_inode*)NULL)); in ntfs_inode_sync()
1087 int ntfs_inode_close_in_dir(ntfs_inode *ni, ntfs_inode *dir_ni) in ntfs_inode_close_in_dir() argument
1091 res = ntfs_inode_sync_in_dir(ni, dir_ni); in ntfs_inode_close_in_dir()
1096 res = ntfs_inode_close(ni); in ntfs_inode_close_in_dir()
1111 int ntfs_inode_add_attrlist(ntfs_inode *ni) in ntfs_inode_add_attrlist() argument
1120 if (!ni) { in ntfs_inode_add_attrlist()
1126 ntfs_log_trace("inode %llu\n", (unsigned long long) ni->mft_no); in ntfs_inode_add_attrlist()
1128 if (NInoAttrList(ni) || ni->nr_extents) { in ntfs_inode_add_attrlist()
1135 ctx = ntfs_attr_get_search_ctx(ni, NULL); in ntfs_inode_add_attrlist()
1176 ale->mft_reference = MK_LE_MREF(ni->mft_no, in ntfs_inode_add_attrlist()
1177 le16_to_cpu(ni->mrec->sequence_number)); in ntfs_inode_add_attrlist()
1188 __FUNCTION__, (long long)ni->mft_no); in ntfs_inode_add_attrlist()
1193 ni->attr_list = al; in ntfs_inode_add_attrlist()
1194 ni->attr_list_size = al_len; in ntfs_inode_add_attrlist()
1195 NInoSetAttrList(ni); in ntfs_inode_add_attrlist()
1196 NInoAttrListSetDirty(ni); in ntfs_inode_add_attrlist()
1199 if (le32_to_cpu(ni->mrec->bytes_allocated) - in ntfs_inode_add_attrlist()
1200 le32_to_cpu(ni->mrec->bytes_in_use) < in ntfs_inode_add_attrlist()
1202 if (ntfs_inode_free_space(ni, in ntfs_inode_add_attrlist()
1212 if (ntfs_resident_attr_record_add(ni, in ntfs_inode_add_attrlist()
1220 na = ntfs_attr_open(ni, AT_ATTRIBUTE_LIST, AT_UNNAMED, 0); in ntfs_inode_add_attrlist()
1239 ni->attr_list = NULL; in ntfs_inode_add_attrlist()
1240 NInoClearAttrList(ni); in ntfs_inode_add_attrlist()
1250 ni->attr_list = al; in ntfs_inode_add_attrlist()
1251 ni->attr_list_size = al_len; in ntfs_inode_add_attrlist()
1252 NInoSetAttrList(ni); in ntfs_inode_add_attrlist()
1261 if (MREF_LE(ale->mft_reference) != ni->mft_no) { in ntfs_inode_add_attrlist()
1267 if (ntfs_attr_record_move_to(ctx, ni)) in ntfs_inode_add_attrlist()
1277 ni->attr_list = NULL; in ntfs_inode_add_attrlist()
1278 ni->attr_list_size = 0; in ntfs_inode_add_attrlist()
1279 NInoClearAttrList(ni); in ntfs_inode_add_attrlist()
1280 NInoAttrListClearDirty(ni); in ntfs_inode_add_attrlist()
1296 int ntfs_inode_free_space(ntfs_inode *ni, int size) in ntfs_inode_free_space() argument
1301 if (!ni || size < 0) { in ntfs_inode_free_space()
1303 ntfs_log_perror("%s: ni=%p size=%d", __FUNCTION__, ni, size); in ntfs_inode_free_space()
1308 (unsigned long long)ni->mft_no, size); in ntfs_inode_free_space()
1310 freed = (le32_to_cpu(ni->mrec->bytes_allocated) - in ntfs_inode_free_space()
1311 le32_to_cpu(ni->mrec->bytes_in_use)); in ntfs_inode_free_space()
1316 ctx = ntfs_attr_get_search_ctx(ni, NULL); in ntfs_inode_free_space()
1332 while (ctx->ntfs_ino->mft_no != ni->mft_no) { in ntfs_inode_free_space()
1384 void ntfs_inode_update_times(ntfs_inode *ni, ntfs_time_update_flags mask) in ntfs_inode_update_times() argument
1388 if (!ni) { in ntfs_inode_update_times()
1393 if ((ni->mft_no < FILE_first_user && ni->mft_no != FILE_root) || in ntfs_inode_update_times()
1394 NVolReadOnly(ni->vol) || !mask) in ntfs_inode_update_times()
1399 ni->last_access_time = now; in ntfs_inode_update_times()
1401 ni->last_data_change_time = now; in ntfs_inode_update_times()
1403 ni->last_mft_change_time = now; in ntfs_inode_update_times()
1405 NInoFileNameSetDirty(ni); in ntfs_inode_update_times()
1406 NInoSetDirty(ni); in ntfs_inode_update_times()
1463 int ntfs_inode_get_times(ntfs_inode *ni, char *value, size_t size) in ntfs_inode_get_times() argument
1471 ctx = ntfs_attr_get_search_ctx(ni, NULL); in ntfs_inode_get_times()
1476 (long long)ni->mft_no); in ntfs_inode_get_times()
1521 int ntfs_inode_set_times(ntfs_inode *ni, const char *value, size_t size, in ntfs_inode_set_times() argument
1539 ctx = ntfs_attr_get_search_ctx(ni, NULL); in ntfs_inode_set_times()
1545 (long long)ni->mft_no); in ntfs_inode_set_times()
1557 set_nino_flag(ni, TimesSet); in ntfs_inode_set_times()
1559 ni->creation_time in ntfs_inode_set_times()
1563 ni->last_data_change_time in ntfs_inode_set_times()
1568 ni->last_access_time in ntfs_inode_set_times()
1572 ni->last_mft_change_time = now; in ntfs_inode_set_times()
1574 NInoFileNameSetDirty(ni); in ntfs_inode_set_times()
1599 (long long)ni->mft_no); in ntfs_inode_set_times()