From 54d78993688cef803a1a1fa31cee49eb98683b56 Mon Sep 17 00:00:00 2001 From: Yura Pakhuchiy Date: Fri, 7 Sep 2007 15:50:29 +0300 Subject: [PATCH] Workaround windows defragmentation tool bug. Windows defragmentation tool do not update name offset correctly for unnamed attributes, but chkdsk do not like when it negative, so do not change it at all if it would become negative. (Szaka) --- libntfs/attrib.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libntfs/attrib.c b/libntfs/attrib.c index cccc86b9..21d5a513 100644 --- a/libntfs/attrib.c +++ b/libntfs/attrib.c @@ -4386,7 +4386,16 @@ retry: memmove((u8*)a + le16_to_cpu(a->name_offset) - 8, (u8*)a + le16_to_cpu(a->name_offset), a->name_length * sizeof(ntfschar)); - a->name_offset = cpu_to_le16(le16_to_cpu( + /* + * Windows defragmentation tool do not update + * name offset correctly for unnamed + * attributes, but chkdsk do not like when it + * negative, so do not change it at all if it + * would become negative. + */ + if (le16_to_cpu(a->name_offset) >= 8) + a->name_offset = cpu_to_le16( + le16_to_cpu( a->name_offset) - 8); a->mapping_pairs_offset = cpu_to_le16(le16_to_cpu(