Commit Graph

639 Commits

Author SHA1 Message Date
Jean-Pierre André
34d29fe0b0 Fixed reparse data check for non-Microsoft tags
Windows requires non-Microsoft reparse points (identified by having bit
31 of the reparse tag clear) to have a 16-byte GUID following the regular
reparse point header.  This GUID is not, and cannot, be included in the
"reparse data length" field.

(Contributed by Eric Biggers)
2015-11-09 16:14:31 +01:00
Jean-Pierre André
37bd6661d4 Fixed getting space for making an index non resident
Under some rare condition there is no space in an MFT entry to make
an index non-resident, and the index root has to be moved to an extent.
This fix cares for the situation when the attribute list was inserted
beforehand.
2015-11-09 16:09:52 +01:00
Jean-Pierre André
1aaaa8fac1 Wrote as much data as possible in compressed attribute pwrite
When writing to compressed data, the function ntfs_attr_pwrite()
cannot cross a compression block border. This is a problem for archivers
which rely on libntfs-3g, so the function is now wrapped in another one
which restarts the writing as needed.
2015-11-09 16:00:31 +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é
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
Erik Larsson
c9771d0509 unistr.c: Cleanup of OS X Unicode normalization code.
Normalize coding conventions to fit in with the rest of NTFS-3G,
including line breaks at column 80.
2015-06-23 06:43:17 +02:00
Jean-Pierre André
5741f54529 Zeroed uninitialized bytes before writing compressed data
Compressed records may be written as full clusters even though cluster
tails are meaningless. This is to avoid the lower levels doing a read-
modify-write cycle. Be sure to zero the meaningless bytes to avoid
leaking information.

Contributed by Eric Biggers
2015-04-17 11:31:47 +02:00
Jean-Pierre André
46716df541 Simplified NTFS ACLs when group same as owner and same permission as all
When the owner and the group of a file have the same SID, and permissions
for the group is the same as permissions for other, no ACE is needed for
the group.
2015-04-17 11:17:51 +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é
e24ea68632 Removed a temporary debug comment (cosmetic)
The comment was a left over from some debugging action.
2015-04-17 10:56:34 +02:00
Jean-Pierre André
b249246e9f Defended against reusing data from an invalid MFT record
An unused MFT record may show a bad length, leading to fetch fixups from
unallocated memory when allocating the record to a new file. So check
the length before applying the fixups. Such records have been found after
the MFT has been reallocated by a defragmenter, and they are not cleaned
by chkdsk.
2015-04-17 10:41:04 +02:00
Jean-Pierre André
8fb58de762 Updated the read-only flag even when the security attribute was cached
When chmod'ing a file, no new ACL has to be created if the one needed
is already present in the cache. However the read-only flag may have
to be updated, so that it is kept as the opposite of S_IWUSR.
2015-04-17 10:35:26 +02:00
Jean-Pierre André
3fb1deb13b Fixed getting sector size from a partition image (Windows variant)
On Windows, when processing a partition image, get the sector size
from the boot sector instead of the containing partition.
2015-04-17 09:21:58 +02:00
Jean-Pierre André
bbeebd5a15 Rephrased the warning for trimming not supported (cosmetic)
The initial text looked like an error message
2015-04-17 09:06:22 +02:00
Jean-Pierre André
3a8d923c13 Fixed accessing security attributes the old way on ntfs 3.x
When the security attribute is present, chkdsk may set a null security id
in the standard attributes, and this should not be considered as an error.
(this partially reverts commit [70e5b1])
2014-11-10 08:43:32 +01:00
Jean-Pierre André
b6152757c5 Reengineered the compression algorithm
This patch changes the algorithm to use hash chains instead of binary
trees, with much stronger hashing.  It also introduces useful (for
performance) parameters, such as the "nice match length" and "maximum
search depth", that are similar to those used in other commonly used
compression algorithms such as zlib's DEFLATE implementation.

The speed improvement is very significant, with some loss of compression
rate. The compression rate is still better than then Windows one.

