OSDN Git Service

android-x86/external-ntfs-3g.git
8 years agoMerge branch 'edge' of git://git.code.sf.net/p/ntfs-3g/ntfs-3g into marshmallow-x86 android-x86-6.0-r1 android-x86-6.0-r2
Chih-Wei Huang [Wed, 6 Jul 2016 17:33:21 +0000 (01:33 +0800)]
Merge branch 'edge' of git://git.code.sf.net/p/ntfs-3g/ntfs-3g into marshmallow-x86

8 years agoAndroid.mk: create symbolic links required by vold
Chih-Wei Huang [Wed, 6 Jul 2016 17:31:42 +0000 (01:31 +0800)]
Android.mk: create symbolic links required by vold

8 years agoAndroid.mk: clean up
Chih-Wei Huang [Wed, 6 Jul 2016 17:28:17 +0000 (01:28 +0800)]
Android.mk: clean up

Get the include paths automatically by LOCAL_EXPORT_C_INCLUDE_DIRS.

8 years agoCompiled out conditionally debug-oriented code
Jean-Pierre André [Wed, 22 Jun 2016 10:01:25 +0000 (12:01 +0200)]
Compiled out conditionally debug-oriented code

Although ntfs_log_trace() is defined to a no-op in non-DEBUG builds,
ntfs_attr_name_get() is not.  This function performs a string conversion
and a memory allocation, so it is nice to have the call to it compiled
out when not needed.

Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
8 years agoFixed ntfs_delete() failure caused by string conversion error
Jean-Pierre André [Wed, 22 Jun 2016 09:58:20 +0000 (11:58 +0200)]
Fixed ntfs_delete() failure caused by string conversion error

It was possible for ntfs_attr_name_get() to set errno due to a wide
character string that could not be converted to a multibyte string.  This
caused ntfs_delete() to fail.

Fix by checking for a nonzero return value specifically from
ntfs_attr_lookup(), rather than assuming that nothing else sets errno.

Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
8 years agoSwitch to using the standard autoconf AC_HEADER_MAJOR macro
Jean-Pierre André [Tue, 31 May 2016 06:33:10 +0000 (08:33 +0200)]
Switch to using the standard autoconf AC_HEADER_MAJOR macro

Switch to the standard autoconf AC_HEADER_MAJOR macro which takes care
of the ugly details like when to use mkdev.h and when to use sysmacros.h.
(requires <sys/types.h> to be included)
Also include these in all files that use major/minor/makedev funcs.

(Contributed by Mike Frysinger)

8 years agoSilenced a truncation warning in upper case table
Jean-Pierre André [Tue, 31 May 2016 06:24:23 +0000 (08:24 +0200)]
Silenced a truncation warning in upper case table

The upper case value for 0x1d79 is 0xa77d, so the difference is 0x8a04,
which overflows in the table which defines the computation of upper case
values. Rewriting this difference as -0x75fc leads to the same result
in an upper case table truncated to two bytes, and this avoid the
compiler warning.

8 years agoPorted patches to libfuse from the OpenIndiana variant
Jean-Pierre André [Wed, 4 May 2016 08:15:35 +0000 (10:15 +0200)]
Ported patches to libfuse from the OpenIndiana variant

A few patches had been found useful to the OpenIndiana variant of libfuse
(2.7.6). Port them to libfuse-lite and restrict them to Solaris/OpenIndiana.

8 years ago383 Fixed masks for major and minor in fuse-lite for OpenIndiana
Jean-Pierre André [Wed, 4 May 2016 08:08:06 +0000 (10:08 +0200)]
383 Fixed masks for major and minor in fuse-lite for OpenIndiana

On Solaris/OpenIndiana, the major and minor fields in st_rdev have to
be represented on 14 bits and 18 bits respectively. They must have
the same representation on 32-bit and 64-bit builds as the kernel
and the library do not know the word size of each other.

8 years agoUsed <sys/mkdev.h> instead of <sys/sysmacros.h> on OpenIndiana
Jean-Pierre André [Wed, 4 May 2016 08:03:39 +0000 (10:03 +0200)]
Used <sys/mkdev.h> instead of <sys/sysmacros.h> on OpenIndiana

On Solaris/OpenIndiana, use the macroes makedev(), major() and minor()
from <sys/mkdev.h>. Those from <sys/sysmacros.h> are inappropriate for
current builds.

8 years agoRedefined ELIBBAD as ENOEXEC when missing
Jean-Pierre André [Wed, 4 May 2016 07:59:18 +0000 (09:59 +0200)]
Redefined ELIBBAD as ENOEXEC when missing

When a plugin cannot be initialized a ELIBBAD error is returned on Linux
and OpenIndiana. As this is not a Posix error code, use ENOEXEC on
systems which do not define ELIBBAD.

8 years agoUpdated information about ntfsprogs to the README file
Jean-Pierre André [Wed, 4 May 2016 07:55:16 +0000 (09:55 +0200)]
Updated information about ntfsprogs to the README file

