Commit Graph

78 Commits (edge)

Author SHA1 Message Date
Jean-Pierre André 399ba862c9 Updated the urls present in ntfs-3g code
The urls now point at Github
2021-08-30 09:27:33 +02:00
Jean-Pierre André f85ce6ff2e Skipped errors for bad free clusters before they are computed
The count of free clusters may be updated while mounting before it
has been initialized, which may lead to irrelevant error messages.
Moreover the count is not computed at all in some ntfsprogs utilities.
So set up a flags to avoid outputting irrelevant errors.
2021-07-19 09:23:23 +02:00
Jean-Pierre André f30b52490f Restricted the attribute definition table size to 24 bits
The standard size is 2560 bytes. It can be extended for specific purposes,
but its former limit to 32 bits was unreasonable. Anyway ntfs-3g is
not committed to support non-standard situations.
2021-07-12 08:31:18 +02:00
Jean-Pierre André 7f45544ed7 Added and grouped generic attribute checks
Checked that attributes are [non-]resident when they have to be, and
grouped consistency checks on each of them in a dedicated function.
Consequenly request the checks where needed and remove existing index
checks.
2021-07-12 08:31:18 +02:00
Jean-Pierre André 32e858a87a Aborted mounting when cannot access standard information of MFT
The standard information of the MFT must be its first attribute in the
base record. If it is not accessible initially, we end up searching it
in an extent before the MFT struct is ready for that.
2021-07-12 08:31:18 +02:00
Jean-Pierre André ec7bf54377 Checked the MFTMirr lcn to be consistent with the boot sector
The lcn of the initial run of the MFTMirr data must be the same as
described in the boot sector. As a consequence this cannot be a hole.
2021-07-12 08:31:18 +02:00
Jean-Pierre André e2e625065d Checked the layout of attribute list entries
Make sure the attribute list has at least one element, and that each of
them has the minimal size and does not overflow out of the end of list.
2021-07-12 08:31:17 +02:00
Jean-Pierre André 37a330ea8c Improved the consistency checks of standard information
Make sure the standard information attribute has a valid size.
2021-05-17 15:39:13 +03:00
Jean-Pierre André 1258474e07 Improved check of upcase table length
The consistency check on the upcase size was laxist.
The unicode points are limited to 1048575 (20 bits), but there is no
provision to support code points beyond 65535.
In the current implementation the upcase size must be even and <= 131072.
2021-05-17 15:30:17 +03:00
Jean-Pierre André 2ede3b67ee Improved checking of the location of MFT
Terminate cleanly when the MFT is improperly located, by making sure it
is located within the volume and that it contains its own data.
2021-03-05 10:21:36 +01:00
Jean-Pierre André 2514ce6a42 Attempted mounting read-only after failed permission to read-write
If a partition image could not be opened read-write, retry as read-only
2018-08-22 09:43:19 +02:00
Jean-Pierre André 85e208176f Stopped checking matches of MFTMirr against MFT at record 16
Since its 2017 edition, Windows 10 has stopped mirroring $MFT to the
full size of $MFTMirr leading to mounts of partitions with big clusters
to be rejected because of mismatches. With this patch, only 16 records
are checked, though mirroring is still done for all records in $MFTMirr.
2017-12-22 11:29:00 +01:00
Jean-Pierre André 32587b485c Improved opening/closing $Secure when un/mounting NTFS volume
Call ntfs_close_secure() earlier, check for error, and other cleanups

Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
2016-09-02 08:30:07 +02:00
Jean-Pierre André 2840e84a97 Always opened $Secure when mounting NTFS volume
Currently, applications that wish to access security descriptors have to
explicitly open the volume's security descriptor index ("$Secure") using
ntfs_open_secure().  Applications are also responsible for closing the
index when done with it.  However, the cleanup function for doing,
ntfs_close_secure(), cannot be called easily by all applications because
it requires a SECURITY_CONTEXT argument, not simply the ntfs_volume.
Some applications therefore have to close the inode and index contexts
manually in order to clean up properly.

This proposal updates libntfs-3g to open $Secure unconditonally as part
of ntfs_mount(), so that applications do not have to worry about it.

This proposal updates libntfs-3g to open $Secure unconditonally as part
of ntfs_mount(), so that applications do not have to worry about it.

