|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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. They are not returned when the extended attribute list is queried, and consequently, unless stated otherwise, they are not saved by tar with option --xattrs to avoid conflicts with POSIX ACL and symbolic link savings, but specific tools may be designed to save and restore them.
[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 alternative stream "color"
D:\xattr>more < k:tests\xattr\file:color
green
D:\xattr>REM Change the alternative 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"
The NTFS attributes are a set of miscellaneous flags associated with
a file or directory.
The NTFS attributes are mapped to a four-byte word extended
attribute named system.ntfs_attrib
whose value is represented with the endianness of the processor used.
Only eight flags can be changed. The system flag
(FILE_ATTRIBUTE_SYSTEM)
is used in symbolic links and special files, it 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 |
Examples :
# Display the current NTFS attributes of the file source-file
getfattr -h -e hex -n system.ntfs_attrib source-file
# Set the NTFS read-only flag to file target-file (on a small-endian computer)
setfattr -h -v 0x01000000 -n system.ntfs_attrib target-file
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 -s '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 -s '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
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 decryption information is mapped to an extended attribute named user.ntfs.efsinfo.
It
can
thus
be
retrieved and recreated, so that backup applications can
blindly 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.
Please note : encryption and compression are not compatible. Do not
restore an encrypted file into a directory marked for compression.