Added mentions of ntfssecaudit, ntfsusermap and ntfsrecover to the
README file.

8 years agoDefined an option to kill the Windows cache and play the log file
Jean-Pierre André [Wed, 4 May 2016 07:47:51 +0000 (09:47 +0200)]
Defined an option to kill the Windows cache and play the log file

The new ntfsrecover option --kill-fast-restart can be used to delete
the Windows fast-restart indication before playing the log. This can
lead to data loss, but is needed before mounting a partition improperly
unmounted from Windows when remounting on Windows is inconvenient.

8 years agoRejected implicit mounting read-only when hiberfile option is present
Jean-Pierre André [Wed, 4 May 2016 07:39:48 +0000 (09:39 +0200)]
Rejected implicit mounting read-only when hiberfile option is present

If the remove_hiberfile mount option is present, explicitly disallow
the library from switching to a read-only mount. This is only to avoid
confusion, as the remove_hiberfile is processed before taking the
decision to fall back to read-only.

8 years agoUsed Microsoft terminology for SID names
Jean-Pierre André [Wed, 4 May 2016 07:33:42 +0000 (09:33 +0200)]
Used Microsoft terminology for SID names

A few SIDs descriptions might be confusing because of a wording different
from Microsoft usage.

8 years agoDisplayed the SID revision as an unsigned number (cosmetic)
Jean-Pierre André [Wed, 4 May 2016 07:30:48 +0000 (09:30 +0200)]
Displayed the SID revision as an unsigned number (cosmetic)

Properly display a SID revision if it should ever reach 128.
(suggested by Ulf Zibis)

8 years agoChecked the number of subauthorities before accessing them
Jean-Pierre André [Wed, 4 May 2016 07:27:32 +0000 (09:27 +0200)]
Checked the number of subauthorities before accessing them

Be more crash resistent when analyzing a badly formed SID.
(contributed by Ulf Zibis)

8 years agoFixed segmentation fault on empty $LogFile in ntfsrecover
Jean-Pierre André [Wed, 4 May 2016 07:24:51 +0000 (09:24 +0200)]
Fixed segmentation fault on empty $LogFile in ntfsrecover

ntfsrecover -f -v <log file> receives a SIGSEGV because of trying to
read memory outside allocated buffer because of no sanity checks on
restart page header values. This happens on an empty $LogFile because
of no basic checks present. Attached patch adds basic checks similar
to those inside logfile library and allows tool to exit with more
suitable message.
(contributed by Rakesh Pandit)

8 years agoFixed a missing "break" in ntfssecaudit.c
Jean-Pierre André [Wed, 4 May 2016 07:19:39 +0000 (09:19 +0200)]
Fixed a missing "break" in ntfssecaudit.c

A missing "break" in a case construct could be troublesome.
(suggested by Ulf Zibis)

8 years agoFixed indentation in ntfssecaudit.c (cosmetic)
Jean-Pierre André [Wed, 4 May 2016 07:15:43 +0000 (09:15 +0200)]
Fixed indentation in ntfssecaudit.c (cosmetic)

There was an abusive indentation.

8 years agounistr.c: Unify the two defines NOREVBOM and ALLOW_BROKEN_SURROGATES.
Erik Larsson [Tue, 12 Apr 2016 15:02:40 +0000 (17:02 +0200)]
unistr.c: Unify the two defines NOREVBOM and ALLOW_BROKEN_SURROGATES.

In the mailing list discussion we came to the conclusion that there
doesn't seem to be any reason to keep these declarations separate since
they address the same issue, namely libntfs-3g's tolerance for bad
Unicode data in filenames and other UTF-16 strings in the file system,
so merge the two defines into the new define ALLOW_BROKEN_UNICODE.

8 years agounistr.c: Enable encoding broken UTF-16 into broken UTF-8, A.K.A. WTF-8.
Erik Larsson [Fri, 8 Apr 2016 03:39:48 +0000 (05:39 +0200)]
unistr.c: Enable encoding broken UTF-16 into broken UTF-8, A.K.A. WTF-8.

Windows filenames may contain invalid UTF-16 sequences (specifically
broken surrogate pairs), which cannot be converted to UTF-8 if we do
strict conversion.

This patch enables encoding broken UTF-16 into similarly broken UTF-8 by
encoding any surrogate character that don't have a match into a separate
3-byte UTF-8 sequence.

This is "sort of" valid UTF-8, but not valid Unicode since the code
points used for surrogate pair encoding are not supposed to occur in a
valid Unicode string... but on the other hand the source UTF-16 data is
also broken, so we aren't really making things any worse.

This format is sometimes referred to as WTF-8 (Wobbly Translation
Format, 8-bit encoding) and is a common solution to represent broken
UTF-16 as UTF-8.

It is a lossless round-trip conversion, i.e converting from broken
UTF-16 to "WTF-8" and back to UTF-16 yields the same broken UTF-16
sequence. Because of this property it enables accessing these files
by filename through ntfs-3g and the ntfsprogs (e.g. ls -la works as
expected).

