From e5690b57d489615f1f01d3184d621437a4c15077 Mon Sep 17 00:00:00 2001 From: Yura Pakhuchiy Date: Sun, 16 Sep 2007 00:15:46 +0300 Subject: [PATCH] Allow mounting volumes with non-clean logfile with force mount option. Volume left dirty upon umount. So, this is equal to running ntfsfix and then mounting with force option. --- libntfs/volume.c | 13 +++++++++---- ntfsprogs/utils.c | 3 +-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/libntfs/volume.c b/libntfs/volume.c index b705c924..ecf813e2 100644 --- a/libntfs/volume.c +++ b/libntfs/volume.c @@ -1219,14 +1219,20 @@ ntfs_volume *ntfs_device_mount(struct ntfs_device *dev, ntfs_mount_flags flags) * But do not do that if this is a FORENSIC mount. */ if (!(flags & NTFS_MNT_RDONLY)) { - if (ntfs_volume_check_logfile(vol) < 0) - goto error_exit; if (ntfs_volume_check_hiberfile(vol) < 0) goto error_exit; + if (ntfs_volume_check_logfile(vol) < 0) { + if (errno != EOPNOTSUPP || !(flags & NTFS_MNT_FORCE)) + goto error_exit; + ntfs_log_warning("WARNING: $LogFile is not clean, " + "forced to continue.\n"); + NVolSetWasDirty(vol); /* Leave volume dirty since we + empted logfile. */ + } if (!NVolForensicMount(vol)) { if (ntfs_logfile_reset(vol) < 0) goto error_exit; - if (!NVolWasDirty(vol)) { + if (!(vol->flags & VOLUME_IS_DIRTY)) { vol->flags |= VOLUME_IS_DIRTY; if (ntfs_volume_write_flags(vol, vol->flags) < 0) @@ -1234,7 +1240,6 @@ ntfs_volume *ntfs_device_mount(struct ntfs_device *dev, ntfs_mount_flags flags) } } } - return vol; io_error_exit: errno = EIO; diff --git a/ntfsprogs/utils.c b/ntfsprogs/utils.c index d6c7e7b7..416cf793 100644 --- a/ntfsprogs/utils.c +++ b/ntfsprogs/utils.c @@ -104,8 +104,7 @@ static const char *unclean_journal_msg = " C) Use 'Eject' from Windows Explorer to safely remove the device.\n" " D) If you ran chkdsk previously then boot Windows again which will\n" " automatically initialize the journal.\n" -" E) Run 'ntfsfix' on Linux which will reset the NTFS journal.\n" -" Then submit force option (WARNING: This solution it not recommended).\n" +" E) Submit 'force' option (WARNING: This solution it not recommended).\n" " F) ntfsmount: Mount the volume read-only by using the 'ro' mount option.\n"; static const char *opened_volume_msg =