From 28cacf40b0507dbf52e817146483afd17fd00631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Mon, 22 Apr 2013 18:45:48 +0200 Subject: [PATCH] Fixed trying to update the MFT and Bitmap on a test run of ntfsresize When the beginning of the MFT is beyond the end of the resized partition, a specific procedure has to be used to relocate this part of the MFT and adjust the bitmap accordingly. On a test run, these updates should not be done. --- ntfsprogs/ntfsresize.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ntfsprogs/ntfsresize.c b/ntfsprogs/ntfsresize.c index c64e318f..09b9ee7f 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-2012 Jean-Pierre Andre + * Copyright (c) 2011-2013 Jean-Pierre Andre * * This utility will resize an NTFS volume without data loss. * @@ -2027,9 +2027,10 @@ static void relocate_inode(ntfs_resize_t *resize, MFT_REF mref, int do_mftdata) pos = (resize->new_mft_start->lcn << vol->cluster_size_bits) + (FILE_MFT << vol->mft_record_size_bits); - if (ntfs_mst_pwrite(vol->dev, pos, 1, + if (!opt.ro_flag + && (ntfs_mst_pwrite(vol->dev, pos, 1, vol->mft_record_size, - resize->mrec) != 1) + resize->mrec) != 1)) perr_exit("Couldn't update MFT own record"); } else { if (write_mft_record(vol, mref, resize->mrec)) @@ -2492,8 +2493,9 @@ static void truncate_bitmap_file(ntfs_resize_t *resize) /* write the MFT record at its new location */ pos = (resize->new_mft_start->lcn << vol->cluster_size_bits) + (FILE_Bitmap << vol->mft_record_size_bits); - if (ntfs_mst_pwrite(vol->dev, pos, 1, - vol->mft_record_size, resize->ctx->mrec) != 1) + if (!opt.ro_flag + && (ntfs_mst_pwrite(vol->dev, pos, 1, + vol->mft_record_size, resize->ctx->mrec) != 1)) perr_exit("Couldn't update $Bitmap at new location"); } else { if (write_mft_record(vol, resize->ctx->ntfs_ino->mft_no,