To disable this behaviour you can pass the preprocessor/compiler flag
'-DALLOW_BROKEN_SURROGATES=0' when building ntfs-3g.

8 years agoDeleted file secaudit.h
Jean-Pierre André [Thu, 7 Apr 2016 07:36:01 +0000 (09:36 +0200)]
Deleted file secaudit.h

The declarations for compiling secaudit on Windows are not used any more
and can be dropped.

8 years agoRemoved declarations for using acls.c outside ntfs-3g
Jean-Pierre André [Thu, 7 Apr 2016 07:32:26 +0000 (09:32 +0200)]
Removed declarations for using acls.c outside ntfs-3g

The declarations for using acls.c within secaudit on Windows are not used
any more and can be dropped.

8 years agoAdapted secaudit and usermap (now ntfssecaudit and ntfsusermap) to ntfsprogs
Jean-Pierre André [Thu, 7 Apr 2016 07:20:23 +0000 (09:20 +0200)]
Adapted secaudit and usermap (now ntfssecaudit and ntfsusermap) to ntfsprogs

These tools were originally developed for running on Windows and later
ported to libntfs-3g. This patch makes them similar to other ntfsprogs
tools, dropping the native Windows interfaces and using libntfs-3g on
all platforms.

There is no change in usage or supported features, only the command
names have changed.

8 years agoMoved secaudit and usermap to directory ntfsprogs
Jean-Pierre André [Thu, 7 Apr 2016 07:07:13 +0000 (09:07 +0200)]
Moved secaudit and usermap to directory ntfsprogs

These tools were developped before the ntfsprogs were merged into ntfs-3g,
redesigning them like the ntfsprogs make the code simpler.

Note : at this stage secaudit and usermap cannot be built any more.

8 years agoFixed indentation in ntfsclone help text (cosmetic)
Jean-Pierre André [Wed, 6 Apr 2016 09:09:35 +0000 (11:09 +0200)]
Fixed indentation in ntfsclone help text (cosmetic)

The tabs in source code appear differently in actual output.

8 years agoFixed a spelling error in ntfsresize manual (cosmetic)
Jean-Pierre André [Wed, 6 Apr 2016 09:07:30 +0000 (11:07 +0200)]
Fixed a spelling error in ntfsresize manual (cosmetic)

an other -> another

8 years agoMoved general declarations from ntfsrecover.h to logfile.h
Jean-Pierre André [Wed, 6 Apr 2016 09:03:31 +0000 (11:03 +0200)]
Moved general declarations from ntfsrecover.h to logfile.h

The declarations related to the log file structure are now grouped
in logfile.h, those specific to the recovery process are kept in
ntfsrecover.h

8 years agoAdded a usn field to RESTART_PAGE_HEADER
Jean-Pierre André [Wed, 6 Apr 2016 08:58:25 +0000 (10:58 +0200)]
Added a usn field to RESTART_PAGE_HEADER

Prepare merging ntfsrecover.h into logfile.h by adding a usn field to
RESTART_PAGE_HEADER. As this changes the record size, ignore the new
field in existing code.

8 years agoRenamed reserved fields in ntfsrecover the same way as in logfile.h
Jean-Pierre André [Wed, 6 Apr 2016 08:54:51 +0000 (10:54 +0200)]
Renamed reserved fields in ntfsrecover the same way as in logfile.h

Prepare merging ntfsrecover.h into logfile.h by naming reserved fields
the same way.

8 years agoRenamed record_length as log_record_header_length in ntfsrecover.h
Jean-Pierre André [Wed, 6 Apr 2016 08:52:18 +0000 (10:52 +0200)]
Renamed record_length as log_record_header_length in ntfsrecover.h

Prepare merging ntfsrecover.h into logfile.h by naming the record
header length the same way.

8 years agoRenamed restart_offset as restart_area_offset in ntfsrecover.h
Jean-Pierre André [Wed, 6 Apr 2016 08:50:31 +0000 (10:50 +0200)]
Renamed restart_offset as restart_area_offset in ntfsrecover.h

Prepare merging ntfsrecover.h into logfile.h by renaming the restart
offset the same way.

8 years agoRedefined target_vcn on 64 bits in ntfsrecover.h
Jean-Pierre André [Wed, 6 Apr 2016 08:45:30 +0000 (10:45 +0200)]
Redefined target_vcn on 64 bits in ntfsrecover.h

In a log record, the target vcn has to be stored on 64 bits

8 years agoRedefined file_offset on 64 bits in ntfsrecover.h
Jean-Pierre André [Wed, 6 Apr 2016 08:40:28 +0000 (10:40 +0200)]
Redefined file_offset on 64 bits in ntfsrecover.h

The log file offsets are apparently stored on 64 bits, though the file
size is unlikely to reach 2MB.