ntfs_close_secure() is updated to take in a ntfs_volume for internal use,
and ntfs_destroy_security_context() is now the function to call to free
memory associated with a SECURITY_CONTEXT rather than a ntfs_volume.

Some memory leaks in error paths of ntfs_open_secure() are also fixed.

Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
2016-07-28 16:22:16 +02:00
Jean-Pierre André 8a1358fff4 Enabled fallback to read-only mount when volume is hibernated
When a volume is found hibernated (or prepared for fast restarting),
it is force-mounted as read-only.
2016-04-06 09:51:47 +02:00
Jean-Pierre André d2197785f4 Avoided pointer cast when checking record types
Some compilers issue warning when casting a pointer to a pointer to
a different type.
When checking a record magic, there is no need to cast pointers.
2016-02-15 11:54:33 +01:00
Erik Larsson 9893ea9ee6 Merge endianness fixes.
Conflicts:
	libntfs-3g/attrib.c
2016-01-28 09:22:42 +01:00
Erik Larsson 701cd61cca volume.c: Fix passing bad pointer type to ntfs_is_[baad|mft]_recordp. 2016-01-25 11:31:12 +01:00
Jean-Pierre André 9f22e17a16 Improved the check for a valid $MFTMirr
The test for a valid $MFTMirr could segfault on a badly damaged partition.
Add safety checks.
2015-09-30 09:02:15 +02:00
Jean-Pierre André 20801dc6a0 Used /proc/mounts for checking existing mounts
The file /etc/mtab is traditionally checked to avoid multiple mountings
of the same device, but this is not accurate enough in some conditions.
So use /proc/mounts when available and fall back to /etc/mtab on
systems which do not have /proc/mounts.
2013-04-22 18:37:51 +02:00
Erik Larsson 7506d8b80b Rename legacy MS_* flags for ntfs_mount with NTFS_MNT_* flags.
The MS_* flags originated from system constants. However the flags
passed to ntfs_mount were really unrelated to the system constants and
many new MS_* flags had to be introduced as different features were
added to the library. Those flags had no counterparts in any system
APIs, so using the same naming scheme is inappropriate.

Instead, let's namespace these flags similarly to what has already been
done in ntfsprogs/libntfs earlier. This avoids any possible conflicts
with system constants.
The values of the flags themselves are kept the same as earlier, so
backward compatibility is retained.
2012-11-07 16:29:48 +01:00
Erik Larsson ebb38c4b1c API cleanup of const arguments.
- Replaced 'ntfschar*' parameters with 'const ntfschar*' where
  appropriate (the function does not need to modify the string).
- Replaced some instances of 'u8*' and 'char*' read-only buffer
  arguments with 'const u8*' and 'const char*'.
2012-11-07 14:15:53 +01:00
Jean-Pierre André 559270a8f6 Prevented partitions with metadata cached in Windows from being mounted
Windows 8 includes a "fast restart" feature for restarting without fully
remounting the internal volumes. When this mode is selected, metadata
stored in the cache (probably hiberfil.sys) is used instead of what
is actually on disk, and this may lead to inconsistencies when changes
have been made by ntfs-3g in the meantime.

This patch tries to prevent ntfs-3g from mounting in read-write mode
when a fast restart of Windows 8 is detected. It relies on the restart
pages in the $LogFile being identified as version 2.0, which is
apparently related to data being cached for hibernation or fast restarting.
2012-09-25 09:46:54 +02:00
Jean-Pierre André 0b2a85b612 Forced option ro when mounting a read-only device
External devices, such as USB keys, may have a switch to make them
temporarily unwriteable. When such a device is plugged in, mount it
as read-only by default.
2012-09-12 09:47:36 +02:00
Jean-Pierre André 93ac6ce3bf Removed the suggestions to use option remove_hiberfile
The suggestion to use option remove_hiberfile was displayed in the
standard help and when a volume is found dirty. As this option may
lead to loss of data, only mention it in the manual, with a proper
warning.
2012-06-18 12:46:21 +02:00
Jean-Pierre André 2b779a6510 Implemented the check for already mounted device on OpenIndiana
This adds a variant for checking on OpenIndiana whether a device
is mentioned in /etc/mnttab as being mounted.
2012-03-21 19:01:33 +01:00
Jean-Pierre André 3c6e88cb0f fixed checking whether Windows 7 was hibernated
On Windows XP and Vista, the system hibernation is identified by the
sequence "hibr" at the beginning of hiberfil.sys. This had been changed
to "HIBR" in Windows 7, so both sequences have to be accepted as
hibernation criteria.
2012-01-23 17:16:07 +01:00
Jean-Pierre André 59ecea5c80 new : allow compression in default setup
With the default mount options, compression of new files are now done
if the parent directory is marked for compression. The mount option
"compression" is not needed any more, but the option "nocompression"
can be used to disable compression of new files.

