From 5edb3ec9203c93e9fc95f4809fc17570bfc19f78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Fri, 12 Feb 2016 17:03:53 +0100 Subject: [PATCH] Closed the bad sector inode after updating the list Unlike in most cases, the bad sector inode has to be closed if it was updated and required MFT extents (when there are a lot of bad sectors and some of them were outside the truncated partition). Not doing so causes the inode to not be fully synced to device. --- ntfsprogs/ntfsresize.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/ntfsprogs/ntfsresize.c b/ntfsprogs/ntfsresize.c index 9b67bce5..af5da8e4 100644 --- a/ntfsprogs/ntfsresize.c +++ b/ntfsprogs/ntfsresize.c @@ -5,7 +5,7 @@ * Copyright (c) 2002-2005 Anton Altaparmakov * Copyright (c) 2002-2003 Richard Russon * Copyright (c) 2007 Yura Pakhuchiy - * Copyright (c) 2011-2015 Jean-Pierre Andre + * Copyright (c) 2011-2016 Jean-Pierre Andre * * This utility will resize an NTFS volume without data loss. * @@ -404,7 +404,7 @@ static void version(void) printf("Copyright (c) 2002-2005 Anton Altaparmakov\n"); printf("Copyright (c) 2002-2003 Richard Russon\n"); printf("Copyright (c) 2007 Yura Pakhuchiy\n"); - printf("Copyright (c) 2011-2015 Jean-Pierre Andre\n"); + printf("Copyright (c) 2011-2016 Jean-Pierre Andre\n"); printf("\n%s\n%s%s", ntfs_gpl, ntfs_bugs, ntfs_home); } @@ -2537,8 +2537,6 @@ static void lookup_data_attr(ntfs_volume *vol, ntfs_ucsfree(ustr); } -#if CLEAN_EXIT - static void close_inode_and_context(ntfs_attr_search_ctx *ctx) { ntfs_inode *ni; @@ -2551,8 +2549,6 @@ static void close_inode_and_context(ntfs_attr_search_ctx *ctx) ntfs_inode_close(ni); } -#endif /* CLEAN_EXIT */ - static int check_bad_sectors(ntfs_volume *vol) { ntfs_attr_search_ctx *ctx; @@ -2619,11 +2615,7 @@ static void truncate_badclust_file(ntfs_resize_t *resize) resize->mref = FILE_BadClus; truncate_badclust_bad_attr(resize); -#if CLEAN_EXIT close_inode_and_context(resize->ctx); -#else - ntfs_attr_put_search_ctx(resize->ctx); -#endif } /**