8 years agoUnfolded record headers in ntfsrecover the same way as in logfile.h
Jean-Pierre André [Wed, 6 Apr 2016 08:38:06 +0000 (10:38 +0200)]
Unfolded record headers in ntfsrecover the same way as in logfile.h

Prepare merging ntfsrecover.h into logfile.h by unfolding the record
headers the same way.

8 years agoTypedef'ed new structs in ntfsrecover the same way as in logfile.h
Jean-Pierre André [Wed, 6 Apr 2016 08:34:46 +0000 (10:34 +0200)]
Typedef'ed new structs in ntfsrecover the same way as in logfile.h

Prepare merging ntfsrecover.h into logfile.h by declaring new structs
the same was as in logfile.h

8 years agoTypedef'ed old structs in ntfsrecover the same way as in logfile.h
Jean-Pierre André [Wed, 6 Apr 2016 08:32:39 +0000 (10:32 +0200)]
Typedef'ed old structs in ntfsrecover the same way as in logfile.h

Prepare merging ntfsrecover.h into logfile.h by declaring duplicated
structs the same way

8 years agoRedefined ntfsrecover enums as little-endian values
Jean-Pierre André [Wed, 6 Apr 2016 08:26:46 +0000 (10:26 +0200)]
Redefined ntfsrecover enums as little-endian values

Rather than cpu-endian values, use little-endian ones in ntfsrecover
for similarity with layout.h

8 years agoMade a full check for whether a user extended attribute is allowed
Jean-Pierre André [Wed, 6 Apr 2016 08:17:27 +0000 (10:17 +0200)]
Made a full check for whether a user extended attribute is allowed

User extended attributes should only be set on files and directories,
not on symlinks, sockets, devices, etc. For safety they are also
forbidden on metadata files, but should be allowed on the root
directory. For files based on reparse points, requests are made
to the plugin to determine the type.

8 years agoTranslated directory separators when running ntfscluster on Windows
Jean-Pierre André [Wed, 6 Apr 2016 08:11:08 +0000 (10:11 +0200)]
Translated directory separators when running ntfscluster on Windows

Use \ as a directory separator when running on Windows.

8 years agoReturned an error code for an exclusive access violation on Windows
Jean-Pierre André [Wed, 6 Apr 2016 08:08:01 +0000 (10:08 +0200)]
Returned an error code for an exclusive access violation on Windows

Translate to Windows error code STATUS_SHARING_VIOLATION to Unix error
code EBUSY.

8 years agoFixed the maximum size of an ACL
Jean-Pierre André [Wed, 6 Apr 2016 08:02:23 +0000 (10:02 +0200)]
Fixed the maximum size of an ACL

Define the maximum size of an ACL as results from the maximum number of
sub-authorities defined in layout.h

8 years agoUsed a more portable way to force alignment in security.h
Jean-Pierre André [Wed, 6 Apr 2016 07:57:59 +0000 (09:57 +0200)]
Used a more portable way to force alignment in security.h

Defining an array of zero elements does not force alignment on some CPUs,
insert a filler.

8 years agoEnabled fallback to read-only mount when volume is hibernated
Jean-Pierre André [Wed, 6 Apr 2016 07:51:47 +0000 (09:51 +0200)]
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.

8 years agoAllowed kernel cacheing by lowntfs-3g when not using Posix ACLs
Jean-Pierre André [Wed, 6 Apr 2016 07:44:59 +0000 (09:44 +0200)]
Allowed kernel cacheing by lowntfs-3g when not using Posix ACLs

Kernel cacheing of file attributes is usually not used by ntfs-3g,
because it has defects when dealing with hard linked files and directory
permission checks. Kernel cacheing is however possible when using
lowntfs-3g and not using Posix ACLs.

8 years agoFixed bad test in fuse mount
Jean-Pierre André [Wed, 6 Apr 2016 07:42:16 +0000 (09:42 +0200)]
Fixed bad test in fuse mount

Apply a fix from the full fuse library

8 years agoSilenced fixup warnings when allocating a new MFT record
Jean-Pierre André [Wed, 6 Apr 2016 07:32:18 +0000 (09:32 +0200)]
Silenced fixup warnings when allocating a new MFT record

When creating a new MFT record, do not issue a warning if the current
record has bad fixups. These warnings are meaningless, difficult to
interpret and cause unneeded worries.

8 years agoAdded clarification about creating a partition to the ntfsclone manual
Jean-Pierre André [Wed, 6 Apr 2016 07:27:07 +0000 (09:27 +0200)]
Added clarification about creating a partition to the ntfsclone manual

Try to make clear the option --output feeds data into a partition, but
does not create the partition.

8 years agoUsed plugins to process reparse points
Jean-Pierre André [Wed, 6 Apr 2016 07:10:35 +0000 (09:10 +0200)]
Used plugins to process reparse points

The new "system compression" files used by Windows 10 make use of reparse
points to record the compression parameters, and a specific named data
stream is used to store the compressed data. With this patch, processing
of reparse points can be done by an external plugin only loaded as needed.
Junctions and symlinks, which are also based on reparse points, are now
processed by "internal plugins".

