Extend make_ext4fs to support setting SELinux security contexts in ext4 images.

Extend make_ext4fs with support for looking up the right security context from
the file_contexts configuration and setting it in the generated image.  This is
similar to the existing support for looking up the UID/GID/mode via
android_filesystem_config.h and setting it, but via configuration rather than
defined in a header.

Change-Id: Ief9c44eeaaca4a44100a384b063f40b185469be3
diff --git a/ext4_utils/xattr.h b/ext4_utils/xattr.h
new file mode 100644
index 0000000..2c6d9cc
--- /dev/null
+++ b/ext4_utils/xattr.h
@@ -0,0 +1,23 @@
+#include <sys/types.h>
+
+#define EXT4_XATTR_MAGIC 0xEA020000
+#define EXT4_XATTR_INDEX_SECURITY 6
+
+struct ext4_xattr_entry {
+    __u8 e_name_len;
+    __u8 e_name_index;
+    __le16 e_value_offs;
+    __le32 e_value_block;
+    __le32 e_value_size;
+    __le32 e_hash;
+    char e_name[0];
+};
+
+#define EXT4_XATTR_PAD_BITS 2
+#define EXT4_XATTR_PAD (1<<EXT4_XATTR_PAD_BITS)
+#define EXT4_XATTR_ROUND (EXT4_XATTR_PAD-1)
+#define EXT4_XATTR_LEN(name_len) \
+    (((name_len) + EXT4_XATTR_ROUND + \
+    sizeof(struct ext4_xattr_entry)) & ~EXT4_XATTR_ROUND)
+#define EXT4_XATTR_SIZE(size) \
+    (((size) + EXT4_XATTR_ROUND) & ~EXT4_XATTR_ROUND)