Commit Graph

4949 Commits (c9b795489ee24cc2b0d812c797c102ebd88a62c6)
 

Author SHA1 Message Date
Erik Larsson c9b795489e Merge version 2016.2.22 into the strict endians branch.
Conflicts:
	libntfs-3g/volume.c
2016-02-22 09:40:35 +01:00
Jean-Pierre André 6b5e47f094 Version 2016.2.22 2016-02-22 08:28:50 +01:00
Erik Larsson 038a45a8a1 Fix compilation errors on OpenIndiana caused by missing limit macros. 2016-02-16 20:43:00 +01:00
Erik Larsson 9d1360b282 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.
2016-02-16 20:29:56 +01:00
Erik Larsson 9dee659190 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'.
2016-02-16 09:38:12 +01:00
Erik Larsson 62b5c91420 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.
2016-02-16 09:30:49 +01:00
Jean-Pierre André 1ae297378c Version 2016.2.15 2016-02-15 16:32:03 +01:00
Jean-Pierre André 4f6fb651c2 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.
2016-02-15 12:07:28 +01:00
Jean-Pierre André 941ec4762f Silenced a compiler warning for different types
Some compilers issue a warning when the alternatives in a "? :"
expression have different signedness.
2016-02-15 12:02:10 +01: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
Jean-Pierre André f655192f26 Updated the drivers copyrights
Extend the copyright to 2016
2016-02-12 17:24:27 +01:00
Jean-Pierre André 6548d91f73 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.
2016-02-12 17:13:21 +01:00
Jean-Pierre André 5edb3ec920 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.
2016-02-12 17:03:53 +01:00
Erik Larsson a207d4e86a 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.
2016-02-11 14:19:41 +01:00
Erik Larsson f463919310 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.
2016-02-11 14:06:53 +01:00
Erik Larsson abb2266147 mft.c: Fix compiler warning about mismatching format/argument type.
The expression is promoted to 'int' implicitly so we explicitly cast it
to 'u8'.
2016-02-11 13:52:59 +01:00
Erik Larsson 33cb3087b5 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.
2016-02-08 18:42:53 +01:00
Erik Larsson 0b378fd177 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.
2016-02-08 18:32:24 +01:00
Erik Larsson 3e3ef8901c Fixes for making strict endians branch compile after merge. 2016-02-05 18:04:22 +01:00
Erik Larsson 34bb449324 Merge branch 'edge' into edge.strict_endians
Conflicts:
	libntfs-3g/dir.c
	libntfs-3g/index.c
	libntfs-3g/runlist.c
	ntfsprogs/ntfsfix.c
	ntfsprogs/ntfsinfo.c
2016-02-05 18:02:02 +01:00
Erik Larsson a2efc3ec9f 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.
2016-01-29 12:36:06 +01:00
Erik Larsson ee4c48f4b1 playlog.c: Use const macro for byteswapping const expression. 2016-01-29 10:49:52 +01:00
Erik Larsson 81fce3b70e playlog.c: Fix improper byteswapping macros used for sle64 members. 2016-01-29 10:49:25 +01:00
Erik Larsson 9893ea9ee6 Merge endianness fixes.
Conflicts:
	libntfs-3g/attrib.c
2016-01-28 09:22:42 +01:00
Erik Larsson 760ddd62cf Merge endianness fixes required for the strict endians code to compile.
Conflicts:
	libntfs-3g/attrib.c
	libntfs-3g/dir.c
	libntfs-3g/logfile.c
	libntfs-3g/volume.c
	ntfsprogs/ntfscp.c
	ntfsprogs/ntfsdump_logfile.c
	ntfsprogs/ntfsfallocate.c
	ntfsprogs/ntfsfix.c
	ntfsprogs/ntfsinfo.c
	ntfsprogs/ntfsresize.c
	ntfsprogs/ntfstruncate.c
2016-01-28 09:21:09 +01:00
Erik Larsson e37258bf01 ntfscmp.c: Fix missing byteswap of little-endian attribute type value. 2016-01-28 09:11:55 +01:00
Erik Larsson 1984a714e5 Enable strict checking of endian-specific types.
Strict checking of endian-specific types mean that types that have a
fixed endianness in the data representation of the value are now defined
as complex types, enabling the compiler to catch mixed usage of these
types with native-endian types. This allows us to catch most issues
relating to usage on big-endian systems since we cannot anymore assign a
fixed-endian value to a native-endian variable and vice-versa without a
compiler error.