8 years agoAdded an option for preserving the full log file in ntfsclone
Jean-Pierre André [Wed, 6 Apr 2016 06:51:36 +0000 (08:51 +0200)]
Added an option for preserving the full log file in ntfsclone

Usually, only a few pages of the Windows log file are saved in an
ntfsclone image. This is inappropriate for building reference images
for recovering the log, and the --full-logfile option serves that
purpose.

8 years agoReworked decisions to undo related to unreadable records
Jean-Pierre André [Wed, 6 Apr 2016 06:44:38 +0000 (08:44 +0200)]
Reworked decisions to undo related to unreadable records

When an INDX or MFT record could not be read while undoing the creation
of this record, there is nothing to do. However if this was undoing the
deletion of the last entry in an index, a new void index block has to be
created.

8 years agoVersion 2016.2.22
Jean-Pierre André [Mon, 22 Feb 2016 07:28:50 +0000 (08:28 +0100)]
Version 2016.2.22

8 years agoFix compilation errors on OpenIndiana caused by missing limit macros.
Erik Larsson [Tue, 16 Feb 2016 19:43:00 +0000 (20:43 +0100)]
Fix compilation errors on OpenIndiana caused by missing limit macros.

8 years agoendians.h: Fix bad assumption of valid __BYTE_ORDER__ values.
Erik Larsson [Tue, 16 Feb 2016 19:29:56 +0000 (20:29 +0100)]
endians.h: Fix bad assumption of valid __BYTE_ORDER__ values.

On the OpenIndiana Hipster distribution, compiling with GCC 4.9 would
fail because __BYTE_ORDER__ was defined but not to any of the values
assumed to be associated with this define (__LITTLE_ENDIAN__ or
__BIG_ENDIAN__). Instead it was defined to either
__ORDER_LITTLE_ENDIAN__ or __ORDER_BIG_ENDIAN__. This caused
compilation to fail.

Fixed by checking that all referenced defines are in fact defined
before using them and adding an additional #elif clause for this newly
discovered condition.

8 years agontfsrecover.c: Fix compiler warning about uninitialized 'savebuf' usage.
Erik Larsson [Tue, 16 Feb 2016 08:38:12 +0000 (09:38 +0100)]
ntfsrecover.c: Fix compiler warning about uninitialized 'savebuf' usage.

The previous fix for the warning referred to 'prevbuf' being used
uninitialized and this is also what the compiler says. However
initializing 'prevbuf' doesn't make the warning go away and further
testing revealed that it is really 'savebuf' being possibly used prior
to initialization that is the source of the warning (the incorrect
warning message is probably an optimization-related gcc bug). So replace
previous ineffective fix with explicit initialization of 'savebuf'.

8 years agoFix compiler warnings about mismatching printf format / argument type.
Erik Larsson [Tue, 16 Feb 2016 08:30:49 +0000 (09:30 +0100)]
Fix compiler warnings about mismatching printf format / argument type.

For 64-bit (e.g. x86_64) Linux the 64-bit wide types resolve to long,
not long long as is the case in 32-bit (e.g. i386) Linux. So we need an
explicit cast to long long for 64-bit types since the format string must
specify the 'll' modifier in order to print 64-bit values.

8 years agoVersion 2016.2.15
Jean-Pierre André [Mon, 15 Feb 2016 15:32:03 +0000 (16:32 +0100)]
Version 2016.2.15

8 years agoSilenced a compiler warning for possibly uninitialized pointer
Jean-Pierre André [Mon, 15 Feb 2016 11:07:28 +0000 (12:07 +0100)]
Silenced a compiler warning for possibly uninitialized pointer

Some compilers issue a warning when a pointer is initialized in
both alternatives of a condition. Force an extra initialization
to avoid such warnings.

8 years agoSilenced a compiler warning for different types
Jean-Pierre André [Mon, 15 Feb 2016 11:02:10 +0000 (12:02 +0100)]
Silenced a compiler warning for different types

Some compilers issue a warning when the alternatives in a "? :"
expression have different signedness.

8 years agoAvoided pointer cast when checking record types
Jean-Pierre André [Mon, 15 Feb 2016 10:54:33 +0000 (11:54 +0100)]
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.

8 years agoUpdated the drivers copyrights
Jean-Pierre André [Fri, 12 Feb 2016 16:24:27 +0000 (17:24 +0100)]
Updated the drivers copyrights

Extend the copyright to 2016

8 years agoClosed the volume when a resizing is done
Jean-Pierre André [Fri, 12 Feb 2016 16:13:21 +0000 (17:13 +0100)]
Closed the volume when a resizing is done

Closing the volume is the way to sync the MFT to disk. When not doing
so, the MFT runlists in $DATA and $Bitmap are not synced if they have
been updated in the second resizing stage relative to runlists which
have grown outside their original MFT record.

