From 0959ea990751b6604d0f65ca1f3c19621259b859 Mon Sep 17 00:00:00 2001 From: cha0smaster Date: Wed, 3 Aug 2005 21:25:42 +0000 Subject: [PATCH] Fix ntfs_is_cb_compressed for nasty runlist merging case in which compression block was incorrectly treated as not compressed. --- ChangeLog | 2 ++ libntfs/compress.c | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e7da835c..6290a151 100644 --- a/ChangeLog +++ b/ChangeLog @@ -25,6 +25,8 @@ xx/xx/xxxx - 1.12.0-WIP - Make find work correctly on volumes mounted by ntfsmount. (Yura) - Replaced all occurances of ENOTSUP to EOPNOTSUPP to be in better harmony with the kernel driver. (Szaka) + - Fix ntfs_is_cb_compressed for nasty runlist merging case in which + compression block was incorrectly treated as not compressed. (Yura) 20/07/2005 - 1.11.1 - Fix several ntfsmount bugs. diff --git a/libntfs/compress.c b/libntfs/compress.c index 407d4d90..f0cb164c 100644 --- a/libntfs/compress.c +++ b/libntfs/compress.c @@ -3,6 +3,7 @@ * project. * * Copyright (c) 2004-2005 Anton Altaparmakov + * Copyright (c) 2005 Yura Pakhuchiy * * This program/include file is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as published @@ -265,9 +266,17 @@ static __inline__ BOOL ntfs_is_cb_compressed(ntfs_attr *na, rl++; /* Map the next runlist fragment if it is not mapped. */ if (rl->lcn < LCN_HOLE || !rl->length) { - rl = ntfs_attr_find_vcn(na, rl->vcn); + VCN tvcn; + + tvcn = rl->vcn; + rl = ntfs_attr_find_vcn(na, tvcn); if (!rl || rl->lcn < LCN_HOLE || !rl->length) return TRUE; + if (rl->vcn < tvcn) { + /* Runs merged. Need special handling. */ + cb_clusters -= rl->length - (tvcn - rl->vcn); + continue; + } } /* If the current run is sparse, the cb is compressed. */ if (rl->lcn == LCN_HOLE)