Contributed by Eric Biggers
2014-09-02 09:45:16 +02:00
Jean-Pierre André
c26a519da1 Fixed fstrim(8) applied to partitions
The new way goes via /sys/dev/block/MAJOR:MINOR to map partitions to
devices and get discard parameters of the parent device. It also ensures
that the partition is aligned to the discard block size.

Contributed by Richard W.M. Jones
2014-08-04 17:39:50 +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é
935ce8d08b Fixed inappropriate description of ntfs_build_basic_posix() (cosmetic)
Fixed a missing description and wrongly copied+pasted comment
2014-06-23 11:46:58 +02:00
Jean-Pierre André
ab8f021861 Fixed checking permissions when Posix ACLs are compiled in but not enabled
When the Posix ACLs are not enabled in the mount options, the permission
checks should not take into account the extra owners and groups of the
file.
2014-06-23 11:26:00 +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é
973949964c Fixed ownership of files created by root with no user mapping
Ownership of files should always represent the creator of files.
This fixes a situation, currently disabled, where there is no user
mapping and the owner of the parent directory is used as the owner
of the created file.
2014-06-23 11:11:07 +02:00
Jean-Pierre André
952917bccf Fixed const violation in win32_io.c (cosmetic)
Fixed the read-modify-write procedure to be compatible with the
write-only one to avoid violating the "const" attibute of the latter.
2014-06-23 10:46:31 +02:00
Jean-Pierre André
37862daf83 Fixed getting inherited security ids from cache
When using Windows inheritance, the cacheing of ACLs for files created
within a directory only depended on the directory. Actually it also
depends on the user who creates the file. With the patch, only the ACLs
created by the owner of the directory are cached.
2014-05-22 09:52:42 +02:00
Jean-Pierre André
e8c43f434b Fixed checking static groups against process owner
When grouping of users are determined from /etc/group (a compile-time
option not currently used), the groups examined for checking access rights
to a file were wrongly derived from the uid of the file instead of the
uid of the current process.
2014-05-22 09:38:47 +02:00
Jean-Pierre André
8390ac4dee Recognized interactive users as any user
Since Vista, the standard directory /Users/Public which should be accessed
by any user is actually restricted to a few group of users, among them
the interactive ones. To make this directory accessible without using
the Posix ACLs, all Linux users are considered as interactive.
However, when Posix ACLs are used, users supposed to be interactive have
to be put into a secondary group mapped to the equivalent Windows group.
2014-05-22 09:30:07 +02:00
Jean-Pierre André
38dcb707ef Improved the ownership definition when inheriting and user mapping fails
When using the Windows permission inheritance mode and the current user
has not been mapped, try to derive a reasonable user from the parent
directory.
2014-05-22 09:19:52 +02:00
Jean-Pierre André
c2af343c03 Improved the conditions for double inheritance of an ACE
The Windows-type inheritance of an ACE may imply creating two ACE's : one
for access and one for further inheritance. The conditions for doing so,
and the flags set on created ACE were sometimes wrong.
Note : the rules have been derived from testing multiple situations, but
there still are some gray cases.
2014-05-22 09:07:43 +02:00
Jean-Pierre André
eefa41c385 Allowed group mapping of a few well-known SIDs
Since Vista, Windows defines a /Users/Public directory supposed to be
public, but actually only allowed to a few user categories (interactive,
batch, etc.) This patch makes possible to create equivalent Unix groups
and group users the same way as in Windows. Posix ACLs have to be enabled
for access to /Users/Public to be allowed to several groups.
2014-05-22 08:36:41 +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é
25d0f163ee Mapped the runlist when filling an initial hole
A bug was introduced by commit d2c7d40a2b :
when the beginning of a file was a hole and the runlist span over several
MFT extents, the runlist was not mapped on filling the initial hole.
This lead to a crash when using torrent to download big files.
2014-04-12 09:32:59 +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é
fb88692394 Implemented updating an encrypted file in ntfsdecrypt
Existing encrypted files can be updated provided the encryption method
and key can be extracted from the LOGGED_UTILITY_STREAM attribute.
2014-03-11 11:10:33 +01: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é
15f300412a Fixed displaying the correct sector number in error message
When opening a volume, the availability of the last sector is checked,
but the error message mentioned a wrong sector.
2014-03-11 10:37:27 +01:00
Jean-Pierre André
b80d33785a Fixed marking device as closed (Windows variant)
When closing a device, the flag keeping track of open state was not reset,
and this prevented opening again (native Windows variant only).
2014-03-11 10:32:39 +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
Jean-Pierre André
ea8e192613 Traced dirtying runlists and updated them accordingly
Use a new flag to trace changes to a runlist and avoid recomputing the
runlist when no actual change occurred.
2014-03-11 10:11:00 +01:00
Jean-Pierre André
d2c7d40a2b Avoided full runlist updating in more situations
When a hole in a sparse file was filled, the runlist was fully recomputed.
When a sparse file spans over several MFT extents, this patch leads to
only recompute the runlist from the modified extent to the end.
2014-03-11 10:04:54 +01:00
Jean-Pierre André
f0c5c2a54f Ignored unmapped regions when checking whether sparse
Updating an attribute may imply decompressing runlists which are not
contiguous, leaving an unmapped region between them. When checking whether
the attribute has been made sparse, such unmapped regions should be ignored
This mostly happens after updating an index. (fix by Forrest Liu)
2013-12-17 10:39:55 +01:00
Jean-Pierre André
5b38218f0b Logged more details when an attribute is not found
Log the inode number and attribute type when an attribute is not found.
This simplifies identifying relevant ones among such log messages.
2013-09-20 16:20:02 +02:00
Jean-Pierre André
91a44b438c Allowed DACLs to to not have any ACE
Windows server 2012 apparently uses files with no ACEs in their DACL,
thus denying any access to any process except system backup.
Such DACLs should however be considered valid.
2013-09-20 16:14:55 +02:00
Jean-Pierre André
89af38f687 Fixed expanding a resident attribute without inserting holes
When calling ntfstruncate() to expand a resident attribute, the function
is called again recursively, losing the requirement for not inserting
holes. This is for forwarding the requirement (used by ntfscp).
2013-09-09 15:27:38 +02:00
Jean-Pierre André
1f7fd0160f Fixed testing whether a stream has been wiped out
When testing whether a stream has been wiped out for possibly changing
its compression status, only the non-resident case was considered.
This fixes the test for streams which were never made non-resident.
2013-09-09 15:19:50 +02:00
Jean-Pierre André
33bbb9d009 Fixed creating a new image file on Windows
Creating a new image file (clone or metadata) by ntfsclone failed on
Windows, because the file was not opened with the needed flags.
2013-08-06 11:44:40 +02:00
Jean-Pierre André
a28e2a8606 Fixed dealing with errors getting the file size from Windows
Using SetFilePointer() for compatibility with old Windows implies
a specific management of errors....
2013-08-06 11:39:13 +02:00
Jean-Pierre André
ebf35000c9 Fixed computing a file size on Windows
The lower part should not have been sign-extended.
2013-07-30 11:42:59 +02:00
Jean-Pierre André
2c10bd6a98 Fixed struct formats for running on 64-bit Windows
Added a few paddings for field alignment in structs whose layout has to
match 64-bit Windows internals.
2013-07-30 11:31:56 +02:00
Jean-Pierre André
e221ad783c Improved emulation of stat(2) on Windows
Made a distinction between a file and a partition when emulating stat(2)
on Windows (useful for ntfsclone).
2013-07-30 11:17:29 +02:00
Jean-Pierre André
66cdec13d9 Fixed processing compressed data beyond file size
Windows 8 does not zero any more the end of a compression block beyond
what is needed to reach the end of a file. We must now be careful not
to decompress more data than needed.
2013-05-30 10:23:04 +02:00
Jean-Pierre André
abba388447 Fixed the reversing of slashes in relative Windows-type symlinks
When translating Windows-type symlinks to Linux ones, the directory
separator has to be changed from '\' to '/'. The change was wrong
for multiple "..\" and ".\"
2013-04-26 19:07:47 +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
Jean-Pierre André
6aa24b3df3 Fixed a use of uninitialized variable compiler warning
Author: Anton Altaparmakov
Date:   Wed Feb 13 02:29:47 2013 +0000