8 years agoClosed the bad sector inode after updating the list
Jean-Pierre André [Fri, 12 Feb 2016 16:03:53 +0000 (17:03 +0100)]
Closed the bad sector inode after updating the list

Unlike in most cases, the bad sector inode has to be closed if it
was updated and required MFT extents (when there are a lot of bad
sectors and some of them were outside the truncated partition).
Not doing so causes the inode to not be fully synced to device.

8 years agoendians.h: Cast the result of const endianness macros to the right type.
Erik Larsson [Thu, 11 Feb 2016 13:19:41 +0000 (14:19 +0100)]
endians.h: Cast the result of const endianness macros to the right type.

This fixes compiler warnings emitted when you compare an le32 value with
e.g. 'const_cpu_to_le32(-1)' on a little-endian system, because
previously the expansion of the macro expression 'const_cpu_to_le32(-1)'
would be '(-1)' on a little-endian system but '(u32)((((u32)(-1) &
0xff000000u) >> 24) | (((u32)(-1) & 0x00ff0000u) >>  8) | (((u32)(-1) &
0x0000ff00u) <<  8) | (((u32)(-1) & 0x000000ffu) << 24))' on a
big-endian system, i.e. the type of the expanded expression would be
'int' (signed) in the little-endian case but 'u32' (unsigned) in the
big-endian case.

With this commit the type of the expanded expression will be 'le32' in
both the little-endian and the big-endian case.

8 years agontfs-3g_common.h: Fix improper type for 'dmtime' in ntfs_fuse_context_t.
Erik Larsson [Thu, 11 Feb 2016 13:06:53 +0000 (14:06 +0100)]
ntfs-3g_common.h: Fix improper type for 'dmtime' in ntfs_fuse_context_t.

This field is always assigned a signed value, and compared to other
signed values (ntfs_time values are signed little-endian 32-bit
integers).

This fixes two compiler warnings about signed/unsigned comparison.

8 years agomft.c: Fix compiler warning about mismatching format/argument type.
Erik Larsson [Thu, 11 Feb 2016 12:52:59 +0000 (13:52 +0100)]
mft.c: Fix compiler warning about mismatching format/argument type.

The expression is promoted to 'int' implicitly so we explicitly cast it
to 'u8'.

8 years agoefs.c: Fix incorrect type of local variables 'newsize' and 'oldsize'.
Erik Larsson [Mon, 8 Feb 2016 17:42:53 +0000 (18:42 +0100)]
efs.c: Fix incorrect type of local variables 'newsize' and 'oldsize'.

These variable are only ever assigned to/from s64 values, so their type
should be s64, not u64. This fixes a compiler warning about
signed/unsigned comparison.

8 years agontfslabel.c: Fix incorrect label buffer being NULL-terminated.
Erik Larsson [Mon, 8 Feb 2016 17:32:24 +0000 (18:32 +0100)]
ntfslabel.c: Fix incorrect label buffer being NULL-terminated.

The UTF-16LE label buffer containing the result of mbs2ucs is the one
that should be NULL-terminated when the label is longer than permitted.
Not the input buffer, which is a function parameter assumed to be
NULL-terminated anyway.

8 years agoChange type of all LSN struct members in ntfsrecover.h to leLSN.
Erik Larsson [Fri, 29 Jan 2016 11:36:06 +0000 (12:36 +0100)]
Change type of all LSN struct members in ntfsrecover.h to leLSN.

This is done to match the type of the LSN struct members in layout.h.
The effect of this change is that while these members were declared with
the le64 type previously, leLSN resolves to sle64. I.e. what was
previously unsigned fields are now signed.

Following this change we also need to switch over a few macros from
unsigned to signed versions in the code that uses these struct
definitions.

8 years agoplaylog.c: Use const macro for byteswapping const expression.
Erik Larsson [Fri, 29 Jan 2016 09:49:52 +0000 (10:49 +0100)]
playlog.c: Use const macro for byteswapping const expression.

8 years agoplaylog.c: Fix improper byteswapping macros used for sle64 members.
Erik Larsson [Fri, 29 Jan 2016 09:49:25 +0000 (10:49 +0100)]
playlog.c: Fix improper byteswapping macros used for sle64 members.

8 years agoMerge endianness fixes.
Erik Larsson [Thu, 28 Jan 2016 08:22:42 +0000 (09:22 +0100)]
Merge endianness fixes.

Conflicts:
libntfs-3g/attrib.c

8 years agontfscmp.c: Fix missing byteswap of little-endian attribute type value.
Erik Larsson [Thu, 28 Jan 2016 08:11:55 +0000 (09:11 +0100)]
ntfscmp.c: Fix missing byteswap of little-endian attribute type value.

8 years agontfsmove.c: Fix multiple cases of raw usage of little-endian fields.
Erik Larsson [Wed, 27 Jan 2016 14:28:55 +0000 (15:28 +0100)]
ntfsmove.c: Fix multiple cases of raw usage of little-endian fields.

