Replaced all occurrences of the libntfs mount flag NTFS_MNT_FORCE with the libntfs-3g mount flag MS_RECOVER.
Note: The NTFS_MNT_FORCE, in addition to what MS_RECOVER does, also bypasses the check for the 'dirty' bit in libntfs' ntfs_mount. However, this check does not exist in libntfs-3g (libntfs-3g will not check or change the dirty bit, being confident that it can handle volumes marked as 'dirty'), so in essence the same behaviour is achieved with MS_RECOVER.edge.strict_endians
parent
6ff5d3f8a7
commit
18789cdeaa
|
@ -411,7 +411,7 @@ int main(int argc, char *argv[])
|
|||
utils_set_locale();
|
||||
|
||||
vol = utils_mount_volume(opts.device, MS_RDONLY |
|
||||
(opts.force ? NTFS_MNT_FORCE : 0));
|
||||
(opts.force ? MS_RECOVER : 0));
|
||||
if (!vol) {
|
||||
ntfs_log_perror("ERROR: couldn't mount volume");
|
||||
return 1;
|
||||
|
|
|
@ -493,7 +493,7 @@ int main(int argc, char *argv[])
|
|||
utils_set_locale();
|
||||
|
||||
vol = utils_mount_volume(opts.device, MS_RDONLY |
|
||||
(opts.force ? NTFS_MNT_FORCE : 0));
|
||||
(opts.force ? MS_RECOVER : 0));
|
||||
if (!vol)
|
||||
return 1;
|
||||
|
||||
|
|
|
@ -349,7 +349,7 @@ int main(int argc, char *argv[])
|
|||
if (opts.noaction)
|
||||
flags = MS_RDONLY;
|
||||
if (opts.force)
|
||||
flags |= NTFS_MNT_FORCE;
|
||||
flags |= MS_RECOVER;
|
||||
|
||||
vol = utils_mount_volume(opts.device, flags);
|
||||
if (!vol) {
|
||||
|
|
|
@ -1453,7 +1453,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
/* Mount the ntfs volume. */
|
||||
vol = utils_mount_volume(opts.device, MS_RDONLY |
|
||||
(opts.force ? NTFS_MNT_FORCE : 0));
|
||||
(opts.force ? MS_RECOVER : 0));
|
||||
if (!vol) {
|
||||
ntfs_log_error("Failed to mount ntfs volume. Aborting.\n");
|
||||
ntfs_rsa_private_key_release(rsa_key);
|
||||
|
|
|
@ -2253,7 +2253,7 @@ int main(int argc, char **argv)
|
|||
utils_set_locale();
|
||||
|
||||
vol = utils_mount_volume(opts.device, MS_RDONLY |
|
||||
(opts.force ? NTFS_MNT_FORCE : 0));
|
||||
(opts.force ? MS_RECOVER : 0));
|
||||
if (!vol) {
|
||||
printf("Failed to open '%s'.\n", opts.device);
|
||||
exit(1);
|
||||
|
|
|
@ -396,7 +396,7 @@ int main(int argc, char **argv)
|
|||
|
||||
vol = utils_mount_volume(opts.device,
|
||||
(opts.noaction ? MS_RDONLY : 0) |
|
||||
(opts.force ? NTFS_MNT_FORCE : 0));
|
||||
(opts.force ? MS_RECOVER : 0));
|
||||
if (!vol)
|
||||
return 1;
|
||||
|
||||
|
|
|
@ -652,7 +652,7 @@ int main(int argc, char **argv)
|
|||
utils_set_locale();
|
||||
|
||||
vol = utils_mount_volume(opts.device, MS_RDONLY |
|
||||
(opts.force ? NTFS_MNT_FORCE : 0));
|
||||
(opts.force ? MS_RECOVER : 0));
|
||||
if (!vol) {
|
||||
// FIXME: Print error... (AIA)
|
||||
return 2;
|
||||
|
|
|
@ -877,7 +877,7 @@ int main(int argc, char *argv[])
|
|||
if (opts.noaction)
|
||||
flags |= MS_RDONLY;
|
||||
if (opts.force)
|
||||
flags |= NTFS_MNT_FORCE;
|
||||
flags |= MS_RECOVER;
|
||||
|
||||
vol = utils_mount_volume(opts.device, flags);
|
||||
if (!vol) {
|
||||
|
|
|
@ -2156,7 +2156,7 @@ int main(int argc, char *argv[])
|
|||
utils_set_locale();
|
||||
|
||||
vol = utils_mount_volume(opts.device, MS_RDONLY |
|
||||
(opts.force ? NTFS_MNT_FORCE : 0));
|
||||
(opts.force ? MS_RECOVER : 0));
|
||||
if (!vol)
|
||||
return 1;
|
||||
|
||||
|
|
|
@ -1342,7 +1342,7 @@ int main(int argc, char *argv[])
|
|||
if (opts.info || opts.noaction)
|
||||
flags = MS_RDONLY;
|
||||
if (opts.force)
|
||||
flags |= NTFS_MNT_FORCE;
|
||||
flags |= MS_RECOVER;
|
||||
|
||||
vol = utils_mount_volume(opts.device, flags);
|
||||
if (!vol)
|
||||
|
|
|
@ -216,7 +216,22 @@ ntfs_volume * utils_mount_volume(const char *device, ntfs_mount_flags flags)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (!utils_valid_device(device, flags & NTFS_MNT_FORCE))
|
||||
/* Porting notes:
|
||||
*
|
||||
* libntfs-3g does not have the 'force' flag in ntfs_mount_flags.
|
||||
* The 'force' flag in libntfs bypasses two safety checks when mounting
|
||||
* read/write:
|
||||
* 1. Do not mount when the VOLUME_IS_DIRTY flag in
|
||||
* VOLUME_INFORMATION is set.
|
||||
* 2. Do not mount when the logfile is unclean.
|
||||
*
|
||||
* libntfs-3g only has safety check number 2. The dirty flag is simply
|
||||
* ignored because we are confident that we can handle a dirty volume.
|
||||
* So we treat MS_RECOVER like NTFS_MNT_FORCE, knowing that the first
|
||||
* check is always bypassed.
|
||||
*/
|
||||
|
||||
if (!utils_valid_device(device, flags & MS_RECOVER))
|
||||
return NULL;
|
||||
|
||||
vol = ntfs_mount(device, flags);
|
||||
|
@ -242,7 +257,7 @@ ntfs_volume * utils_mount_volume(const char *device, ntfs_mount_flags flags)
|
|||
* before mount, so we can only warn if the VOLUME_IS_DIRTY flag is set
|
||||
* in VOLUME_INFORMATION. */
|
||||
if (vol->flags & VOLUME_IS_DIRTY) {
|
||||
if (!(flags & NTFS_MNT_FORCE)) {
|
||||
if (!(flags & MS_RECOVER)) {
|
||||
ntfs_log_error("%s", dirty_volume_msg);
|
||||
ntfs_umount(vol, FALSE);
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in New Issue