The default option also applies to applications using libntfs-3g with
no mount command.
2011-10-20 18:55:32 +02:00
Erik Larsson 8d06955ea4 Cleaned up and moved label changing functionality into libntfs-3g.
The label changing code in ntfslabel was cleaned up and modified to use the more
advanced functionality of libntfs-3g instead of using older custom code to
resize and create resident attributes.
The core label changing functionality was also moved into the library so it can
be reused by other programs.
2011-09-13 09:43:30 +02:00
Erik Larsson 182c5c2a2f Fix: Forgot to update state bits after last change. 2011-08-03 15:49:40 +02:00
Erik Larsson 7f2d1efa82 Bugfix: ntfs_mft_load didn't fill in the size fields in the $MFT inode. 2011-08-03 11:13:40 +02:00
Jean-Pierre André 571dbc5784 Fixed device path canonicalization for use by devmapper (basilinya)
For some reason, when the monted device is "/dev/mapper/*", a record
in the form "/dev/dm-*" ends up in /etc/mtab and the device cannot be
unmounted.

The reason is unclear, the /dev/mapper name is not a symlink, and the
function doing the name change is not known. No detailed feedback from
the users having met the issue.

The patch changes the name back to the /dev/mapper name after realpath()
is called, and, if there is an actual change, both the name passed to
ntfs-3g and the one passed to fuse and mount are logged in the hope
of getting a clue about what is happening.

But ntfs-3g is probably not the right place for a fix.
2011-07-05 12:17:12 +02:00
Szaka f246d6ce97 Update ntfs-3g.org references 2011-03-27 15:29:48 +03:00
Jean-Pierre André 4c6cf9d977 Moved the knowledge of default upcase size to unistr.c 2011-02-08 13:52:12 +01:00
Jean-Pierre André d4e2a501a5 Enabled forensic mounting 2010-12-21 15:51:07 +01:00
Jean-Pierre André 135cb75249 Fixed logging corrupted $UpCase 2010-11-09 09:40:02 +01:00
Jean-Pierre André 563f5dda3f Implemented a basic check on upcase table 2010-10-26 08:59:51 +02:00
Jean-Pierre André 693aa8780d enabled case insensitive file names in lowntfs-3g 2010-05-25 10:12:44 +02:00
Jean-Pierre André 3745d0a1e3 marked files whose name has a dot initial as "hidden" if option hide_dot_files 2010-05-25 09:58:36 +02:00
jpandre 6f72ec189d Logged the outcome of making $TXF_DATA resident 2010-01-16 09:26:01 +00:00
jpandre da39179421 Merged Anton's patch for $TXF_DATA attribute 2010-01-08 11:15:46 +00:00
jpandre c708a2bdee Fixed TXF_DATA attribute on root directory when made non-resident 2010-01-04 08:09:44 +00:00
jpandre 41a371f4a7 Redesigned caches for indexing cached entries 2009-12-17 17:36:06 +00:00
jpandre 9279c2e493 Fixed inappropriate casts 2009-11-25 14:29:08 +00:00
jpandre a75724fea8 Fixed a few misleading endianness types 2009-11-24 14:18:53 +00:00
jpandre f259fb44df Improved cluster allocation on volumes too filled 2009-07-01 19:16:33 +00:00
jpandre 1e822076d6 Adapted to ntfs-3g.2009.3.8 2009-03-27 09:15:24 +00:00
jpandre a13ee0c82c Fed the free spaces in context for calls from security API 2009-03-27 08:36:07 +00:00
jpandre 93b695f1cc Adapted to ntfs-3g-2009.2.1 2009-02-12 20:32:21 +00:00
jpandre 11216c6942 Adapted to ntfs-3g-2009.1.1 2009-01-23 11:11:44 +00:00