From 08c2540cb7649b8f9eea8435551e5dc3bc11a250 Mon Sep 17 00:00:00 2001
From: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Date: Sat, 19 Nov 2022 16:59:41 +0100
Subject: Add a man-page section about the xattr file format

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
---
 bin/gensquashfs/gensquashfs.1 | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/bin/gensquashfs/gensquashfs.1 b/bin/gensquashfs/gensquashfs.1
index f0697ab..88f58c4 100644
--- a/bin/gensquashfs/gensquashfs.1
+++ b/bin/gensquashfs/gensquashfs.1
@@ -95,6 +95,10 @@ A short hand for `\-\-set\-uid 0 \-\-set\-gid 0`.
 If built with SELinux support, use the given SELinux label file to add context
 labels to the elements packed into the SquashFS image.
 .TP
+\fB\-\-xattr-file\fR, \fB\-A\fR <file>
+Read extended attributes from a file. The format for the file is identical to
+the output generated by `\fBgetfattr \-\-dump\fR`.
+.TP
 \fB\-\-exportable\fR, \fB\-e\fR
 Generate an export table for NFS support.
 .TP
@@ -345,6 +349,33 @@ T}
 # For demonstration, a quoted filename and no flags
 1337  "usr/share/my \\"special\\" file  "
 .fi
+.SH XATTR FILE FORMAT
+The format for xattr files tries to be identical to the output
+of \fBgetfattr\fR.
+
+Attributes are listed as key-value pairs with an \fB=\fR sign in between.
+
+If a line starts with `\fB# file: \fR`, the rest of the line is interpreted
+as an absolute path that the following xattrs are applied to.
+
+Plain text values are wrapped in quotation marks ("...") and support some
+escape sequences.
+Currently supported are \fB\\"\fR, \fB\\\\\fR and \fB\\0<octal-sequence>\fR.
+
+Raw binary values can encoded as hexadecimal or base64, by starting the
+value with a \fB0x\fR or \fB0s\fR prefix respectively.
+
+.SS Example
+.PP
+.nf
+# file: dev/
+security.selinux="system_u:object_r:device_t:s0"
+user.beverage_preference=0xCAFECAFEDECAFBAD
+
+# file: dev/rfkill
+security.selinux="system_u:object_r:wireless_device_t:s0"
+system.posix_acl_access=0sSGVsbG8gdGhlcmUgOi0pCg==
+.fi
 .SH ENVIRONMENT
 If the command line switch \fB\-\-defaults\fR is not used or no default mtime
 is specified, the value of the environment variable \fBSOURCE\_DATE\_EPOCH\fR
-- 
cgit v1.2.3