Commit Graph

688 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
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 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 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 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 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 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 9f5ad52e5f Replace all le32 non-zero "and" test conditions with !le32_andz(...). 2016-01-28 08:28:48 +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 97ccd587d6 Replace all sle64 non-zero test conditions with "!sle64_cmpz(...)". 2016-01-28 08:28:43 +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 18990412fa Replace all le32 non-zero test conditions with "!le32_cmpz(...)". 2016-01-28 08:28:39 +01:00
Erik Larsson 90697bb5ab Replace all le16 non-zero test conditions with "!le16_cmpz(...)". 2016-01-28 08:28:37 +01:00
Erik Larsson c29924872f Replace all be32 usage of the '==' operation with "be32_eq(...)". 2016-01-28 08:28:36 +01:00
Erik Larsson e616a84f21 Replace all be16 usage of the '==' operation with "be16_eq(...)". 2016-01-28 08:28:35 +01:00
Erik Larsson 7b85755080 Replace all sle64 usage of the '==' operation with "sle64_eq(...)". 2016-01-28 08:28:33 +01:00
Erik Larsson 94589cde03 Replace all sle16 usage of the '==' operation with "sle16_eq(...)". 2016-01-28 08:28:31 +01:00
Erik Larsson 7a88d7821e Replace all le64 usage of the '==' operation with "le64_eq(...)". 2016-01-28 08:28:28 +01:00
Erik Larsson 011a9e9e5e Replace all le32 usage of the '==' operation with "le32_eq(...)". 2016-01-28 08:28:26 +01:00
Erik Larsson 347bdf21ec Replace all le16 usage of the '==' operation with "le16_eq(...)". 2016-01-28 08:28:23 +01:00
Erik Larsson 9cf04fd2cd 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.
2015-12-21 23:55:31 +01:00
Erik Larsson dfa4a6647f 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.
2015-12-21 23:21:00 +01:00
Erik Larsson 58bb59487c endians.h: Add const endian conversion macros for s{l,b}e{16,32,64}. 2015-12-21 23:05:36 +01:00
Jean-Pierre André 730776b0e5 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.
2015-12-01 10:56:01 +01:00
Erik Larsson 9191d85e28 Use appropriate little-endian/big-endian types in struct definitions.
On-disk struct definitions used native types (u16/u32/u64/s16/s32/s64),
which doesn't say anything about the intended interpretation of the
data. The intention of having little-endian-specific types and
big-endian-specific types must have been to clarify interpretation of
data and intentions in the code. Therefore it seems reasonable to use
these types in struct definitions to clarify what data represention is
used to encode field data.

Because some struct members in layout.h are big-endian, this change also
means moving the duplicated definitions for big-endian byteswapping
macros and big-endian types found in acls.h and security.h to the
appropriate locations in endians.h and types.h respectively in order to
make them available for the struct definitions in layout.h.
2015-10-03 12:58:08 +02:00
Jean-Pierre André 9c2657b4ae Made use of fuse module cache on OpenIndiana
The fuse cache does not handle properly hard-linked files, so ntfs-3g
traditionally disables it by using a null time-out. With an upgrade of
the fuse kernel module on OpenIndiana, cacheing of non hard-linked files
is now possible, so use it.
2015-09-30 08:36:37 +02:00
Jean-Pierre André 2c11aaa2aa Fixed the range of valid subauthority counts in a SID
ntfs_valid_sid() required that the subauthority count be between 1 and 8
inclusively.  However, Windows permits more than 8 subauthorities as well
as 0 subauthorities:

  - The install.wim file for the latest Windows 10 build contains a file
    whose DACL contains a SID with 10 subauthorities.
    ntfs_set_ntfs_acl() was failing on this file.

  - The IsValidSid() function on Windows returns true for subauthority
    less than or equal to 15, including 0.

There was actually already a another SID validation function that had the
Windows-compatible behavior, so I merged the two together.

Contributed by Eric Biggers
2015-07-14 08:37:01 +02:00
Jean-Pierre André e40b86a86c Upgraded the upper-case table as defined by Windows 7
Newer versions of Windows use more recent definitions of upper-case
table defined by the Unicode consortium. Now using the same table as
Windows 7, windows 8 and Windows 10. This only has an effect on file
systems newly created by mkntfs.
2015-04-17 11:03:58 +02:00
Jean-Pierre André 39c7d8538d Set the fuse protocol fall back to 7.12 when available
The support for ioctls has been added to fuse when using protocol 7.18,
and an equivalent upgrade has been done in fuse lite with commit [ae9aee].
For old kernels, a fall back to protocol 7.8 was implemented, but this
appears not to be supported in not-so-old kernels (e.g. 2.6.35).
With this patch, the fall back protocol is set to 7.12 or to the highest
level supported by the kernel.
2014-11-10 08:52:23 +01:00
Jean-Pierre André 54833dffc0 Inserted missing ea.h and ioctl.h in devel file list
ea.h and ioctl.h were not mentioned in include/ntfs-3g/Makefile.am
so they were not released as public headers in devel files.
2014-09-02 09:39:12 +02:00
Jean-Pierre André f4e3f126df Implemented fstrim(8)
fstrim(8) discards unused blocks on a mounted filesystem. It is useful for
solid-state drives (SSDs) and thinly-provisioned storage.
Only trimming the full device (with no option) is supported.

Contributed by Richard W.M. Jones
2014-07-31 14:03:11 +02:00
Jean-Pierre André ae9aeebbbf Upgraded fuse-lite to support ioctls
This is backporting code from the full FUSE library in order to support
ioctls. The fuse protocol level negociated is now 7.18 instead of 7.8.
A fallback protocol to 7.8 is provided for compatibility with older kernels.

32-bit ioctls are not supported by a 64-bit library
2014-07-30 16:44:18 +02:00
Jean-Pierre André bfc5f3dd3d Fixed processing umask when Posix ACLs are compiled in but not enabled
When Posix ACLs are used, the umask is ignored and the initial permissions
of created files are taken for the parent directory. However the umask
should still be used when the Posix ACLs are not enabled in the mount
options.
2014-06-23 11:20:21 +02:00
Jean-Pierre André 70e5b1b250 Fixed inserting a new ACL after they have been wiped out by chkdsk
chkdsk deletes the ACLs when they are bad or when they are not used any
more. This fixes inserting a new ACL after the previously last ACL (or
even all of them) was deleted.
2014-04-23 09:53:13 +02:00
Jean-Pierre André ae459dd7b3 Implemented an extended attribute to get/set EAs
The new extended attribute "system.ntfs_ea" can now be used to get or
set the set of EAs of a file or directory.
2014-04-12 09:22:17 +02:00
Jean-Pierre André 543b17b7ef Rejected reserved files names when option windows_names is set
Windows applies legacy restrictions to file names, so when the option
windows_names is applied, reject the same reserved names, which are
CON, PRN, AUX, NUL, COM1..COM9, and LPT1..LPT9
2014-03-11 10:56:31 +01:00
Jean-Pierre André e6c46d4fa0 Used MFT record 15 for the first extent to MFT:DATA
When the runlist of the data attribute of MFT has to be split across
several extents, the location of each extent has to be known from the
runlist present in previous extents. So, force the first extent into
record 15 to avoid a bad layout.
2014-03-11 10:16:26 +01:00