From 76cc3b3c6a9d339ee76ae479e8e3406eb3422f66 Mon Sep 17 00:00:00 2001 From: "(none)!yura" <(none)!yura> Date: Thu, 14 Oct 2004 18:23:21 +0000 Subject: [PATCH] improve ntfs_non_resident_attr_record_add (Logical change 1.612) --- libntfs/attrib.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libntfs/attrib.c b/libntfs/attrib.c index 3b5dc560..f10876cd 100644 --- a/libntfs/attrib.c +++ b/libntfs/attrib.c @@ -2508,6 +2508,15 @@ int ntfs_non_resident_attr_record_add(ntfs_inode *ni, ATTR_TYPES type, a->lowest_vcn = cpu_to_sle64(lowest_vcn); a->mapping_pairs_offset = cpu_to_le16(length - dataruns_size); a->compression_unit = (flags & ATTR_IS_COMPRESSED) ? 4 : 0; + /* If @lowest_vcn == 0, than setup empty attribute. */ + if (!lowest_vcn) { + a->highest_vcn = cpu_to_sle64(-1); + a->allocated_size = 0; + a->data_size = 0; + a->initialized_size = 0; + /* Set empty mapping pairs. */ + *((u8*) a + (length - dataruns_size)) = 0; + } if (name_len) memcpy((u8*)a + le16_to_cpu(a->name_offset), name, sizeof(ntfschar) * name_len);