2 $Id: ea.h,v 1.1 2009-10-02 09:32:40 franklahm Exp $
3 Copyright (c) 2009 Frank Lahm <franklahm@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
24 * This seems to be the current limit fo HFS+, we arbitrarily force that
25 * which also safes us from buffer overflows
27 #define MAX_EA_SIZE 3802
30 * At time of writing the 10.5.6 client adds 8 bytes to the
31 * length of the EA that we send him
33 #define MAX_REPLY_EXTRA_BYTES 8
36 * Library user must provide a static buffer of size ATTRNAMEBUFSIZ.
37 * It's used when listing EAs as intermediate buffer. For afpd it's
38 * defined in extattrs.c.
40 #define ATTRNAMEBUFSIZ 4096
49 #define EA_MAGIC 0x61644541 /* "adEA" */
50 #define EA_VERSION1 0x01
51 #define EA_VERSION EA_VERSION1
55 EA_CREATE = (1<<1), /* create if not existing on ea_open */
56 EA_RDONLY = (1<<2), /* open read only */
57 EA_RDWR = (1<<3), /* open read/write */
58 /* ea_open internal flags */
59 EA_DIR = (1<<4) /* ea header file is for a dir, ea_open adds it as appropiate */
62 #define EA_MAGIC_OFF 0
63 #define EA_MAGIC_LEN 4
64 #define EA_VERSION_OFF (EA_MAGIC_OFF + EA_MAGIC_LEN)
65 #define EA_VERSION_LEN 2
66 #define EA_COUNT_OFF (EA_VERSION_OFF + EA_VERSION_LEN)
67 #define EA_COUNT_LEN 2
68 #define EA_HEADER_SIZE (EA_MAGIC_LEN + EA_VERSION_LEN + EA_COUNT_LEN)
71 * structs describing the layout of the Extended Attributes bookkeeping file.
72 * This isn't really an AppleDouble structure, it's just a binary blob that
73 * lives in our .AppleDouble directory too.
77 size_t ea_namelen; /* len of ea_name without terminating 0 ie. strlen(ea_name)*/
78 size_t ea_size; /* size of EA*/
79 char *ea_name; /* name of the EA */
82 /* We read the on-disk data into *ea_data and parse it into this*/
84 const struct vol *vol; /* vol handle, ea_close needs it */
85 char *filename; /* name of file, needed by ea_close too */
86 unsigned int ea_count; /* number of EAs in ea_entries array */
87 struct ea_entry (*ea_entries)[]; /* malloced and realloced as needed by ea_count*/
88 int ea_fd; /* open fd for ea_data */
89 eaflags_t ea_flags; /* flags */
90 size_t ea_size; /* size of header file = size of ea_data buffer */
91 char *ea_data; /* pointer to buffer into that we actually *
92 * read the disc file into */
95 /* On-disk format, just for reference ! */
97 struct ea_entry_ondisk {
99 char ea_name[]; /* zero terminated string */
104 u_int16_t ea_version;
106 struct ea_entry_ondisk ea_entries[ea_count];
110 #endif /* ATALK_EA_H */