This is a fix to the use of hd library to get the legacy BIOS geometry.
2013-02-13 08:54:34 +01:00
Jean-Pierre André
9442db0d8b Added use of hd library to get the legacy BIOS geometry
Author: Anton Altaparmakov <anton@tuxera.com>
Date:   Tue Feb 12 10:33:55 2013 +0000

    Modify libntfs-3g to make use of hd library to get the legacy BIOS geometry
    from EDD.  We scan all whole disk devices on the system and check if they
    match the open ntfs device and if not we scan all partition devices on the
    system and check if they match the open ntfs device.

    If we find a partition device to match then we find its parent device again
    using the hd library.

    Once we have the parent of the partition device or we matched a whole disk
    device we get the legacy EDD sectors per track and heads again using the hd
    library.

    Use of the hd library is auto detected (based on finding <hd.h> header file,
    being able to link against libhd and finding the hd_list symbol in libhd.

    Use can also be disabled/enabled/libhd prefix specified at ./configure time.
    See ./configure --help for details.

    Note this obviously requires libhd to be installed.  On Ubuntu 12/04 systems
    the relevant packages needed are libhd-dev and libhd16 (on older Ubuntu
    versions it will be libhdN where N is some number <= 16 but an easy way to
    get the right package is to simply install libhd-dev which by dependency
    pulls in the correct libhdN package) whilst on SLES systems the relevant
    packages needed are hwinfo and hwinfo-devel.
2013-02-12 15:45:54 +01:00
Jean-Pierre André
2737f9cbd0 Initialize the random generator for the internal guid generator
When uuid/uuid.h is not available, mkntfs uses a home-made guid
generator. Better initialize the random generator to get a random guid.
2013-02-09 15:12:56 +01:00
Jean-Pierre André
44fbf02a97 Upgraded the Win32 interface for use with ntfsprogs
Upgrade the Win32 interface (win32_io.c) which was designed for Cygwin
so that it can be used for using the ntfsprogs utilities on native Windows.
Two new entries are added for truncating a file and creating a sparse
file, both of which not being supported through msvcrt.dll.
2013-02-09 11:22:41 +01: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
Erik Larsson
2bee30c2f7 acls.c: Fix compiler warning regarding usage of uninitialized variable.
This warning is really a false alarm, but fix it anyway.
2012-11-06 02:12:48 +01:00
Jean-Pierre André
761ba29110 Inserted updated definitions of reparse tags into layout.h
Replace the obsolete definition of reparse tags in layout.h by the
current definitions from msdn, and use them in reparse.c instead of
redefining them.
2012-10-05 10:42:19 +02:00
Jean-Pierre André
4d3967840c Fixed a memory leak caused by disabling getting/setting DOS names
After rejecting a DOS name setting on a hardlinked file, the search
context has to be freed.
2012-10-05 10:35:59 +02:00
Jean-Pierre André
67fa6273cf Disabled getting/setting DOS names on hardlinked files
As the path passed to ntfs-3g for getxattr(2)/setxattr(2) are not
guaranteed to be the one mentioned by the caller when there are hard links,
getting/setting DOS names have to be discontinued in that situation.
Getting/setting DOS names is still possible when there is a single
non-DOS name.
2012-10-03 11:23:58 +02: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
Erik Larsson
9337e0a069 bootsect.c: Don't allow negative start clusters for $MFT/$MFTMirr.
Negative values for mft_lcn / mftmirr_lcn don't make any sense and must
be detected as corruptions.
2012-09-24 12:57:22 +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é
4d0b9163c9 Accepted processing restart pages v 2.0 with no warning (used by Windows 8)
In the $LogFile, Windows 8 defines restart pages with version 2.0.
The checks designed for version 1.1 appear to apply, so accept v 2.0
and apply the usual checks.
2012-09-12 09:42:24 +02:00
Jean-Pierre André
c31c7463e8 Allowed SACLs to to not have any ACE
Accept security descriptors in which the SACL is present though it does not
contain any ACE. Such security descriptors have been found in Windows
installation files.
2012-09-12 09:36:21 +02:00
Jean-Pierre André
3e4c439520 Fixed the returned files types in readdir()
The type of special files (symlinks, fifos, etc.) was not returned in
readdir() and they appeared wrongly in the field d_type of "struct dirent".
This prevented some applications which relied on d_type (which does
not exist in Solaris) from navigating in an NTFS tree.
2012-08-20 14:34:16 +02:00
Jean-Pierre André
3953e929bb Fixed Windows-type inheritance for creator-owner ACE
Inheriting a creator-owner ACE the Windows way led to a buggy ACL
2012-08-20 14:29:51 +02:00
Jean-Pierre André
35eab4044e Avoided an unnecessary runlist update when appending data to a file
Appending data to a file is done in two steps : first extending the
file to the required size, then inserting data in the created space.
There is no need to recompute the runlist at the end of the first
step, just be sure the original configuration is rolled back if inserting
data leads to an error.
2012-08-20 13:48:49 +02:00
Jean-Pierre André
3103a6c383 Extended Windows-type ACL inheritance, as needed by Windows 8
Windows 8 uses "Authenticated user" principals which needs to be replaced
by the actual owner when inheriting
2012-08-20 12:36:45 +02:00
Jean-Pierre André
4b651b9340 Processed ACLs with no mentioned rights for owner (used by Windows8)
Windows 8 uses ACL patterns in which the owner has only implicit rights
(pattern not used by previous Windows versions)
2012-08-20 12:28:15 +02:00
Jean-Pierre André
db5af00af6 Processed junctions and symlinks whose target references another one
When the target of a junction or a Windows-type symlink references another
junction or symlink, the search for the full path on the current partition
and its translation for case-sensitive access is interrupted. The target can
now be dereferenced, provided the end of the path needed no translation.
2012-07-06 09:48:05 +02:00
Jean-Pierre André
0f8ef123ea Added inheritance of the set-group-id flag
So far the set-group-id flag could be set in a chmod. This patch enables
the inheritance of the group to files and subdirectories, and the
inheritance of the set-group-id flag to subdirectories.
2012-06-18 12:53:25 +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é
9704ff9396 Processed ACL inheritance for authenticated users
Under some conditions, Windows defines an ACL inheritance for an
unidentified authenticated user. With this patch, such an unidentified
user is treated as any user (same as "world").
2012-06-18 12:27:38 +02:00
Jean-Pierre André
464a9156cd Fixed a wrong computation of ACL size (minor issue) 2012-06-18 12:26:36 +02:00
Jean-Pierre André
911ecba5e2 Set the hidden flag according to the latest name when hide_dot_files is set
When the hide_dot_files option is set, a file is marked hidden if the
first character in its name is a dot. This patch updates the hidden flag
when the file is renamed or hard linked (useful for text editors which
create files with a temporary name)
2012-03-21 19:19:39 +01:00
Jean-Pierre André
4e29280cb2 Kept the name of a deleted file in place for easier undeletion
When a file is deleted, there is no need to remove its last name in
the deleted MFT record. The name may be useful for undeleting the file
later (Windows also does not delete the name).
2012-03-21 19:14:03 +01: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é
1c93e2a97d Avoided setuid/setgid removal by chown on OpenIndiana
On OpenIndiana, it is not customary to remove the setuid/setgid flags
when doing a chown, so comply with the local rules.
2012-03-21 18:52:07 +01:00
Jean-Pierre André
f78cc45208 Implemented supplementary group checks for OpenIndiana
Checking supplementary groups permissions to access a file relies on
a supplementary group list available in /proc/PID. This patch adds a
variant to implement the checks based on the specific format used
by OpenIndiana.
2012-03-21 18:34:48 +01:00
Jean-Pierre André
cd0be288b9 Fixed debug check for double opening after deleting an inode
A debug check could be defeated when a deleted inode number was reused.
2012-01-23 18:05:27 +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é
4ce33daf6c Cosmetic : fixed an indentation in unistr 2012-01-23 17:09:19 +01:00
Jean-Pierre André
d06ee35332 Used ENOENT instead of ENODATA when the latter is not defined (Robert Millan)
ENODATA is not defined by Posix and is lacking on FreeBSD
2012-01-23 16:50:25 +01:00
Jean-Pierre André
b76883dc84 major : Fixed computation of index block size (Anton Altaparmakov)
When the cluster size is bigger than the index block size, the index
block size unit is 512 (not the sector size) instead of the cluster size.
The partitions formatted by mkntfs and used by ntfs-3g were not
interoperable with Windows when the cluster size is bigger than 4K
and the sector size is not 512.
2011-11-04 11:01:11 +01:00
Jean-Pierre André
864cf7232e Fixed huge data writes
When computing the runlist for the first non-resident write to an
attribute, an inconsistency was created between the attribute image
and the ntfs_attr structure, which could cause an MFT record overflow
when the first write is huge and fragmented (reported by Vito Caputo).
2011-10-20 19:05:27 +02: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
Jean-Pierre André
c0955e5d74 cosmetic : fixed improper wordings (hggdh2) 2011-09-28 16:41:12 +02:00
Jean-Pierre André
08bf2b5bcb Avoided logging meaningless fixup errors in ntfsclone and ntfsresize
Logging of fixup errors for uninitialized inodes cause unnecessary
worries and suspicion of malfunctions in ntfs-3g. This patch silences
these loggings in ntfsclone and ntfsresize which have to analyze all
inodes, including the uninitialized ones.
2011-09-23 11:28:42 +02:00
Jean-Pierre André
ad53f4c24a Enabled getting the sector size from an ioctl on FreeBSD and MacOSX (Erik Larsson)
The sector size is needed for formatting a volume unless forced through
an option or using the traditional sector size.
2011-09-14 12:21:59 +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
Jean-Pierre André
4dd63e0fd1 Fixed the setting of attributes by secaudit
The setting of attributes was done in the "standard information",
it must also be propagated to the indexes in parent directories.
2011-09-12 18:41:25 +02:00
Erik Larsson
b8103bbcfe Permit $VOLUME_NAME to be 0-sized, even when $AttrDef says otherwise.
When clearing a volume name in Windows, $VOLUME_NAME is set to size 0, even if
the standard $AttrDef says that the minimum size is 2.

So the definition in $AttrDef doesn't reflect actual Windows behaviour in this
particular case, and to clear volume names ourselves the way Windows does it,
we must must add a special rule to permit us to truncate the $VOLUME_NAME
attribute to 0 even when $AttrDef specifies a higher value as minimum size.
2011-09-12 09:07:00 +02:00
Jean-Pierre André
178ae712c3 Fixed the truncation of dos file names
Truncate dos file names to 12 ntfschars instead of 12 utf-8 bytes
2011-09-08 09:52:51 +02:00
Jean-Pierre André
0b8b7521a4 Fixed the FullyMapped flag when making an attribute resident
When an attribute is truncated and made resident, the NAttrFullyMapped
flags has to be cleared, otherwise the attribute cannot be properly
mapped when the attribute is later made non-resident again.
2011-08-30 16:02:32 +02:00
Jean-Pierre André
0b827cc978 Avoid endless recursion when MFT extents are described in themselves
When getting extents of MFT, we must be sure they are in the MFT part which
has already been mapped, otherwise we fall into an endless recursion.

Situations have been met where extents locations are described in themselves,
as a consequence of a bug, probably unrelated to ntfs-3g.
This is a severe error which chkdsk cannot fix.
2011-08-30 15:56:36 +02:00
Jean-Pierre André
a1161d552f cosmetic : Removed a pointless store in ntfs_attr_make_resident() (Fabian Keil) 2011-08-04 15:49:36 +02:00
Jean-Pierre André
ae020fc4a7 cosmetic : Removed two dead stores in remove_object_id_index() (Fabian Keil) 2011-08-04 15:49:36 +02:00