2852f8c
diff --git a/doc/tar.texi b/doc/tar.texi
2852f8c
index d678db9..ab8a0c8 100644
2852f8c
--- a/doc/tar.texi
2852f8c
+++ b/doc/tar.texi
2852f8c
@@ -162,6 +163,7 @@ How to Create Archives
2852f8c
 How to List Archives
2852f8c
 
2852f8c
 * list dir::
2852f8c
+* List Extended Attributes::
2852f8c
 
2852f8c
 How to Extract Members from an Archive
2852f8c
 
2852f8c
@@ -1492,6 +1494,7 @@ for a detailed discussion of globbing patterns and related
2852f8c
 
2852f8c
 @menu
2852f8c
 * list dir::
2852f8c
+* List Extended Attributes::
2852f8c
 @end menu
2852f8c
 
2852f8c
 @node list dir
2852f8c
@@ -1522,6 +1525,116 @@ drwxrwxrwx myself/user       0 1990-05-31 21:49 practice/
2852f8c
 When you use a directory name as a file name argument, @command{tar} acts on
2852f8c
 all the files (including sub-directories) in that directory.
2852f8c
 
2852f8c
+@node List Extended Attributes
2852f8c
+@unnumberedsubsec Listing xattrs, POSIX ACLs and SELinux context
2852f8c
+
2852f8c
+From upstream GNU tar 1.26.9, tar is able to store, extract and list extended
2852f8c
+file attributes.  Listing of those attributes is then active only in verbose and
2852f8c
+double-verbose mode.
2852f8c
+
2852f8c
+This section exercises how to list attributes on examples.  Lets start with
2852f8c
+simple verbose mode.  This output is inspired by GNU @command{ls -l} command
2852f8c
+output.
2852f8c
+
2852f8c
+@itemize @bullet
2852f8c
+@item
2852f8c
+Show only pure extended attributes.
2852f8c
+
2852f8c
+@smallexample
2852f8c
+$ tar --xattrs --list -v archive.tar
2852f8c
+-rw-rwxr--  user/group 0 2012-08-08 15:15 acls.txt
2852f8c
+-rw-rw-r--* user/group 0 2012-08-08 15:15 xattrs.txt
2852f8c
+@end smallexample
2852f8c
+
2852f8c
+Note the asterisk on the third line!  It reflects the situation that the file
2852f8c
+'xattrs.txt' has some extended attribute set.  The default mode (same as if you
2852f8c
+are extracting extended attributes) shows information only about extended
2852f8c
+attributes from 'user.*' domain.  Anyway, feel free to change the sensitivity
2852f8c
+using @option{--xattrs-include} or @option{--xattrs-exclude} options.
2852f8c
+
2852f8c
+@item Show only POSIX ACLs - the character you should look for is '+':
2852f8c
+
2852f8c
+@smallexample
2852f8c
+$ tar --acls --list -v archive.tar
2852f8c
+-rw-rwxr--+ praiskup/praiskup 0 2012-08-08 15:15 acls.txt
2852f8c
+-rw-rw-r--  praiskup/praiskup 0 2012-08-08 15:15 xattrs.txt
2852f8c
+@end smallexample
2852f8c
+
2852f8c
+@item Show only SELinux - the key character is '.':
2852f8c
+
2852f8c
+@smallexample
2852f8c
+$ tar --selinux --list -v archive.tar
2852f8c
+-rw-rw-r--.  praiskup/praiskup 0 2012-08-08 15:16 selinux_only.txt
2852f8c
+-rw-rw-r--   praiskup/praiskup 0 2012-08-08 15:15 xattrs.txt
2852f8c
+@end smallexample
2852f8c
+
2852f8c
+@item
2852f8c
+Show info about ACLs, SELinux and general extended attributes together:
2852f8c
+
2852f8c
+@smallexample
2852f8c
+$ tar --selinux --acls --xattrs --list -v archive.tar
2852f8c
+-rw-rw-r--. praiskup/praiskup 0 2012-08-08 15:16 selinux_only.txt
2852f8c
+-rw-rwxr--+ praiskup/praiskup 0 2012-08-08 15:15 acls.txt
2852f8c
+-rw-rw-r--. praiskup/praiskup 0 2012-08-08 15:15 xattrs.txt
2852f8c
+@end smallexample
2852f8c
+
2852f8c
+In this case, the priority of character is '+' > '.' > '*'.  You don't see the
2852f8c
+general extended attributes flag ('*' character) on this example because it is
2852f8c
+hidden by '.' (meaning that the file has SELinux context set).
2852f8c
+
2852f8c
+@end itemize
2852f8c
+
2852f8c
+The example of double verbose mode is here.  In this output the single verbose
2852f8c
+characters '.', '+' and '*' are also present after the permission string.
2852f8c
+
2852f8c
+@smallexample
2852f8c
+$ tar --xattrs --selinux --acls -tvvf archive.tar
2852f8c
+-rw-rw-r--. praiskup/praiskup 0 2012-08-08 15:16 selinux_only.txt
2852f8c
+  s: unconfined_u:object_r:user_tmp_t:s0
2852f8c
+-rw-rwxr--+ praiskup/praiskup 0 2012-08-08 15:15 acls.txt
2852f8c
+  s: unconfined_u:object_r:user_tmp_t:s0
2852f8c
+  a: user::rw-,user:tester:rwx,group::rw-,mask::rwx,other::r--
2852f8c
+-rw-rw-r--. praiskup/praiskup 0 2012-08-08 15:15 xattrs.txt
2852f8c
+  s: unconfined_u:object_r:user_tmp_t:s0
2852f8c
+  x: 12 user.xattr
2852f8c
+  x: 12 user.we_like_tar
2852f8c
+@end smallexample
2852f8c
+
2852f8c
+This mode extends tar's output with additional lines beginning with
2852f8c
+distinguishing characters - 's' for SELinux context, 'a' for POSIX Access
2852f8c
+Control Lists  and 'x' for generic extended attributes.
2852f8c
+
2852f8c
+In this format, POSIX ACLs are written in SHORT TEXT FORM as specified in manual
2852f8c
+page @command{man 5 acl}.
2852f8c
+
2852f8c
+Use the @option{--xattrs-include} again if you want to print other than default
2852f8c
+'user.*' extended attributes domain:
2852f8c
+
2852f8c
+@smallexample
2852f8c
+$ tar --xattrs --xattrs-include='*' --acls --selinux -tvvf archive.tar
2852f8c
+-rw-rw-r--. praiskup/praiskup 0 2012-08-08 15:16 selinux_only.txt
2852f8c
+  s: unconfined_u:object_r:user_tmp_t:s0
2852f8c
+  x: 36 security.selinux
2852f8c
+-rw-rwxr--+ praiskup/praiskup 0 2012-08-08 15:15 acls.txt
2852f8c
+  s: unconfined_u:object_r:user_tmp_t:s0
2852f8c
+  a: user::rw-,user:tester:rwx,group::rw-,mask::rwx,other::r--
2852f8c
+  x: 36 security.selinux
2852f8c
+  x: 44 system.posix_acl_access
2852f8c
+-rw-rw-r--. praiskup/praiskup 0 2012-08-08 15:15 xattrs.txt
2852f8c
+  s: unconfined_u:object_r:user_tmp_t:s0
2852f8c
+  x: 36 security.selinux
2852f8c
+  x: 12 user.xattr
2852f8c
+  x: 12 user.we_like_tar
2852f8c
+@end smallexample
2852f8c
+
2852f8c
+As is in @pxref{Option Summary} section described, tar by default stores all
2852f8c
+extended attributes that are available (not only 'user.*' domain).  It means
2852f8c
+that the SELinux context and POSIX ACLs (because they are implemented using the
2852f8c
+generic extended attributes on usual file system) may be stored twice sometimes
2852f8c
+-- firstly in "raw" file system binary format and secondly in more portable way
2852f8c
+-- using appropriate system calls (invoked by @command{tar} options
2852f8c
+@option{--selinux} and @option{--acls}).
2852f8c
+
2852f8c
 @node extract
