From e5ea399ee6b280452aacdc0d99896b733179431a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Tue, 11 Mar 2014 10:51:47 +0100 Subject: [PATCH] Added a summary of inodes found by ntfscluster Output the number of inodes found. --- ntfsprogs/cluster.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ntfsprogs/cluster.c b/ntfsprogs/cluster.c index f9cf858d..82188f4c 100644 --- a/ntfsprogs/cluster.c +++ b/ntfsprogs/cluster.c @@ -2,6 +2,7 @@ * cluster - Part of the Linux-NTFS project. * * Copyright (c) 2002-2003 Richard Russon + * Copyright (c) 2014 Jean-Pierre Andre * * This function will locate the owner of any given sector or cluster range. * @@ -46,6 +47,8 @@ int cluster_find(ntfs_volume *vol, LCN c_begin, LCN c_end, cluster_cb *cb, void int result = -1; struct mft_search_ctx *m_ctx = NULL; ntfs_attr_search_ctx *a_ctx = NULL; + s64 count; + BOOL found; ATTR_RECORD *rec; runlist *runs; @@ -54,6 +57,7 @@ int cluster_find(ntfs_volume *vol, LCN c_begin, LCN c_end, cluster_cb *cb, void m_ctx = mft_get_search_ctx(vol); m_ctx->flags_search = FEMR_IN_USE | FEMR_BASE_RECORD; + count = 0; while (mft_next_record(m_ctx) == 0) { @@ -65,6 +69,7 @@ int cluster_find(ntfs_volume *vol, LCN c_begin, LCN c_end, cluster_cb *cb, void a_ctx = ntfs_attr_get_search_ctx(m_ctx->inode, NULL); + found = FALSE; while ((rec = find_attribute(AT_UNUSED, a_ctx))) { if (!rec->non_resident) { @@ -103,13 +108,20 @@ int cluster_find(ntfs_volume *vol, LCN c_begin, LCN c_end, cluster_cb *cb, void if ((*cb) (m_ctx->inode, a_ctx->attr, runs+j, data)) return 1; + found = TRUE; } } ntfs_attr_put_search_ctx(a_ctx); a_ctx = NULL; + if (found) + count++; } + if (count > 1) + ntfs_log_info("* %lld inodes found\n",(long long)count); + else + ntfs_log_info("* %s inode found\n", (count ? "one" : "no")); result = 0; done: ntfs_attr_put_search_ctx(a_ctx);