The downside is that we aren't able to apply simple binary operators to
the fixed-endian types anymore since they are complex... so all
combining fixed-endian constants and values with |, &, etc. and
comparison with ==, !=, <=, etc. must be replaced with a macro which
unpacks the wrapped value and performs the operation. Lots of changes,
lots of work but in the interest of good code quality it's justified.
2016-01-28 08:29:03 +01:00
Erik Larsson 7e85b4ccd4 Replace switch statements for le/be types with equivalent if statements.
Since the le/be-types are now typedef'd to aggregate types, we can't use
those in switch statements.
2016-01-28 08:29:02 +01:00
Erik Larsson 1fdd4fbb71 Replace all le64 "not" negations with le64_not(...). 2016-01-28 08:29:01 +01:00
Erik Larsson 597adff2bb Replace all le32 "not" negations with le32_not(...). 2016-01-28 08:29:00 +01:00
Erik Larsson 85588b8e92 Replace all le16 "not" negations with le16_not(...). 2016-01-28 08:28:59 +01:00
Erik Larsson 46dfbe17ec Replace all le64 "xor" calculations with le64_xor(...). 2016-01-28 08:28:58 +01:00
Erik Larsson 14190d81b3 Replace all le32 "xor" calculations with le32_xor(...). 2016-01-28 08:28:57 +01:00
Erik Larsson 1118a56eea Replace all le16 "xor" calculations with le16_xor(...). 2016-01-28 08:28:56 +01:00
Erik Larsson cc414d9e8b Replace all le64 "or" calculations with le64_or(...). 2016-01-28 08:28:55 +01:00
Erik Larsson 1500a77676 Replace all le32 "or" calculations with le32_or(...). 2016-01-28 08:28:54 +01:00
Erik Larsson b61e7ff449 Replace all le16 "or" calculations with le16_or(...). 2016-01-28 08:28:53 +01:00
Erik Larsson 66d7b85573 Replace all le64 "and" calculations with le64_and(...). 2016-01-28 08:28:52 +01:00
Erik Larsson 7b3700ed5e Replace all le32 "and" calculations with le32_and(...). 2016-01-28 08:28:51 +01:00
Erik Larsson 2b4c3a618c Replace all le16 "and" calculations with le16_and(...). 2016-01-28 08:28:50 +01:00
Erik Larsson e970b57c74 Replace all le32 zero "and" test conditions with le32_andz(...). 2016-01-28 08:28:49 +01:00
Erik Larsson 9f5ad52e5f Replace all le32 non-zero "and" test conditions with !le32_andz(...). 2016-01-28 08:28:48 +01:00
Erik Larsson 1b7bfaa133 Replace all le16 zero "and" test conditions with le16_andz(...). 2016-01-28 08:28:47 +01:00
Erik Larsson 35c72761c7 Replace all le16 non-zero "and" test conditions with !le16_andz(...). 2016-01-28 08:28:46 +01:00
Erik Larsson 01c493f16c Replace all be16 zero test conditions with "be16_cmpz(...)". 2016-01-28 08:28:45 +01:00
Erik Larsson 5097bb9ea3 Replace all sle64 zero test conditions with "sle64_cmpz(...)". 2016-01-28 08:28:44 +01:00
Erik Larsson 97ccd587d6 Replace all sle64 non-zero test conditions with "!sle64_cmpz(...)". 2016-01-28 08:28:43 +01:00
Erik Larsson 65eea3fe0a Replace all le64 zero test conditions with "le64_cmpz(...)". 2016-01-28 08:28:42 +01:00
Erik Larsson 17a2c5f58e Replace all le64 non-zero test conditions with "!le64_cmpz(...)". 2016-01-28 08:28:41 +01:00
Erik Larsson ed87a4dffa Replace all le32 zero test conditions with "le32_cmpz(...)". 2016-01-28 08:28:40 +01:00