Commit Graph

89 Commits

Author SHA1 Message Date
Jean-Pierre André
5d46b32b91 Enabled Recording the special files the same way as WSL
Optionally record the special files (symlinks, fifos, sockets, character
and block devices) using reparse points instead of using Interix representation.
Doing so, the special files are interoperable with Windows Subsystem for
linux (WSL).
2021-01-26 10:06:18 +01:00
Jean-Pierre André
02673bd04a Enabled actions on directories in reparse plugins
The plugins triggered by reparse points can now act on a directory
through link(2) unlink(2) and creat(2).
2021-01-26 10:06:17 +01:00
Jean-Pierre André
d6558f1dea Defined option "posix_nlink" to compute a Posix compliant st_nlink
When the mount option "posix_nlink" is used, the number of links
returned by stat complies with Posix : the legacy 8.3 names are not
taken into account, and the subdirectories are taken into account
for directories. This causes some overhead for recomputing the
number of links.
2020-08-14 11:50:35 +02:00
Jean-Pierre André
7cd46f95df Fixed object types returned in readdir() for reparse points
The types of reparse point objects cannot be decided upon the data
available in a directory, so we must delegate their determination to a
specific plugin when available, and be consistent if there is none.
2020-03-08 10:03:23 +01:00
Jean-Pierre André
17b56ccfa2 Allowed names with trailing dot or space on conditions
Windows places filenames with a trailing dot or space in the Win32
namespace and allows setting DOS names on such files.  This is true even
though on Windows such filenames can only be created and accessed using
WinNT-style paths and will confuse most Windows software.  Regardless,
because libntfs-3g did not allow setting DOS names on such files, in
some cases it was impossible to correctly restore, using libntfs-3g, a
directory structure that was created under Windows.

Update ntfs_set_ntfs_dos_name() to permit operating on a file that has a
long name with a trailing dot or space.  But continue to forbid creating
such names on a filesystem FUSE-mounted with the windows_name option.
Additionally, continue to forbid a trailing a dot or space in DOS names;
this matches the Windows behavior.

(contributed by Eric Biggers)
2017-02-11 10:54:51 +01:00
Jean-Pierre André
3c5fb9b352 Eliminated unnecessary strlen() in ntfs_get_ntfs_dos_name()
Since ntfs_ucstombs() returns the output string length, there is no need
to call strlen().

(contributed by Eric Biggers)
2017-02-11 09:58:30 +01:00
Jean-Pierre André
043b0e6e73 Allowed using full library API on systems without extended attributes support
A number of functions in libntfs-3g are generally useful, but are tied to
extended attributes support and are not included when the library is
built on platforms without extended attributes support.

This proposal updates libntfs-3g to always include these functions.

The only tricky part is dealing with the XATTR_CREATE and XATTR_REPLACE
flags.  These flags are defined in <sys/xattr.h>, so they must be
redefined on platforms without extended attributes support.

Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
2016-07-28 16:13:59 +02:00
Jean-Pierre André
b973c0bd3c 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>
2016-06-22 12:01:25 +02:00
Jean-Pierre André
5693341f0d 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>
2016-06-22 11:58:20 +02:00
Jean-Pierre André
cf6f265069 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)
2016-05-31 08:33:10 +02:00
Jean-Pierre André
34f7bd7ff0 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.
2016-05-04 10:03:39 +02:00
Jean-Pierre André
88451c8069 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.
2016-04-06 10:17:27 +02:00
Erik Larsson
9893ea9ee6 Merge endianness fixes.
Conflicts:
	libntfs-3g/attrib.c
2016-01-28 09:22:42 +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
Jean-Pierre André
f7bc5249bc Alleviated constraints relative to reparse points
Some constraints put on reparse points of unknown type (e.g. they cannot
be deleted) are not acceptable to archivers. This patch removes some
constraints.
2015-11-09 16:22:16 +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
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é
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é
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é
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é
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é
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é
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é
5cd49257b0 Removed unneeded variables as warned by gcc 4.6 2011-07-05 12:17:29 +02:00
Jean-Pierre André
bb142bc742 Fixed deleting files using ignore_case option 2010-12-21 15:51:07 +01:00
Jean-Pierre André
a70e40021d Added detail to an error message to discriminate from a similar one 2010-11-09 09:41:00 +01:00
Jean-Pierre André
15c4d282ce Enable/disable compression according to option 2010-06-03 10:11:42 +02:00
Jean-Pierre André
07d86b0cfd Reenabled compression in root directory 2010-06-03 10:07:27 +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
Jean-Pierre André
51a9ab8c48 fixed compressions on parent directory or NTFS version < 3.0 2010-05-25 09:52:34 +02:00
Jean-Pierre André
1bb7443eb6 Fixed setting archive bit on file and alternated data stream creation 2010-02-24 12:08:56 +01:00
jpandre
d78add4e8f Developed time stamping up to 100ns resolution 2010-01-04 08:24:44 +00:00
jpandre
6072a95591 Cached looked-up inodes for subsequent use 2009-12-18 08:27:05 +00:00
jpandre
d75f69d80e Cached inode data for subsequent use 2009-12-18 08:12:23 +00:00
jpandre
41a371f4a7 Redesigned caches for indexing cached entries 2009-12-17 17:36:06 +00:00
jpandre
7c88ccb95b Grouped parameters affecting the global behavior in a specific file 2009-12-17 15:24:02 +00:00
jpandre
c1adbc1787 Implemented getting/setting/removing object ids 2009-12-17 09:07:56 +00:00
jpandre
d990f7996c Changed the interfaces to use extended attributes 2009-12-17 08:24:13 +00:00
jpandre
195945cdc0 Evaluated file names collations in a single parsing 2009-12-16 09:45:28 +00:00
jpandre
2f8ced2ddd Kept junctions points absolute or relative as specified 2009-12-15 09:25:36 +00:00
jpandre
efd2a9701a Avoided translating file names when available in cache 2009-12-11 10:11:38 +00:00
jpandre
758a99ea87 Avoided double copy of dir when closing a file in an open dir 2009-12-10 10:04:53 +00:00
jpandre
b78d895575 Added indexing of reparse data into $Extend/$Reparse 2009-11-03 14:35:53 +00:00
jpandre
84605fd3d7 Fixed a possible memory leak when setting a DOS name 2009-09-18 16:15:36 +00:00
jpandre
c085f70be1 Developed the removal of a DOS name 2009-08-14 14:46:46 +00:00
jpandre
5bee9d73f0 Allowed to set a DOS name exactly the same as the long name 2009-08-14 14:44:12 +00:00