diff --git a/ntfsprogs/ntfsfix.c b/ntfsprogs/ntfsfix.c index a0220e6f..c6ec628a 100644 --- a/ntfsprogs/ntfsfix.c +++ b/ntfsprogs/ntfsfix.c @@ -264,7 +264,14 @@ static int set_dirty_flag(ntfs_volume *vol) return -1; } vol->flags = flags; - NVolSetWasDirty(vol); + + /* Porting note: libntfs-3g does not have the 'WasDirty' flag/property, + * and never touches the 'dirty' bit except when explicitly told to do + * so. Since we just wrote the VOLUME_IS_DIRTY bit to disk, and + * vol->flags is up-to-date, we can just ignore the NVolSetWasDirty + * statement. */ + /* NVolSetWasDirty(vol); */ + ntfs_log_info(OK); return 0; } @@ -515,7 +522,20 @@ int main(int argc, char **argv) } } /* So the unmount does not clear it again. */ - NVolSetWasDirty(vol); + + /* Porting note: The WasDirty flag was set here to prevent ntfs_unmount + * from clearing the dirty bit (which might have been set in + * fix_mount()). So the intention is to leave the dirty bit set. + * + * libntfs-3g does not automatically set or clear dirty flags on + * mount/unmount, this means that the assumption that the dirty flag is + * now set does not hold. So we need to set it if not already set. */ + if(!(vol->flags & VOLUME_IS_DIRTY) && ntfs_volume_write_flags(vol, + vol->flags | VOLUME_IS_DIRTY)) { + ntfs_log_error("Error: Failed to set volume dirty flag (%d " + "(%s))!\n", errno, strerror(errno)); + } + /* Check NTFS version is ok for us (in $Volume) */ ntfs_log_info("NTFS volume version is %i.%i.\n", vol->major_ver, vol->minor_ver); diff --git a/ntfsprogs/ntfsmove.c b/ntfsprogs/ntfsmove.c index 13092701..6cfff46f 100644 --- a/ntfsprogs/ntfsmove.c +++ b/ntfsprogs/ntfsmove.c @@ -893,7 +893,19 @@ int main(int argc, char *argv[]) count = move_file(vol, inode, opts.location, 0); if ((count > 0) && (!opts.nodirty)) { - NVolSetWasDirty(vol); + + /* Porting note: libntfs-3g does not automatically set or clear + * dirty flags on mount/unmount. It always preserves them until + * they are explicitly changed with ntfs_volume_write_flags. + * This means that the dirty flag is possibly not set, but + * should be set. So we explicitly set it with a call to + * ntfs_volume_write_flags. */ + if(!(vol->flags & VOLUME_IS_DIRTY) && ntfs_volume_write_flags( + vol, vol->flags | VOLUME_IS_DIRTY)) { + ntfs_log_error("Error: Failed to set volume dirty " + "flag (%d (%s))!\n", errno, strerror(errno)); + } + ntfs_log_info("Relocated %lld bytes\n", count); } if (count >= 0) diff --git a/ntfsprogs/ntfsresize.c b/ntfsprogs/ntfsresize.c index 8f0d4e26..18dd6a45 100644 --- a/ntfsprogs/ntfsresize.c +++ b/ntfsprogs/ntfsresize.c @@ -2297,7 +2297,12 @@ static void prepare_volume_fixup(ntfs_volume *vol) vol->flags |= VOLUME_IS_DIRTY; if (ntfs_volume_write_flags(vol, vol->flags)) perr_exit("Failed to set the volume dirty"); - NVolSetWasDirty(vol); + + /* Porting note: This flag does not exist in libntfs-3g. The dirty flag + * is never modified by libntfs-3g on unmount and we set it above. We + * can safely comment out this statement. */ + /* NVolSetWasDirty(vol); */ + if (vol->dev->d_ops->sync(vol->dev) == -1) perr_exit("Failed to sync device"); printf("Resetting $LogFile ... (this might take a while)\n");