|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| Your
operating system has to provide an extended attribute interface for the features referenced on this page to be available. Some Linux distributions and most other operating systems do not support a compatible extended attribute interface. On systems with open name spaces, such as Mac OS X, these features are enabled through the mount option streams_interface=openxattr. |
[user xattr]$ # Set the extended attribute "user.color" with value "green"A few extended attributes in the system name space are used to give access to NTFS internal data which cannot be accessed through Linux standard methods. They can be accessed with any setting of the option streams_interface.
[user xattr]$ setfattr -n user.color -v green /media/tmp/tests/xattr/file
[user xattr]$ # Check the value of the attribute
[user xattr]$ getfattr -n user.color /media/tmp/tests/xattr/file
getfattr: Removing leading '/' from absolute path names
# file: media/tmp/tests/xattr/file
user.color="green"
D:\xattr>REM On windows display the alternate stream "color"
D:\xattr>more < k:tests\xattr\file:color
green
D:\xattr>REM Change the alternate stream contents to "white"
D:\xattr>echo white > k:tests\xattr\file:color
D:\xattr>more < k:tests\xattr\file:color
white
[user xattr]$ # Back on Linux, display the extended attribute "user.color"
[user xattr]$ getfattr -n user.color /media/tmp/tests/xattr/file
getfattr: Removing leading '/' from absolute path names
# file: media/tmp/tests/xattr/file
user.color="white"
system.ntfs_attrib:user.ntfs_attrib
# this is a comment line
system.ntfs_times:user.ntfs_times
The NTFS attributes are a set of miscellaneous flags associated with
a file or directory.
(The attribute
system.ntfs_attrib_be only exists since ntfs-3g-2010.5.22AC.5)
The NTFS attributes are mapped to two four-byte word extended
attributes named system.ntfs_attrib
and system.ntfs_attrib_be.
The value of the former is represented with the endianness of the
processor used (suitable for use with system functions such as
getxattr(2)),
the value of the latter is represented as big-endian and is more
convenient for use with commands such as
getfattr(1).
Only eight flags can be changed. The system flag
(FILE_ATTRIBUTE_SYSTEM)
is used in symbolic links and special files, and should not be changed
unawares. The compressed flag on a directory is only used when creating
new files into the directory, it has no effect on existing files. The
other changeable flags are not used by Linux.
| Names of settable flags |
value
(hex) |
| FILE_ATTRIBUTE_READONLY |
1 |
| FILE_ATTRIBUTE_HIDDEN |
2 |
| FILE_ATTRIBUTE_SYSTEM |
4 |
| FILE_ATTRIBUTE_ARCHIVE |
20 |
| FILE_ATTRIBUTE_TEMPORARY |
100 |
| FILE_ATTRIBUTE_COMPRESSED (directories only) | 800 |
| FILE_ATTRIBUTE_OFFLINE |
1000 |
| FILE_ATTRIBUTE_NOT_CONTENT_INDEXED |
2000 |
When using the
setfattr(1)
command, be sure to define the value as a four-byte number
(or eight hexadecimal digits) representing the sum of the desired
flags values.
Examples :
# Display the current NTFS attributes of the file source-file
getfattr -h -e hex -n system.ntfs_attrib_be source-file
# Set the NTFS read-only flag to file target-file (any computer)
setfattr -h -v 0x00000001 -n system.ntfs_attrib_be target-file
# Set the compression flag on a directory (small-endian computer)
setfattr -h -v 0x10080000 -n system.ntfs_attrib target-directory
NTFS use reparse data to define special actions before opening a file or directory. For instance reparse data is used to define Windows junctions and symlinks.
If present, the reparse data of a file or directory is mapped to an
extended attribute named system.ntfs_reparse_data,
and
is returned as a raw variable-length record of small-endian items.
# Display the reparse data of the file source-file
getfattr -h -e hex -n system.ntfs_reparse_data source-file
# Copy the reparse data of the file source-file to the file target-file
REPARSE=`getfattr -h -e hex -n system.ntfs_reparse_data source-file | \
grep '=' | sed -e 's/^.*=//'`
setfattr -h -v $REPARSE -n system.ntfs_reparse_data target-file
The NTFS ACLs are used to control access to files or directories. On linux they are translated into ownership, permissions and Posix ACLs parameters.
The NTFS ACL of a file or directory is mapped to an extended
attribute named system.ntfs_acl,
and is
returned as a raw variable-length record of small-endian items. All the
components of the ACL are returned : the owner id, the group id, the
discretionary ACL and the system ACL.
# Display the NTFS ACL of the file source-file
getfattr -h -e hex -n system.ntfs_acl source-file
# Copy the ACL of the file source-file to the file target-file
ACL=`getfattr -h -e hex -n system.ntfs_acl source-file | \
grep '=' | sed -e 's/^.*=//'`
setfattr -h -v $ACL -n system.ntfs_acl target-file
# Display the short name of the file source-file
getfattr -h -n system.ntfs_dos_name source-file
# Set TARGET~1 as the short name of the file target-file
setfattr -h -v "TARGET~1" -n system.ntfs_dos_name target-file
# Get and hex display the creation time of the file source-file(The attributes system.ntfs_crtime and system.ntfs_crtime_be only exist since ntfs-3g-2010.5.22AC.5)
CRTIME=`getfattr -h -e hex -n system.ntfs_times source-file | \
grep '=' | sed -e 's/^.*=\(0x................\).*$/\1/'`
echo $CRTIME
# Set only this creation time to the file target-file
setfattr -h -v $CRTIME -n system.ntfs_times target-file
EFS is the methodology used in NTFS to deal with encrypted files. An
encrypted file consists of the user data, encoded such that an
unauthorized person is not able to interpret it, and the decryption
information,
the EFS Info, which contains the key, encrypted so that only authorized
people can get it in order to
interpret the user data.
(The attribute system.ntfs_efsinfo
only exists since ntfs-3g-2010.5.22AC.5)
The decryption information is mapped to an extended attribute named system.ntfs_efsinfo.
It can thus be retrieved and recreated, so that backup applications
can save and restore encrypted files and associated data without
interpreting anything. The EFS info is specific to a file, so the file
contents, its user extended attributes and the EFS info have to be kept
associated.
Reading and writing raw encrypted data and decryption information are only possible when using the mount option efs_raw. This causes the size of the raw data to appear slightly bigger than the original data. When the option efs_raw is set, the EFS info is automatically mapped to the alternate extended attribute user.ntfs.efsinfo in user name space for easier use with standard backup tools.
Please note : encryption and compression are not compatible. Do not
restore an encrypted file into a directory marked for compression.
The set of EAs is an attribute of files of directories originally designed to hold extended attributes for the OS/2 operating system. This attribute is not what Unix uses to store its own extended attributes, though the concepts are much similar. It was not much used until Windows 8 came out, but some usage is emerging now.
(The attribute system.ntfs_ea
only exists since ntfs-3g-2014.2.15AR.1)
The full set of EAs of a file or directory is mapped to the extended
attribute system.ntfs_ea, and there is no direct access
to an individual EA. The structure of each individual EA is what Windows
defines as FILE_FULL_EA_INFORMATION,
with the difference that the last NextEntryOffset field is not seen as
zero as it is in the Win32 functions ZwQueryEaFile() and ZwSetEaFile().
The on-disk representations are however the same.
When setting a set of EAs, its consistency is checked and the
update is rejected if the check fails.
Please note : a file or directory cannot have both a set of EAs and
Reparse Data.