There were multiple cases of little-endian fields being used as
CPU-endian without byte swapping. This would result in incorrect
behaviour on big-endian systems.

8 years agontfsdump_logfile.c: Fix use of wrong byteswapping macro for le16 field.
Erik Larsson [Wed, 27 Jan 2016 14:26:51 +0000 (15:26 +0100)]
ntfsdump_logfile.c: Fix use of wrong byteswapping macro for le16 field.

8 years agontfsdump_logfile.c: Fix incorrectly parenthesized expression.
Erik Larsson [Wed, 27 Jan 2016 14:24:52 +0000 (15:24 +0100)]
ntfsdump_logfile.c: Fix incorrectly parenthesized expression.

On big-endian systems the result of the '!=' operation would be
endian-swapped rather than the first argument (which must have been the
intended action).

8 years agontfsck.c: Fix comparing le32 values as u32.
Erik Larsson [Wed, 27 Jan 2016 14:23:13 +0000 (15:23 +0100)]
ntfsck.c: Fix comparing le32 values as u32.

This is harmless except when we do strict endianness checking, in which
case this results in a compile error. Fixed by converting values to
CPU endianness before comparing them.

8 years agontfsck.c: Fix comparison between little-endian and native-endian data.
Erik Larsson [Wed, 27 Jan 2016 14:21:05 +0000 (15:21 +0100)]
ntfsck.c: Fix comparison between little-endian and native-endian data.

This comparison would yield the wrong result on big-endian systems.

8 years agontfstruncate.c: Fix mixed endianness usage of variable 'i'.
Erik Larsson [Tue, 26 Jan 2016 09:28:38 +0000 (10:28 +0100)]
ntfstruncate.c: Fix mixed endianness usage of variable 'i'.

In 'dump_resident_attr_val', 'i' was sometimes used as a native-endian
'int'-precision string length value and sometimes used as a little-
endian 16-bit flags value. This type of mixed usage is bad practice and
results in a hard error when strict endianness checking is used.

Fixed by introducing new variable 'flags' to hold the little-endian 16-
bit flags value.

8 years agontfstruncate.c: Fix incorrect type for CPU-endian value in 'ucstos'.
Erik Larsson [Tue, 26 Jan 2016 09:19:44 +0000 (10:19 +0100)]
ntfstruncate.c: Fix incorrect type for CPU-endian value in 'ucstos'.

8 years agontfstruncate.c: Fix conflicting endianness for variable 'attr_type'.
Erik Larsson [Tue, 26 Jan 2016 09:18:51 +0000 (10:18 +0100)]
ntfstruncate.c: Fix conflicting endianness for variable 'attr_type'.

If the attribute type is specified by the user, 'attr_type' was assigned
a CPU-endian value, however if the attribute type was not specified it
would be assigned the attribute type AT_DATA, which is a little-endian
value. The rest of the code seems to assume that 'attr_type' is
CPU-endian, so this is clearly a bug.

Resolved by fixing the endianness of the variable at little-endian,
converting the input value to little-endian when specified.

8 years agontfstruncate.c: Fix mixed endianness usage of variable 'u'.
Erik Larsson [Tue, 26 Jan 2016 09:03:36 +0000 (10:03 +0100)]
ntfstruncate.c: Fix mixed endianness usage of variable 'u'.

In 'dump_attr_record' the variable 'u' was first used to store a
CPU-endian 32-bit value, and then to store a 16-bit little-endian value.
This is bad practice and results in a hard error when strict endian type
checking is used.

Fixed by storing the 16-bit little-endian flags value in a new variable
'flags'.

8 years agontfs-3g.c: Fix raw usage of inode time fields without byteswapping.
Erik Larsson [Tue, 26 Jan 2016 06:55:45 +0000 (07:55 +0100)]
ntfs-3g.c: Fix raw usage of inode time fields without byteswapping.

8 years agovolume.c: Fix passing bad pointer type to ntfs_is_[baad|mft]_recordp.
Erik Larsson [Mon, 25 Jan 2016 10:31:12 +0000 (11:31 +0100)]
volume.c: Fix passing bad pointer type to ntfs_is_[baad|mft]_recordp.

8 years agomst.c: Fix mixed native/little-endian usage of variable 'usn'.
Erik Larsson [Mon, 25 Jan 2016 10:30:13 +0000 (11:30 +0100)]
mst.c: Fix mixed native/little-endian usage of variable 'usn'.

8 years agoreparse.c: Fix big-endian bug when converting file name to lowercase.
Erik Larsson [Mon, 4 Jan 2016 09:19:05 +0000 (10:19 +0100)]
reparse.c: Fix big-endian bug when converting file name to lowercase.

When looking up the lowercase equivalent of a Unicode character in
ntfs_fix_file_name, no byte swapping was performed on the ntfschar used
as index into the 'locase' array. This would lead to very strange
results on big-endian systems.

