2 $Id: ea.h,v 1.2 2009-10-14 15:04:01 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.
23 #ifdef HAVE_NFSv4_ACLS
27 #include <atalk/vfs.h>
30 * This seems to be the current limit fo HFS+, we arbitrarily force that
31 * which also safes us from buffer overflows
33 #define MAX_EA_SIZE 3802
36 * At time of writing the 10.5.6 client adds 8 bytes to the
37 * length of the EA that we send him
39 #define MAX_REPLY_EXTRA_BYTES 8
42 * Library user must provide a static buffer of size ATTRNAMEBUFSIZ.
43 * It's used when listing EAs as intermediate buffer. For afpd it's
44 * defined in extattrs.c.
46 #define ATTRNAMEBUFSIZ 4096
54 #define EA_INITED 0xea494e54 /* ea"INT", for interfacing ea_open w. ea_close */
55 #define EA_MAGIC 0x61644541 /* "adEA" */
56 #define EA_VERSION1 0x01
57 #define EA_VERSION EA_VERSION1
61 EA_CREATE = (1<<1), /* create if not existing on ea_open */
62 EA_RDONLY = (1<<2), /* open read only */
63 EA_RDWR = (1<<3), /* open read/write */
64 /* ea_open internal flags */
65 EA_DIR = (1<<4) /* ea header file is for a dir, ea_open adds it as appropiate */
68 #define EA_MAGIC_OFF 0
69 #define EA_MAGIC_LEN 4
70 #define EA_VERSION_OFF (EA_MAGIC_OFF + EA_MAGIC_LEN)
71 #define EA_VERSION_LEN 2
72 #define EA_COUNT_OFF (EA_VERSION_OFF + EA_VERSION_LEN)
73 #define EA_COUNT_LEN 2
74 #define EA_HEADER_SIZE (EA_MAGIC_LEN + EA_VERSION_LEN + EA_COUNT_LEN)
77 * structs describing the layout of the Extended Attributes bookkeeping file.
78 * This isn't really an AppleDouble structure, it's just a binary blob that
79 * lives in our .AppleDouble directory too.
83 size_t ea_namelen; /* len of ea_name without terminating 0 ie. strlen(ea_name)*/
84 size_t ea_size; /* size of EA*/
85 char *ea_name; /* name of the EA */
88 /* We read the on-disk data into *ea_data and parse it into this*/
90 uint32_t ea_inited; /* needed for interfacing ea_open w. ea_close */
91 const struct vol *vol; /* vol handle, ea_close needs it */
92 char *filename; /* name of file, needed by ea_close too */
93 unsigned int ea_count; /* number of EAs in ea_entries array */
94 struct ea_entry (*ea_entries)[]; /* malloced and realloced as needed by ea_count*/
95 int ea_fd; /* open fd for ea_data */
96 eaflags_t ea_flags; /* flags */
97 size_t ea_size; /* size of header file = size of ea_data buffer */
98 char *ea_data; /* pointer to buffer into that we actually *
99 * read the disc file into */
102 /* On-disk format, just for reference ! */
104 struct ea_entry_ondisk {
106 char ea_name[]; /* zero terminated string */
111 u_int16_t ea_version;
113 struct ea_entry_ondisk ea_entries[ea_count];
117 /* VFS inderected funcs ... : */
119 /* Default adouble EAs */
120 extern int get_easize(VFS_FUNC_ARGS_EA_GETSIZE);
121 extern int get_eacontent(VFS_FUNC_ARGS_EA_GETCONTENT);
122 extern int list_eas(VFS_FUNC_ARGS_EA_LIST);
123 extern int set_ea(VFS_FUNC_ARGS_EA_SET);
124 extern int remove_ea(VFS_FUNC_ARGS_EA_REMOVE);
125 /* ... EA VFS funcs that deal with file/dir cp/mv/rm */
126 extern int ea_deletefile(VFS_FUNC_ARGS_DELETEFILE);
127 extern int ea_renamefile(VFS_FUNC_ARGS_RENAMEFILE);
129 /* Solaris native EAs */
130 #ifdef HAVE_SOLARIS_EAS
131 extern int sol_get_easize(VFS_FUNC_ARGS_EA_GETSIZE);
132 extern int sol_get_eacontent(VFS_FUNC_ARGS_EA_GETCONTENT);
133 extern int sol_list_eas(VFS_FUNC_ARGS_EA_LIST);
134 extern int sol_set_ea(VFS_FUNC_ARGS_EA_SET);
135 extern int sol_remove_ea(VFS_FUNC_ARGS_EA_REMOVE);
136 #endif /* HAVE_SOLARIS_EAS */
138 #endif /* ATALK_EA_H */