summaryrefslogtreecommitdiff
path: root/source3/modules
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2017-10-10 16:03:13 +0200
committerKarolin Seeger <kseeger@samba.org>2017-10-25 08:43:05 +0200
commita0acb0f6f6b27af6b9f14497d320fa2e2b9316ba (patch)
tree84164343a8c1d3f214c996a7069fecec0bb5cd55 /source3/modules
parent9245b3f12c4331824245ac52081136a8125c588d (diff)
downloadsamba-a0acb0f6f6b27af6b9f14497d320fa2e2b9316ba.tar.gz
vfs_fruit: add AppleDouble xattr structure definitions
Reference: https://opensource.apple.com/source/xnu/xnu-4570.1.46/bsd/vfs/vfs_xattr.c Bug: https://bugzilla.samba.org/show_bug.cgi?id=13076 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> (cherry picked from commit b5a664e2580d8823f4f2d3e7e516b576317eb290)
Diffstat (limited to 'source3/modules')
-rw-r--r--source3/modules/vfs_fruit.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index f5c30502865..c30f46770ab 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -344,12 +344,48 @@ typedef enum {ADOUBLE_META, ADOUBLE_RSRC} adouble_type_t;
#define AD_DATE_FROM_UNIX(x) (htonl((x) - AD_DATE_DELTA))
#define AD_DATE_TO_UNIX(x) (ntohl(x) + AD_DATE_DELTA)
+#define AD_XATTR_HDR_MAGIC 0x41545452 /* 'ATTR' */
+#define AD_XATTR_MAX_ENTRIES 1024 /* Some arbitrarily enforced limit */
+#define AD_XATTR_HDR_SIZE 36
+#define AD_XATTR_MAX_HDR_SIZE 65536
+
/* Accessor macros */
#define ad_getentrylen(ad,eid) ((ad)->ad_eid[(eid)].ade_len)
#define ad_getentryoff(ad,eid) ((ad)->ad_eid[(eid)].ade_off)
#define ad_setentrylen(ad,eid,len) ((ad)->ad_eid[(eid)].ade_len = (len))
#define ad_setentryoff(ad,eid,off) ((ad)->ad_eid[(eid)].ade_off = (off))
+/*
+ * Both struct ad_xattr_header and struct ad_xattr_entry describe the in memory
+ * representation as well as the on-disk format.
+ *
+ * The ad_xattr_header follows the FinderInfo data in the FinderInfo entry if
+ * the length of the FinderInfo entry is larger then 32 bytes. It is then
+ * preceeded with 2 bytes padding.
+ *
+ * Cf: https://opensource.apple.com/source/xnu/xnu-4570.1.46/bsd/vfs/vfs_xattr.c
+ */
+
+struct ad_xattr_header {
+ uint32_t adx_magic; /* ATTR_HDR_MAGIC */
+ uint32_t adx_debug_tag; /* for debugging == file id of owning file */
+ uint32_t adx_total_size; /* file offset of end of attribute header + entries + data */
+ uint32_t adx_data_start; /* file offset to attribute data area */
+ uint32_t adx_data_length; /* length of attribute data area */
+ uint32_t adx_reserved[3];
+ uint16_t adx_flags;
+ uint16_t adx_num_attrs;
+};
+
+/* On-disk entries are aligned on 4 byte boundaries */
+struct ad_xattr_entry {
+ uint32_t adx_offset; /* file offset to data */
+ uint32_t adx_length; /* size of attribute data */
+ uint16_t adx_flags;
+ uint8_t adx_namelen; /* included the NULL terminator */
+ char *adx_name; /* NULL-terminated UTF-8 name */
+};
+
struct ad_entry {
size_t ade_off;
size_t ade_len;
@@ -364,6 +400,8 @@ struct adouble {
uint32_t ad_version;
struct ad_entry ad_eid[ADEID_MAX];
char *ad_data;
+ struct ad_xattr_header adx_header;
+ struct ad_xattr_entry *adx_entries;
};
struct ad_entry_order {