2852f8c
 @section How to Extract Members from an Archive
2852f8c
 @cindex Extraction
2852f8c
@@ -2371,6 +2484,10 @@ Normally when creating an archive, @command{tar} strips an initial
6777584
 treats names specially if they have initial @samp{/} or internal
6777584
 @samp{..}.  This option disables that behavior.  @xref{absolute}.
2852f8c
 
2852f8c
+@opsummary{acls}
2852f8c
+@item --acls
2852f8c
+Causes @command{tar} to store/restore/list POSIX ACL's.  @xref{Attributes}.
2852f8c
+
2852f8c
 @opsummary{after-date}
2852f8c
 @item --after-date
2852f8c
 
2852f8c
@@ -2919,6 +3036,11 @@ contents have changed (as opposed to just @option{--newer}, which will
2852f8c
 also back up files for which any status information has
2852f8c
 changed).  @xref{after}.
2852f8c
 
2852f8c
+@opsummary{no-acls}
2852f8c
+@item --no-acls
2852f8c
+Causes @command{tar} not to store, extract or list POSIX ACL's.
2852f8c
+@xref{Attributes}.
2852f8c
+
2852f8c
 @opsummary{no-anchored}
2852f8c
 @item --no-anchored
2852f8c
 An exclude pattern can match any subsequence of the name's components.
