From f0c5c2a54fdf416d455434845b02e0544a59bd8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Tue, 17 Dec 2013 10:39:55 +0100 Subject: [PATCH] Ignored unmapped regions when checking whether sparse Updating an attribute may imply decompressing runlists which are not contiguous, leaving an unmapped region between them. When checking whether the attribute has been made sparse, such unmapped regions should be ignored This mostly happens after updating an index. (fix by Forrest Liu) --- libntfs-3g/attrib.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libntfs-3g/attrib.c b/libntfs-3g/attrib.c index 3df3a96a..1a9ef372 100644 --- a/libntfs-3g/attrib.c +++ b/libntfs-3g/attrib.c @@ -5567,7 +5567,7 @@ retry: BOOL changed; if (!(na->data_flags & ATTR_IS_SPARSE)) { - int sparse; + int sparse = 0; runlist_element *xrl; /* @@ -5575,10 +5575,18 @@ retry: * have to check whether there is a hole * in the updated region. */ - xrl = na->rl; - if (xrl->lcn == LCN_RL_NOT_MAPPED) - xrl++; - sparse = ntfs_rl_sparse(xrl); + for (xrl = na->rl; xrl->length; xrl++) { + if (xrl->lcn < 0) { + if (xrl->lcn == LCN_HOLE) { + sparse = 1; + break; + } + if (xrl->lcn != LCN_RL_NOT_MAPPED) { + sparse = -1; + break; + } + } + } if (sparse < 0) { ntfs_log_error("Could not check whether sparse\n"); errno = EIO;