8 years agoFix inverted usage of endian conversion macros.
Erik Larsson [Mon, 4 Jan 2016 09:08:15 +0000 (10:08 +0100)]
Fix inverted usage of endian conversion macros.

This is mostly a semantic issue since the end result would be the same.

8 years agoFix incorrect usage of native/little-endian types, signed types, etc.
Erik Larsson [Mon, 21 Dec 2015 22:55:31 +0000 (23:55 +0100)]
Fix incorrect usage of native/little-endian types, signed types, etc.

This is harmless with regard to code generation but if we turn on strict
type checking these type mismatches will result in errors.

8 years agoFix endianness issues in log and terminal output.
Erik Larsson [Mon, 21 Dec 2015 22:31:09 +0000 (23:31 +0100)]
Fix endianness issues in log and terminal output.

This commit addresses issues where little-endian variables are emitted
raw to a log or output stream which is to be interpreted by the user.

Outputting data in non-native endianness can cause confusion for anybody
attempting to debug issues with a file system.

8 years agoFix code to use const_cpu_to_X/const_X_to_cpu macros for constants.
Erik Larsson [Mon, 21 Dec 2015 22:21:00 +0000 (23:21 +0100)]
Fix code to use const_cpu_to_X/const_X_to_cpu macros for constants.

This enables the compiler to optimize this code in cases where compiler
support for endianness swapping is not present.

8 years agoendians.h: Add const endian conversion macros for s{l,b}e{16,32,64}.
Erik Larsson [Mon, 21 Dec 2015 22:05:36 +0000 (23:05 +0100)]
endians.h: Add const endian conversion macros for s{l,b}e{16,32,64}.

8 years agoFixed accessing next log buffer only when it exists
Jean-Pierre André [Tue, 1 Dec 2015 10:12:53 +0000 (11:12 +0100)]
Fixed accessing next log buffer only when it exists

Do not locate the next log buffer until it is known to exist.

8 years agoFixed reporting action states when restart page appears outdated
Jean-Pierre André [Tue, 1 Dec 2015 10:10:48 +0000 (11:10 +0100)]
Fixed reporting action states when restart page appears outdated

If start buffer is more recent than restart, we update committed LSN
with last record LSN of block (last_end_lsn) while applying action but
forget about it while printing records with -f for investigation
purpose.

Note that while applying actions we use start_buffer to calculate
latest page out of block 2 and block 3 and then from latest take
committed LSN. For -f we don't need buffers so we just compare
directly with committed LSN from restart.

(contributed by Rakesh Pandit)

8 years agoRejected invalid null reparse tag
Jean-Pierre André [Tue, 1 Dec 2015 10:06:11 +0000 (11:06 +0100)]
Rejected invalid null reparse tag

The null reparse tag is considered invalid by Windows, so do the same.

8 years agoFixed returning the trimming count to fstrim(8)
Jean-Pierre André [Tue, 1 Dec 2015 10:00:24 +0000 (11:00 +0100)]
Fixed returning the trimming count to fstrim(8)

When used with the option -v, fstrim(8) reported the maximum trimming count
because the correct value was not returned to the ioctl call.

8 years agoDefined reparse tag for system compression
Jean-Pierre André [Tue, 1 Dec 2015 09:56:01 +0000 (10:56 +0100)]
Defined reparse tag for system compression

The new compression formats used by Windows 10 uses reparse data, and
a new reparse tag which it is useful to define even though these formats
is not yet supported by ntfs-3g.

8 years agoFixed special case of decompressing a runlist
Jean-Pierre André [Fri, 20 Nov 2015 15:17:48 +0000 (16:17 +0100)]
Fixed special case of decompressing a runlist

When the unreadable directory has an ATTRIBUTE_LIST attribute and an
INDEX_ALLOCATION attribute occupying split over several extents, the first
of which defines a single cluster, the first INDEX_ALLOCATION extent has
lowest_vcn=0 and highest_vcn=0, and the second one has lowest_vcn=1.

This unusual case, which can be created by the combination of a small
volume and near-full MFT records, triggers some special-case behavior in
ntfs_mapping_pairs_decompress_i(). That behavior is incorrect if the
attribute's first extent only contains a single cluster, since in that case
highest_vcn=0 as well.

This configuration has been tested on Windows and it *is* able to
successfully read the directory.  This supports the hypothesis that the
volume is valid and NTFS-3g has a bug on the read side.

This bug could, in theory, occur with any non-resident attribute, not just
INDEX_ALLOCATION attributes.

(Contributed by Eric Biggers)

8 years agoFixed headers of log play functions in playlog
Jean-Pierre André [Fri, 20 Nov 2015 15:14:16 +0000 (16:14 +0100)]
Fixed headers of log play functions in playlog

The functions were made static with a textual description.

8 years agoFixed missing error return in playlog
Jean-Pierre André [Fri, 20 Nov 2015 15:11:15 +0000 (16:11 +0100)]
Fixed missing error return in playlog

No error was returned from reading a protected record which is part of
an unreadable raw cluster.