2852f8c
@@ -3002,11 +3124,20 @@ locations.  Usually @command{tar} determines automatically whether
2852f8c
 the archive can be seeked or not.  Use this option to disable this
2852f8c
 mechanism.
2852f8c
 
2852f8c
+@opsummary{no-selinux}
2852f8c
+@item --no-selinux
2852f8c
+Causes @command{tar} not to store, extract or list SELinux security context.
2852f8c
+@xref{Attributes}.
2852f8c
+
2852f8c
 @opsummary{no-unquote}
2852f8c
 @item --no-unquote
2852f8c
 Treat all input file or member names literally, do not interpret
2852f8c
 escape sequences.  @xref{input name quoting}.
2852f8c
 
2852f8c
+@opsummary{no-xattrs}
2852f8c
+@item --no-xattrs
2852f8c
+Causes @command{tar} not to store, extract or list xattrs.  @xref{Attributes}.
2852f8c
+
2852f8c
 @opsummary{no-wildcards}
2852f8c
 @item --no-wildcards
2852f8c
 Do not use wildcards.
2852f8c
@@ -3239,6 +3370,11 @@ in cases when such recognition fails.  It takes effect only if the
2852f8c
 archive is open for reading (e.g. with @option{--list} or
2852f8c
 @option{--extract} options).
2852f8c
 
2852f8c
+@opsummary{selinux}
2852f8c
+@item --selinux
2852f8c
+Causes @command{tar} to store, extract or list SELinux security context.
2852f8c
+@xref{Attributes}.
2852f8c
+
2852f8c
 @opsummary{show-defaults}
2852f8c
 @item --show-defaults
2852f8c
 
2852f8c
@@ -3466,6 +3602,11 @@ Enable or disable warning messages identified by @var{keyword}.  The
2852f8c
 messages are suppressed if @var{keyword} is prefixed with @samp{no-}.
2852f8c
 @xref{warnings}.
2852f8c
 
2852f8c
+@opsummary{xattrs}
2852f8c
+@item --xattrs
2852f8c
+Causes @command{tar} to store, restore or list extended file attributes.  For
2852f8c
+more info see @xref{Attributes}.
2852f8c
+
2852f8c
 @opsummary{wildcards}
2852f8c
 @item --wildcards
2852f8c
 Use wildcards when matching member names with patterns.
2852f8c
@@ -4218,6 +4359,11 @@ tar (child): trying gzip
6777584
 @cindex @samp{Record size = %lu blocks}, warning message
6777584
 @item record-size
6777584
 @samp{Record size = %lu blocks}
2852f8c
+@kwindex xattr-write
2852f8c
+@item xattr-write
2852f8c
+@samp{%s: Cannot set '%s' extended attribute for file '%s'}
2852f8c
+@*@samp{%s: Cannot set POSIX ACLs for file '%s'}
2852f8c
+@*@samp{%s: Cannot set SELinux context for file '%s'}
2852f8c
 @end table
