Lines Matching refs:na

268  * @na:		ntfs attribute to initialize
274 * Initialize the ntfs attribute @na with @ni, @type, @name, and @name_len.
276 static void __ntfs_attr_init(ntfs_attr *na, ntfs_inode *ni,
279 na->rl = NULL;
280 na->ni = ni;
281 na->type = type;
282 na->name = name;
284 na->name_len = name_len;
286 na->name_len = 0;
291 * @na:
304 void ntfs_attr_init(ntfs_attr *na, const BOOL non_resident,
310 if (!NAttrInitialized(na)) {
312 NAttrSetNonResident(na);
314 NAttrSetCompressed(na);
316 NAttrSetEncrypted(na);
318 NAttrSetSparse(na);
319 na->allocated_size = allocated_size;
320 na->data_size = data_size;
321 na->initialized_size = initialized_size;
323 ntfs_volume *vol = na->ni->vol;
325 na->compressed_size = compressed_size;
326 na->compression_block_clusters = 1 << compression_unit;
327 na->compression_block_size = 1 << (compression_unit +
329 na->compression_block_size_bits = ffs(
330 na->compression_block_size) - 1;
332 NAttrSetInitialized(na);
355 ntfs_attr *na;
382 na = calloc(sizeof(ntfs_attr), 1);
383 if (!na)
389 free(na);
428 __ntfs_attr_init(na, ni, type, name, name_len);
430 ntfs_attr_init(na, TRUE, (a->flags & ATTR_IS_COMPRESSED)? 1 : 0,
440 ntfs_attr_init(na, FALSE, (a->flags & ATTR_IS_COMPRESSED) ? 1:0,
446 if (NAttrEncrypted(na))
447 ntfs_crypto_attr_open(na);
448 list_add_tail(&na->list_entry, &ni->attr_cache);
449 na->nr_references = 1;
450 return na;
454 free(na);
461 * @na: ntfs attribute structure to free
463 * Release all memory associated with the ntfs attribute @na and then release
464 * @na itself.
466 void ntfs_attr_close(ntfs_attr *na)
468 if (!na)
470 na->nr_references--;
471 if (na->nr_references) {
473 "this attribute.\n", na->nr_references);
477 list_del(&na->list_entry);
478 if (NAttrEncrypted(na))
479 ntfs_crypto_attr_close(na);
480 if (NAttrNonResident(na) && na->rl)
481 free(na->rl);
483 if (na->name != AT_UNNAMED && na->name != NTFS_INDEX_I30)
484 free(na->name);
485 free(na);
490 * @na: ntfs attribute for which to map (part of) a runlist
493 * Map the part of a runlist containing the @vcn of the ntfs attribute @na.
497 int ntfs_attr_map_runlist(ntfs_attr *na, VCN vcn)
503 (unsigned long long)na->ni->mft_no, na->type, (long long)vcn);
505 lcn = ntfs_rl_vcn_to_lcn(na->rl, vcn);
509 ctx = ntfs_attr_get_search_ctx(na->ni, NULL);
514 if (!ntfs_attr_lookup(na->type, na->name, na->name_len, CASE_SENSITIVE,
519 rl = ntfs_mapping_pairs_decompress(na->ni->vol, ctx->attr,
520 na->rl);
522 na->rl = rl;
533 * @na: ntfs attribute for which to map (part of) a runlist
538 * @to_vcn of an ntfs attribute @na. It is OK for @to_vcn to be beyond last run.
542 int ntfs_attr_map_runlist_range(ntfs_attr *na, VCN from_vcn, VCN to_vcn)
549 (unsigned long long)na->ni->mft_no, na->type,
553 if (ntfs_attr_map_runlist(na, from_vcn))
556 for (rl = na->rl; rl->vcn <= to_vcn;) {
577 ctx = ntfs_attr_get_search_ctx(na->ni, NULL);
582 if (ntfs_attr_lookup(na->type, na->name, na->name_len,
588 rl = ntfs_mapping_pairs_decompress(na->ni->vol, ctx->attr,
589 na->rl);
592 na->rl = rl;
606 * @na: ntfs attribute for which to map the runlist
608 * Map the whole runlist of the ntfs attribute @na. For an attribute made up
610 * ntfs_attr_map_runlist(na, 0) but for an attribute with multiple extents this
616 int ntfs_attr_map_whole_runlist(ntfs_attr *na)
620 ntfs_volume *vol = na->ni->vol;
625 (unsigned long long)na->ni->mft_no, na->type);
627 ctx = ntfs_attr_get_search_ctx(na->ni, NULL);
638 if (ntfs_rl_vcn_to_lcn(na->rl, next_vcn) == LCN_RL_NOT_MAPPED)
641 if (ntfs_attr_lookup(na->type, na->name, na->name_len,
649 rl = ntfs_mapping_pairs_decompress(na->ni->vol,
650 a, na->rl);
653 na->rl = rl;
720 * @na: ntfs attribute whose runlist to use for conversion
724 * cluster number (lcn) of a device using the runlist @na->rl to map vcns to
739 LCN ntfs_attr_vcn_to_lcn(ntfs_attr *na, const VCN vcn)
744 if (!na || !NAttrNonResident(na) || vcn < 0)
748 long)na->ni->mft_no, na->type);
751 lcn = ntfs_rl_vcn_to_lcn(na->rl, vcn);
754 if (!is_retry && !ntfs_attr_map_runlist(na, vcn)) {
771 * @na: ntfs attribute whose runlist to search
775 * @na and return the the address of the runlist element containing the @vcn.
789 runlist_element *ntfs_attr_find_vcn(ntfs_attr *na, const VCN vcn)
794 if (!na || !NAttrNonResident(na) || vcn < 0) {
800 (unsigned long long)na->ni->mft_no, na->type,
803 rl = na->rl;
832 if (!is_retry && !ntfs_attr_map_runlist(na, vcn)) {
849 * @na: ntfs attribute to read from
855 * attribute @na into the data buffer @b.
866 s64 ntfs_attr_pread(ntfs_attr *na, const s64 pos, s64 count, void *b)
873 "count 0x%llx.\n", (unsigned long long)na->ni->mft_no,
874 na->type, (long long)pos, (long long)count);
875 if (!na || !na->ni || !na->ni->vol || !b || pos < 0 || count < 0) {
883 if (NAttrCompressed(na) && NAttrNonResident(na))
884 return ntfs_compressed_attr_pread(na, pos, count, b);
889 if (NAttrEncrypted(na) && NAttrNonResident(na))
890 return ntfs_crypto_attr_pread(na, pos, count, b);
892 vol = na->ni->vol;
896 if (pos + count > na->data_size) {
897 if (pos >= na->data_size)
899 count = na->data_size - pos;
902 if (!NAttrNonResident(na)) {
906 ctx = ntfs_attr_get_search_ctx(na->ni, NULL);
909 if (ntfs_attr_lookup(na->type, na->name, na->name_len, 0,
931 if (pos + count > na->initialized_size) {
932 if (pos >= na->initialized_size) {
936 total2 = pos + count - na->initialized_size;
941 rl = ntfs_attr_find_vcn(na, pos >> vol->cluster_size_bits);
960 rl = ntfs_attr_find_vcn(na, rl->vcn);
1020 * @na: ntfs attribute to write to
1026 * @na at position @pos.
1037 s64 ntfs_attr_pwrite(ntfs_attr *na, const s64 pos, s64 count, const void *b)
1052 "count 0x%llx.\n", na->ni->mft_no, na->type,
1054 if (!na || !na->ni || !na->ni->vol || !b || pos < 0 || count < 0) {
1058 vol = na->ni->vol;
1063 if (NAttrEncrypted(na) && NAttrNonResident(na)) {
1068 if (NAttrCompressed(na)) {
1070 // return ntfs_attr_pwrite_compressed(ntfs_attr *na,
1078 old_data_size = na->data_size;
1079 if (pos + count > na->data_size) {
1080 if (__ntfs_attr_truncate(na, pos + count, FALSE)) {
1088 old_initialized_size = na->initialized_size;
1090 if (!NAttrNonResident(na)) {
1093 ctx = ntfs_attr_get_search_ctx(na->ni, NULL);
1096 if (ntfs_attr_lookup(na->type, na->name, na->name_len, 0,
1123 if (pos + count > na->initialized_size) {
1128 if (ntfs_attr_map_runlist_range(na, na->initialized_size >>
1133 ctx = ntfs_attr_get_search_ctx(na->ni, NULL);
1136 if (ntfs_attr_lookup(na->type, na->name, na->name_len, 0,
1140 if (pos > na->initialized_size && ntfs_rl_fill_zero(vol,
1141 na->rl, na->initialized_size,
1142 pos - na->initialized_size))
1158 na->initialized_size = pos + count;
1170 rl = ntfs_attr_find_vcn(na, pos >> vol->cluster_size_bits);
1189 rl = ntfs_attr_find_vcn(na, rl->vcn);
1224 if (ntfs_attr_map_whole_runlist(na))
1230 rl = ntfs_attr_find_vcn(na, cur_vcn);
1280 rl = ntfs_runlists_merge(na->rl, rlc);
1293 na->rl = rl;
1297 rl = ntfs_attr_find_vcn(na, cur_vcn);
1341 if (ofs && ntfs_rl_fill_zero(vol, na->rl, rl->vcn <<
1364 na->initialized_size) {
1403 if (ntfs_attr_update_mapping_pairs(na, update_from)) {
1418 if (pos + total > na->initialized_size)
1437 ctx = ntfs_attr_get_search_ctx(na->ni, NULL);
1443 err = ntfs_attr_lookup(na->type, na->name,
1444 na->name_len, 0, 0, NULL, 0, ctx);
1446 na->initialized_size = old_initialized_size;
1469 ntfs_attr_update_mapping_pairs(na, update_from);
1471 if (need_to.undo_data_size && ntfs_attr_truncate(na, old_data_size))
1479 * @na: multi sector transfer protected ntfs attribute to read from
1486 * at offset @pos from the ntfs attribute @na into the data buffer @b.
1506 s64 ntfs_attr_mst_pread(ntfs_attr *na, const s64 pos, const s64 bk_cnt,
1513 "pos 0x%llx.\n", (unsigned long long)na->ni->mft_no,
1514 na->type, (long long)pos);
1519 br = ntfs_attr_pread(na, pos, bk_cnt * bk_size, dst);
1532 * @na: multi sector transfer protected ntfs attribute to write to
1539 * data buffer @b to multi sector transfer (mst) protected ntfs attribute @na
1560 s64 ntfs_attr_mst_pwrite(ntfs_attr *na, const s64 pos, s64 bk_cnt,
1566 "pos 0x%llx.\n", (unsigned long long)na->ni->mft_no,
1567 na->type, (long long)pos);
1589 written = ntfs_attr_pwrite(na, pos, bk_cnt * bk_size, src);
3048 ntfs_attr *na;
3215 na = ntfs_attr_open(ni, type, name, name_len);
3216 if (!na) {
3222 if (ntfs_attr_truncate(na, size) ||
3223 (val && (ntfs_attr_pwrite(na, 0, size, val) != size))) {
3226 if (ntfs_attr_rm(na))
3232 ntfs_attr_close(na);
3258 * @na: opened ntfs attribute to delete
3262 * closes @na upon exit (both on success and failure).
3266 int ntfs_attr_rm(ntfs_attr *na)
3271 if (!na) {
3278 (long long) na->ni->mft_no, na->type);
3281 if (NAttrNonResident(na)) {
3282 if (ntfs_attr_map_whole_runlist(na)) {
3283 ntfs_attr_close(na);
3286 if (ntfs_cluster_free(na->ni->vol, na, 0, -1) < 0) {
3294 ctx = ntfs_attr_get_search_ctx(na->ni, NULL);
3296 ntfs_attr_close(na);
3299 while (!ntfs_attr_lookup(na->type, na->name, na->name_len,
3315 ntfs_attr_close(na);
3597 * @na: open ntfs attribute to make non-resident
3614 static int ntfs_attr_make_non_resident(ntfs_attr *na,
3618 ntfs_volume *vol = na->ni->vol;
3624 long)na->ni->mft_no, na->type);
3627 if (NAttrNonResident(na)) {
3635 if (ntfs_attr_can_be_non_resident(vol, na->type))
3670 NAttrSetNonResident(na);
3671 na->rl = rl;
3672 na->allocated_size = new_allocated_size;
3673 na->data_size = na->initialized_size = le32_to_cpu(a->u.res.value_length);
3678 NAttrClearCompressed(na);
3679 NAttrClearSparse(na);
3680 NAttrClearEncrypted(na);
3684 bw = ntfs_attr_pwrite(na, 0, le32_to_cpu(a->u.res.value_length),
3749 a->u.nonres.data_size = a->u.nonres.initialized_size = cpu_to_sle64(na->data_size);
3766 if (rl && ntfs_cluster_free(vol, na, 0, -1) < 0)
3769 NAttrClearNonResident(na);
3770 na->allocated_size = na->data_size;
3771 na->rl = NULL;
3778 * @na: resident ntfs attribute to resize
3781 * Change the size of a resident, open ntfs attribute @na to @newsize bytes.
3786 * ERANGE - @newsize is not valid for the attribute type of @na.
3793 static int ntfs_resident_attr_resize(ntfs_attr *na, const s64 newsize)
3801 (unsigned long long)na->ni->mft_no, na->type,
3805 ctx = ntfs_attr_get_search_ctx(na->ni, NULL);
3808 if (ntfs_attr_lookup(na->type, na->name, na->name_len, 0, 0, NULL, 0,
3813 vol = na->ni->vol;
3818 if (ntfs_attr_size_bounds_check(vol, na->type, newsize) < 0) {
3837 na->data_size = na->initialized_size = newsize;
3838 na->allocated_size = ROUND_UP(newsize, 3);
3839 if (NAttrCompressed(na) || NAttrSparse(na))
3840 na->compressed_size = na->allocated_size;
3841 if (na->type == AT_DATA && na->name == AT_UNNAMED) {
3842 na->ni->data_size = na->data_size;
3843 na->ni->allocated_size = na->allocated_size;
3844 NInoFileNameSetDirty(na->ni);
3859 if (!ntfs_attr_make_non_resident(na, ctx)) {
3863 return ntfs_attr_truncate(na, newsize);
3872 ntfs_attr_init_search_ctx(ctx, NULL, na->ni->mrec);
3890 tna = ntfs_attr_open(na->ni, a->type, (ntfschar*)((u8*)a +
3904 return ntfs_resident_attr_resize(na, newsize);
3914 if (na->type == AT_ATTRIBUTE_LIST) {
3916 if (ntfs_inode_free_space(na->ni, offsetof(ATTR_RECORD,
3923 return ntfs_resident_attr_resize(na, newsize);
3932 ntfs_attr_init_search_ctx(ctx, na->ni, NULL);
3933 if (ntfs_attr_lookup(na->type, na->name, na->name_len, CASE_SENSITIVE,
3944 if (na->type == AT_INDEX_ROOT && na->data_size > sizeof(INDEX_ROOT) +
3968 if (na->ni->nr_extents == -1)
3969 ni = na->ni->u.base_ni;
3971 ni = na->ni;
3976 return ntfs_resident_attr_resize(na, newsize);
3992 if (na->ni->nr_extents == -1)
3993 na->ni = ni;
3997 return ntfs_resident_attr_resize(na, newsize);
4016 * @na: open ntfs attribute to make resident
4033 static int ntfs_attr_make_resident(ntfs_attr *na, ntfs_attr_search_ctx *ctx)
4035 ntfs_volume *vol = na->ni->vol;
4041 long)na->ni->mft_no, na->type);
4052 if (!NAttrNonResident(na)) {
4060 if (na->type == AT_BITMAP && na->ni->mft_no == FILE_MFT) {
4066 if (ntfs_attr_can_be_resident(vol, na->type))
4081 if (NAttrCompressed(na) || NAttrEncrypted(na)) {
4091 arec_size = (val_ofs + na->data_size + 7) & ~7;
4102 if (ntfs_attr_map_whole_runlist(na))
4128 a->u.res.value_length = cpu_to_le32(na->data_size);
4142 if (na->initialized_size > na->data_size)
4143 na->initialized_size = na->data_size;
4146 bytes_read = ntfs_rl_pread(vol, na->rl, 0, na->initialized_size,
4148 if (bytes_read != na->initialized_size) {
4158 if (na->initialized_size < na->data_size)
4159 memset((u8*)a + val_ofs + na->initialized_size, 0,
4160 na->data_size - na->initialized_size);
4169 if (ntfs_cluster_free(vol, na, 0, -1) < 0) {
4176 free(na->rl);
4177 na->rl = NULL;
4180 NAttrClearNonResident(na);
4181 NAttrClearCompressed(na);
4182 NAttrClearSparse(na);
4183 NAttrClearEncrypted(na);
4184 na->initialized_size = na->data_size;
4185 na->allocated_size = na->compressed_size = (na->data_size + 7) & ~7;
4186 na->compression_block_size = 0;
4187 na->compression_block_size_bits = na->compression_block_clusters = 0;
4194 * @na: non-resident ntfs open attribute for which we need update
4197 * Build mapping pairs from @na->rl and write them to the disk. Also, this
4201 * @na->allocated_size should be set to correct value for the new runlist before
4202 * call to this function. Vice-versa @na->compressed_size will be calculated and
4224 int ntfs_attr_update_mapping_pairs(ntfs_attr *na, VCN from_vcn)
4235 if (!na || !na->rl) {
4241 if (!NAttrNonResident(na)) {
4248 "\n", (unsigned long long)na->ni->mft_no, na->type,
4251 if (na->ni->nr_extents == -1)
4252 base_ni = na->ni->u.base_ni;
4254 base_ni = na->ni;
4265 while (!ntfs_attr_lookup(na->type, na->name, na->name_len,
4286 first_lcn = ntfs_rl_vcn_to_lcn(na->rl, stop_vcn);
4334 a->u.nonres.allocated_size = cpu_to_sle64(na->allocated_size);
4339 sparse = ntfs_rl_sparse(na->rl);
4350 if (from_vcn && ntfs_attr_map_runlist_range(na,
4362 sparse = ntfs_rl_sparse(na->rl);
4385 if (!NInoAttrList(na->ni)) {
4388 na->ni))
4412 NAttrSetSparse(na);
4435 NAttrClearSparse(na);
4466 na->ni->vol, na->rl);
4474 na->compressed_size = new_compr_size;
4482 if (na->type == AT_DATA && na->name == AT_UNNAMED) {
4484 na->ni->allocated_size =
4485 na->compressed_size;
4487 na->ni->allocated_size =
4488 na->allocated_size;
4489 NInoFileNameSetDirty(na->ni);
4507 mp_size = ntfs_get_size_for_mapping_pairs(na->ni->vol, na->rl,
4534 if (na->type == AT_ATTRIBUTE_LIST) {
4536 if (ntfs_inode_free_space(na->ni, mp_size -
4601 if (!ntfs_mapping_pairs_build(na->ni->vol, (u8*)a + le16_to_cpu(
4602 a->u.nonres.mapping_pairs_offset), mp_size, na->rl,
4633 while (!ntfs_attr_lookup(na->type, na->name, na->name_len,
4663 mp_size = ntfs_get_size_for_mapping_pairs(na->ni->vol,
4664 na->rl, stop_vcn);
4671 ni = ntfs_mft_record_alloc(na->ni->vol, base_ni);
4685 ((NAttrCompressed(na) || NAttrSparse(na)) ?
4687 ((sizeof(ntfschar) * na->name_len + 7) & ~7);
4691 err = ntfs_non_resident_attr_record_add(ni, na->type,
4692 na->name, na->name_len, stop_vcn, mp_size, 0);
4697 if (ntfs_mft_record_free(na->ni->vol, ni)) {
4704 err = ntfs_mapping_pairs_build(na->ni->vol, (u8*)a +
4705 le16_to_cpu(a->u.nonres.mapping_pairs_offset), mp_size, na->rl,
4713 if (ntfs_mft_record_free(na->ni->vol, ni))
4735 * @na: non-resident ntfs attribute to shrink
4738 * Reduce the size of a non-resident, open ntfs attribute @na to @newsize bytes.
4743 * ERANGE - @newsize is not valid for the attribute type of @na.
4745 static int ntfs_non_resident_attr_shrink(ntfs_attr *na, const s64 newsize)
4754 (unsigned long long)na->ni->mft_no, na->type,
4757 vol = na->ni->vol;
4763 if (ntfs_attr_size_bounds_check(vol, na->type, newsize) < 0) {
4779 if ((na->allocated_size >> vol->cluster_size_bits) != first_free_vcn) {
4780 if (ntfs_attr_map_whole_runlist(na)) {
4786 nr_freed_clusters = ntfs_cluster_free(vol, na, first_free_vcn,
4795 if (ntfs_rl_truncate(&na->rl, first_free_vcn)) {
4801 free(na->rl);
4802 na->rl = NULL;
4809 na->allocated_size = first_free_vcn << vol->cluster_size_bits;
4811 if (ntfs_attr_update_mapping_pairs(na, first_free_vcn)) {
4820 ctx = ntfs_attr_get_search_ctx(na->ni, NULL);
4825 if (ntfs_attr_lookup(na->type, na->name, na->name_len, CASE_SENSITIVE,
4836 na->data_size = newsize;
4838 if (newsize < na->initialized_size) {
4839 na->initialized_size = newsize;
4843 if (na->type == AT_DATA && na->name == AT_UNNAMED) {
4844 na->ni->data_size = na->data_size;
4845 NInoFileNameSetDirty(na->ni);
4850 if (ntfs_attr_make_resident(na, ctx)) {
4871 * @na: non-resident ntfs attribute to expand
4875 * Expand the size of a non-resident, open ntfs attribute @na to @newsize bytes,
4881 * ERANGE - @newsize is not valid for the attribute type of @na.
4884 static int ntfs_non_resident_attr_expand(ntfs_attr *na, const s64 newsize,
4896 (unsigned long long)na->ni->mft_no, na->type,
4897 (long long)newsize, (long long)na->data_size);
4899 vol = na->ni->vol;
4905 if (ntfs_attr_size_bounds_check(vol, na->type, newsize) < 0) {
4915 org_alloc_size = na->allocated_size;
4923 if ((na->allocated_size >> vol->cluster_size_bits) < first_free_vcn) {
4925 if (ntfs_attr_map_runlist(na, na->allocated_size >>
4935 if (na->type == AT_DATA && vol->major_ver >= 3 && sparse) {
4940 rl[0].vcn = (na->allocated_size >>
4944 (na->allocated_size >> vol->cluster_size_bits);
4959 if (na->rl->length) {
4961 for (rl = na->rl; (rl + 1)->length; rl++)
4967 while (rl->lcn < 0 && rl != na->rl)
4976 rl = ntfs_cluster_alloc(vol, na->allocated_size >>
4978 (na->allocated_size >>
4988 rln = ntfs_runlists_merge(na->rl, rl);
4998 na->rl = rln;
5001 na->allocated_size = first_free_vcn << vol->cluster_size_bits;
5003 if (ntfs_attr_update_mapping_pairs(na, org_alloc_size >>
5011 ctx = ntfs_attr_get_search_ctx(na->ni, NULL);
5014 if (na->allocated_size == org_alloc_size) {
5021 if (ntfs_attr_lookup(na->type, na->name, na->name_len, CASE_SENSITIVE,
5027 if (na->allocated_size != org_alloc_size) {
5035 na->data_size = newsize;
5038 if (na->type == AT_DATA && na->name == AT_UNNAMED) {
5039 na->ni->data_size = na->data_size;
5040 NInoFileNameSetDirty(na->ni);
5049 if (ntfs_cluster_free(vol, na, org_alloc_size >>
5055 if (ntfs_rl_truncate(&na->rl, org_alloc_size >>
5061 free(na->rl);
5062 na->rl = NULL;
5066 na->allocated_size = org_alloc_size;
5068 if (ntfs_attr_update_mapping_pairs(na, na->allocated_size >>
5085 * @na: open ntfs attribute to resize
5089 * Change the size of an open ntfs attribute @na to @newsize bytes. If the
5099 * ERANGE - @newsize is not valid for the attribute type of @na.
5107 int __ntfs_attr_truncate(ntfs_attr *na, const s64 newsize, BOOL sparse)
5111 if (!na || newsize < 0 ||
5112 (na->ni->mft_no == FILE_MFT && na->type == AT_DATA)) {
5119 long)na->ni->mft_no, na->type);
5121 if (na->data_size == newsize)
5127 if (NAttrEncrypted(na)) {
5135 if (NAttrCompressed(na)) {
5140 if (NAttrNonResident(na)) {
5141 if (newsize > na->data_size)
5142 ret = ntfs_non_resident_attr_expand(na, newsize,
5145 ret = ntfs_non_resident_attr_shrink(na, newsize);
5147 ret = ntfs_resident_attr_resize(na, newsize);
5159 int ntfs_attr_truncate(ntfs_attr *na, const s64 newsize)
5161 return __ntfs_attr_truncate(na, newsize, TRUE);
5187 ntfs_attr *na;
5191 na = ntfs_attr_open(ni, type, name, name_len);
5192 if (!na) {
5196 data = ntfs_malloc(na->data_size);
5200 size = ntfs_attr_pread(na, 0, na->data_size, data);
5201 if (size != na->data_size) {
5210 ntfs_attr_close(na);