2852f8c
 
2852f8c
 @subheading Keywords controlling incremental extraction:
2852f8c
@@ -8770,6 +8916,8 @@ implementation able to read @samp{ustar} archives will be able to read
2852f8c
 most @samp{posix} archives as well, with the only exception that any
2852f8c
 additional information (such as long file names etc.) will in such
2852f8c
 case be extracted as plain text files along with the files it refers to.
2852f8c
+This is the only format that can store ACLs, SELinux context and extended
2852f8c
+attributes.
2852f8c
 
2852f8c
 This archive format will be the default format for future versions
2852f8c
 of @GNUTAR{}.
2852f8c
@@ -9412,6 +9560,135 @@ Same as both @option{--same-permissions} and @option{--same-order}.
2852f8c
 
2852f8c
 This option is deprecated, and will be removed in @GNUTAR{} version 1.23.
2852f8c
 
2852f8c
+@opindex xattrs
2852f8c
+@item --xattrs
2852f8c
+This option causes @command{tar} to store, restore or list the extended file
2852f8c
+attributes (for information about extended attributes see @command{man(5)
2852f8c
+attr}).
2852f8c
+
2852f8c
+Note that all extended attributes are stored "as-is" (in file system binary
2852f8c
+format) and the resulting archive may be not fully portable.  See the
2852f8c
+@option{--selinux} and @option{--acls} options when you want to deal with these
2852f8c
+types of extended attributes in a better way.
2852f8c
+
2852f8c
+The @option{--xattrs} option implies the option @option{--format=posix} when
2852f8c
+tar is in @option{--create} operation mode.  It is the only one format which
2852f8c
+hase usable headers for storing additional file information like extended
2852f8c
+attributes are.
2852f8c
+
2852f8c
+By default, all extended attributes are stored into the archive.  The reason is
2852f8c
+that we want to make the backup process as complete as possible by default.  On
2852f8c
+the other hand, during extracting only the 'user.*' domain is extracted by
2852f8c
+default.  Anyway, this default behaviour may be easily modified by the
2852f8c
+@option{--xattrs-include} and @option{--xattrs-exclude} options.
2852f8c
+
2852f8c
+When you list an archive in verbose mode
2852f8c
+(@command{tar --xattrs --verbose -tf archive.tar}), tar shows the '*' character
2852f8c
+after the permissions string of concrete file ringht to tell you that at least
2852f8c
+one extended attribute is stored with corresponding file.
2852f8c
+
2852f8c
+Double verbose mode (@command{tar --xattrs -tvvf archive.tar}) prints the
2852f8c
+extended attribute length (in bytes) and its ASCII key (for printed examples
2852f8c
+@pxref{List Extended Attributes}).
2852f8c
+
2852f8c
+@option{--xattrs} option has no equivalent short option.
2852f8c
+
2852f8c
+Warnings which occur during impossible writing of extended attributes to
2852f8c
+a file system may be suppressed using the @option{--warning=no-xattr-write}
2852f8c
+option.
2852f8c
+
2852f8c
+@opindex no-xattrs
2852f8c
+@item --no-xattrs
2852f8c
+This option causes @command{tar} not to store/extract or list the current
2852f8c
+extended attributes.  This option does not affect options @option{--no-selinux}
2852f8c
+or @option{--no-acls}.
2852f8c
+
2852f8c
+The @option{--no-xattrs} option has no equivalent short option name.
2852f8c
+
2852f8c
+@opindex xattrs-include
2852f8c
+@opindex xattrs-exclude
2852f8c
+@item --xattrs-include=MASK
2852f8c
+@itemx --xattrs-exclude=MASK
2852f8c
+
2852f8c
+These options allows the xattr store/restore/list process to be more fine
2852f8c
+grained.  The default configuration is that @option{--create} mode handles all
2852f8c
+available extended attributes and the @option{--extract}/@option{--list} mode
2852f8c
+handles only 'user.*' domain.  These options may be used for editing of this
2852f8c
+default behaviour.
2852f8c
+
2852f8c
+@itemize @bullet
2852f8c
+@item
2852f8c
+Lets say we want to store all attributes except some "public restricted" domain
2852f8c
+(e.g.  'user.restricted.*' domain.  The correct way how to do it is:
2852f8c
+
2852f8c
+@command{tar --xattrs --xattrs-include='*' --xattrs-exclude='user.restricted.*'
2852f8c
+-cf archive.tar FILES}
2852f8c
+@item
2852f8c
+And, when we want to extract only some specific domain from an archive - we can
2852f8c
+use:
2852f8c
+
2852f8c
+@command{tar --xattrs --xattrs-include='security.capability' -xf archive.tar
2852f8c
+FILES}
2852f8c
+@end itemize
2852f8c
+
2852f8c
+Multiple passed include/exclude patterns are combined together.  The attribute
2852f8c
+is covered then only if (1) at least one of all include patterns matches its
2852f8c
+keyword and (2) no exclude pattern matches its keyword.
2852f8c
+
2852f8c
+When only include pattern is set - exclude pattern is left in default mode (and
2852f8c
+vice versa).
2852f8c
+
2852f8c
+@opindex selinux
2852f8c
+@item --selinux
2852f8c
+This option causes @command{tar} to store/extract/list the SELinux context
2852f8c
+information into/from an archive.  Command @command{tar} is able to show info
2852f8c
+whether the SELinux context is present in archived file using the verbose
2852f8c
+listing mode (@command{tar --selinux -tvf archive.tar}).  It shows the '.'
2852f8c
+character after permission string in that case.  Double-verbose listing mode
2852f8c
+(@command{tar -tvvf archive.tar}) then prints the full SELinux context to
2852f8c
+standard output, @pxref{List Extended Attributes} for printed example.
2852f8c
+
2852f8c
+This option implies the @option{--format=posix} when @command{tar} works in
2852f8c
+@option{--create} operation mode.
2852f8c
+
2852f8c
+Warnings complaining that SELinux context may not be written to a file system
2852f8c
+may be suppressed by the @option{--warning=no-xattr-write} option.
2852f8c
+
2852f8c
+The @option{--selinux} option has no equivalent short option name.
2852f8c
+
2852f8c
+@opindex no-selinux
2852f8c
+@item --no-selinux
2852f8c
+This option causes @command{tar} not to store the current SELinux security
2852f8c
+context information in the archive and not to extract any SELinux information in
2852f8c
+an archive.
2852f8c
+
2852f8c
+The @option{--no-selinux} option has no equivalent short option name.
2852f8c
+
2852f8c
+@opindex acls
2852f8c
+@item --acls
2852f8c
+This option causes @command{tar} to store the current POSIX access control lists
2852f8c
+into the archive or restore POSIX ACLs from an archive.  It also allows
2852f8c
+@command{tar} to show whether archived file contains ACLs when the verbose mode
2852f8c
+is active (@option{tar --acls -tvf} shows the symbol '+' after the permission
2852f8c
+characters in that case).  Double-verbose mode allows @command{tar} to list
2852f8c
+contained POSIX ACLs (@command{tar --acls -tvvf archive.tar}), for printed
2852f8c
+examples @pxref{List Extended Attributes}.
2852f8c
+
2852f8c
+This option implies the @option{--format=posix} when @command{tar} works in
2852f8c
+@option{--create} operation mode.
2852f8c
+
2852f8c
+Warnings complaining that POSIX ACLs may not be written to a file system may be
2852f8c
+suppressed by the @option{--warning=no-xattr-write} option.
2852f8c
+
2852f8c
+The @option{--acls} option has no equivalent short form.
2852f8c
+
2852f8c
+@opindex no-acls
2852f8c
+@item --no-acls
2852f8c
+This option causes @command{tar} not to store the current POSIX ACL into the
2852f8c
+archive and not to extract any POSIX ACL information from an archive.
2852f8c
+
2852f8c
+The @option{--no-acls} option has no equivalent short option name.
2852f8c
+
2852f8c
 @end table
2852f8c
 
2852f8c
 @node Portability