29#ifndef _ATALK_ADOUBLE_H
30#define _ATALK_ADOUBLE_H
45#define AD_VERSION2 0x00020000
46#define AD_VERSION_EA 0x00020002
49#define AD_VERSION AD_VERSION_EA
57#define ADEID_COMMENT 4
59#define ADEID_ICONCOL 6
61#define ADEID_FILEDATESI 8
62#define ADEID_FINDERI 9
63#define ADEID_MACFILEI 10
64#define ADEID_PRODOSFILEI 11
65#define ADEID_MSDOSFILEI 12
66#define ADEID_SHORTNAME 13
67#define ADEID_AFPFILEI 14
71#define ADEID_PRIVDEV 16
72#define ADEID_PRIVINO 17
73#define ADEID_PRIVSYN 18
74#define ADEID_PRIVID 19
75#define ADEID_MAX (ADEID_PRIVID + 1)
78#define AD_DEV 0x80444556
79#define AD_INO 0x80494E4F
80#define AD_SYN 0x8053594E
81#define AD_ID 0x8053567E
84#define AD_APPLESINGLE_MAGIC 0x00051600
85#define AD_APPLEDOUBLE_MAGIC 0x00051607
86#define AD_MAGIC AD_APPLEDOUBLE_MAGIC
89#define ADEDLEN_MAGIC 4
90#define ADEDLEN_VERSION 4
91#define ADEDLEN_FILLER 16
92#define ADEDLEN_NENTRIES 2
93#define AD_HEADER_LEN (ADEDLEN_MAGIC + ADEDLEN_VERSION + ADEDLEN_FILLER + ADEDLEN_NENTRIES)
94#define AD_ENTRY_LEN 12
97#define ADEDLEN_NAME 255
98#define ADEDLEN_COMMENT 200
99#define ADEDLEN_FILEI 16
100#define ADEDLEN_FINDERI 32
101#define ADEDLEN_FILEDATESI 16
102#define ADEDLEN_SHORTNAME 12
103#define ADEDLEN_AFPFILEI 4
104#define ADEDLEN_MACFILEI 4
105#define ADEDLEN_PRODOSFILEI 8
106#define ADEDLEN_MSDOSFILEI 2
107#define ADEDLEN_ICONBW 128
108#define ADEDLEN_ICONCOL 1024
110#define ADEDLEN_PRIVDEV 8
111#define ADEDLEN_PRIVINO 8
112#define ADEDLEN_PRIVSYN 8
113#define ADEDLEN_PRIVID 4
115#define ADEID_NUM_V2 13
116#define ADEID_NUM_EA 8
117#define ADEID_NUM_OSX 2
119#define AD_DATASZ2 (AD_HEADER_LEN + ADEDLEN_NAME + ADEDLEN_COMMENT + ADEDLEN_FILEI + \
120 ADEDLEN_FINDERI + ADEDLEN_DID + ADEDLEN_AFPFILEI + ADEDLEN_SHORTNAME + \
121 ADEDLEN_PRODOSFILEI + ADEDLEN_PRIVDEV + ADEDLEN_PRIVINO + \
122 ADEDLEN_PRIVSYN + ADEDLEN_PRIVID + (ADEID_NUM_V2 * AD_ENTRY_LEN))
124#error bad size for AD_DATASZ2
127#define AD_DATASZ_EA (AD_HEADER_LEN + (ADEID_NUM_EA * AD_ENTRY_LEN) + \
128 ADEDLEN_FINDERI + ADEDLEN_COMMENT + ADEDLEN_FILEDATESI + ADEDLEN_AFPFILEI + \
129 ADEDLEN_PRIVDEV + ADEDLEN_PRIVINO + ADEDLEN_PRIVSYN + ADEDLEN_PRIVID)
131#if AD_DATASZ_EA != 402
132#error bad size for AD_DATASZ_EA
135#define AD_DATASZ_OSX (AD_HEADER_LEN + (ADEID_NUM_OSX * AD_ENTRY_LEN) + ADEDLEN_FINDERI)
137#if AD_DATASZ_OSX != 82
138#error bad size for AD_DATASZ_OSX
141#define AD_DATASZ_MAX 1024
143#if AD_VERSION == AD_VERSION2
144#define AD_DATASZ AD_DATASZ2
145#elif AD_VERSION == AD_VERSION_EA
146#define AD_DATASZ AD_DATASZ_EA
150#define ADEDOFF_FINDERI_OSX (AD_HEADER_LEN + ADEID_NUM_OSX*AD_ENTRY_LEN)
151#define ADEDOFF_RFORK_OSX (ADEDOFF_FINDERI_OSX + ADEDLEN_FINDERI)
178#define AD_INITED 0xad494e54
179#define AD_CLOSED 0xadc10ced
184 const char *(*ad_path)(
const char *, int);
233#define ADFLAGS_DF (1<<0)
234#define ADFLAGS_RF (1<<1)
235#define ADFLAGS_HF (1<<2)
236#define ADFLAGS_DIR (1<<3)
237#define ADFLAGS_NOHF (1<<4)
238#define ADFLAGS_NORF (1<<5)
239#define ADFLAGS_CHECK_OF (1<<6)
240#define ADFLAGS_SETSHRMD (1<<7)
246#define ADFLAGS_RDWR (1<<8)
247#define ADFLAGS_RDONLY (1<<9)
248#define ADFLAGS_CREATE (1<<10)
249#define ADFLAGS_EXCL (1<<11)
250#define ADFLAGS_TRUNC (1<<12)
252#define ADVOL_NODEV (1 << 0)
253#define ADVOL_RO (1 << 1)
254#define ADVOL_UNIXPRIV (1 << 2)
255#define ADVOL_INVDOTS (1 << 3)
256#define ADVOL_FOLLO_SYML (1 << 4)
257#define ADVOL_FORCE_STICKY_XATTR (1 << 5)
260#define ADLOCK_CLR (0)
261#define ADLOCK_RD (1<<0)
262#define ADLOCK_WR (1<<1)
263#define ADLOCK_MASK (ADLOCK_RD | ADLOCK_WR)
264#define ADLOCK_UPGRADE (1<<2)
265#define ADLOCK_FILELOCK (1<<3)
269#if _FILE_OFFSET_BITS == 64
270#define AD_FILELOCK_BASE (UINT64_C(0x7FFFFFFFFFFFFFFF) - 9)
272#define AD_FILELOCK_BASE (UINT32_C(0x7FFFFFFF) - 9)
275#define BYTELOCK_MAX (AD_FILELOCK_BASE - 1)
278#define AD_FILELOCK_OPEN_WR (AD_FILELOCK_BASE + 0)
279#define AD_FILELOCK_OPEN_RD (AD_FILELOCK_BASE + 1)
280#define AD_FILELOCK_RSRC_OPEN_WR (AD_FILELOCK_BASE + 2)
281#define AD_FILELOCK_RSRC_OPEN_RD (AD_FILELOCK_BASE + 3)
283#define AD_FILELOCK_DENY_WR (AD_FILELOCK_BASE + 4)
284#define AD_FILELOCK_DENY_RD (AD_FILELOCK_BASE + 5)
285#define AD_FILELOCK_RSRC_DENY_WR (AD_FILELOCK_BASE + 6)
286#define AD_FILELOCK_RSRC_DENY_RD (AD_FILELOCK_BASE + 7)
288#define AD_FILELOCK_OPEN_NONE (AD_FILELOCK_BASE + 8)
289#define AD_FILELOCK_RSRC_OPEN_NONE (AD_FILELOCK_BASE + 9)
292#define AD_DATE_CREATE 0
293#define AD_DATE_MODIFY 4
294#define AD_DATE_BACKUP 8
295#define AD_DATE_ACCESS 12
296#define AD_DATE_MASK (AD_DATE_CREATE | AD_DATE_MODIFY | \
297 AD_DATE_BACKUP | AD_DATE_ACCESS)
298#define AD_DATE_UNIX (1 << 10)
299#define AD_DATE_START htonl(0x80000000)
300#define AD_DATE_DELTA 946684800
301#define AD_DATE_FROM_UNIX(x) htonl((x) - AD_DATE_DELTA)
302#define AD_DATE_TO_UNIX(x) (ntohl(x) + AD_DATE_DELTA)
305#define FINDERINFO_FRTYPEOFF 0
306#define FINDERINFO_FRCREATOFF 4
307#define FINDERINFO_FRFLAGOFF 8
310#define FINDERINFO_ISONDESK (1)
311#define FINDERINFO_COLOR (0x0e)
312#define FINDERINFO_HIDEEXT (1<<4)
313#define FINDERINFO_ISHARED (1<<6)
314#define FINDERINFO_HASNOINITS (1<<7)
315#define FINDERINFO_HASBEENINITED (1<<8)
316#define FINDERINFO_HASCUSTOMICON (1<<10)
317#define FINDERINFO_ISSTATIONNERY (1<<11)
318#define FINDERINFO_NAMELOCKED (1<<12)
319#define FINDERINFO_HASBUNDLE (1<<13)
320#define FINDERINFO_INVISIBLE (1<<14)
321#define FINDERINFO_ISALIAS (1<<15)
323#define FINDERINFO_FRVIEWOFF 14
324#define FINDERINFO_CUSTOMICON 0x4
325#define FINDERINFO_CLOSEDVIEW 0x100
334#define ATTRBIT_INVISIBLE (1<<0)
335#define ATTRBIT_MULTIUSER (1<<1)
336#define ATTRBIT_SYSTEM (1<<2)
337#define ATTRBIT_DOPEN (1<<3)
338#define ATTRBIT_ROPEN (1<<4)
339#define ATTRBIT_NOWRITE (1<<5)
340#define ATTRBIT_BACKUP (1<<6)
341#define ATTRBIT_NORENAME (1<<7)
342#define ATTRBIT_NODELETE (1<<8)
343#define ATTRBIT_NOCOPY (1<<10)
344#define ATTRBIT_SETCLR (1<<15)
348#define ATTRBIT_EXPFLDR (1<<1)
349#define ATTRBIT_MOUNTED (1<<3)
350#define ATTRBIT_SHARED (1<<4)
353#define AD_AFPFILEI_OWNER (1 << 0)
354#define AD_AFPFILEI_GROUP (1 << 1)
355#define AD_AFPFILEI_BLANKACCESS (1 << 2)
360#define AD_FILLER_NETATALK "Netatalk "
361#define AD_FILLER_OSX "Mac OS X"
363#define ad_data_fileno(ad) ((ad)->ad_data_fork.adf_fd)
364#define ad_reso_fileno(ad) ((ad)->ad_rfp->adf_fd)
365#define ad_meta_fileno(ad) ((ad)->ad_mdp->adf_fd)
368#define AD_DATA_OPEN(ad) (((ad)->ad_data_refcount) && (ad_data_fileno(ad) >= 0))
369#define AD_META_OPEN(ad) (((ad)->ad_meta_refcount) && (ad_meta_fileno(ad) >= 0))
370#define AD_RSRC_OPEN(ad) (((ad)->ad_reso_refcount) && (ad_reso_fileno(ad) >= 0))
372#define ad_getversion(ad) ((ad)->ad_version)
374#define ad_getentrylen(ad,eid) ((ad)->ad_eid[(eid)].ade_len)
375#define ad_setentrylen(ad,eid,len) ((ad)->ad_eid[(eid)].ade_len = (len))
376#define ad_setentryoff(ad,eid,off) ((ad)->ad_eid[(eid)].ade_off = (off))
378#define ad_get_RF_flags(ad) ((ad)->ad_rfp->adf_flags)
379#define ad_get_MD_flags(ad) ((ad)->ad_mdp->adf_flags)
382#define ad_ref(ad) (ad)->ad_refcount++
383#define ad_unref(ad) --((ad)->ad_refcount)
385#define ad_get_syml_opt(ad) (((ad)->ad_options & ADVOL_FOLLO_SYML) ? 0 : O_NOFOLLOW)
395 const void *value,
size_t size,
int flags);
401 off_t len,
int fork);
404 off_t len,
int fork);
412extern char *
ad_dir(
const char *);
413extern const char *
ad_path(
const char *,
int);
416extern int ad_mode(
const char *, mode_t);
417extern int ad_mkdir(
const char *, mode_t);
424extern int ad_open_native_finderinfo(
const char *
path,
char *ret);
429extern int ad_stat(
const char *,
struct stat *);
438 const struct vol *
vol,
const char **newpath);
442extern ssize_t
ad_read(
struct adouble *, uint32_t, off_t,
char *,
size_t);
443extern ssize_t
ad_pread(
struct ad_fd *,
void *,
size_t, off_t);
444extern ssize_t
ad_write(
struct adouble *, uint32_t, off_t,
int,
const char *,
451 uint8_t *
buf,
size_t buflen);
459#define ad_munmap(buf, len) (munmap((buf), (len)))
470 uint32_t,
const void *);
475extern int ad_readfile_init(
const struct adouble *ad,
int eid, off_t *off,
479extern ssize_t ad_recvfile(
struct adouble *ad,
int eid,
int sock, off_t off,
const char * ad_path_ea(const char *, int)
int ad_lock(struct adouble *, uint32_t eid, int type, off_t off, off_t len, int fork)
Definition ad_lock.c:387
int ad_rebuild_adouble_header_osx(struct adouble *ad, char *adbuf)
Definition ad_flush.c:138
int ad_dtruncate(struct adouble *, off_t)
Definition ad_write.c:199
int ad_testlock(struct adouble *adp, int eid, off_t off)
Definition ad_lock.c:639
uint32_t ad_forcegetid(struct adouble *adp)
Definition ad_attr.c:287
int ad_setfuid(const uid_t)
Definition ad_open.c:2148
int ad_setattr(const struct adouble *, const uint16_t)
Definition ad_attr.c:66
int ad_convert(const char *path, const struct stat *sp, const struct vol *vol, const char **newpath)
Definition ad_conv.c:321
off_t ad_reso_size(const char *path, int adflags, struct adouble *ad)
uid_t ad_getfuid(void)
Definition ad_open.c:2155
int fsetrsrcea(struct adouble *ad, int fd, const char *eaname, const void *value, size_t size, int flags)
int ad_openat(struct adouble *, int dirfd, const char *path, int adflags,...)
Definition ad_open.c:2522
int ad_rebuild_adouble_header_v2(struct adouble *)
Definition ad_flush.c:55
void ad_init(struct adouble *, const struct vol *restrict)
int ad_tmplock(struct adouble *, uint32_t eid, int type, off_t off, off_t len, int fork)
Definition ad_lock.c:541
const char * ad_path(const char *, int)
Definition ad_open.c:2033
int ad_valid_header_osx(const char *path)
Definition ad_open.c:596
int ad_rtruncate(struct adouble *, const char *, off_t)
Definition ad_write.c:175
void ad_init_old(struct adouble *ad, int flags, int options)
Definition ad_open.c:2233
void ad_unlock(struct adouble *, int fork, int unlckbrl)
Definition ad_lock.c:614
int ad_rebuild_adouble_header_ea(struct adouble *)
Definition ad_flush.c:95
int ad_getdate(const struct adouble *, unsigned int, uint32_t *)
Definition ad_date.c:39
ssize_t adf_pread(struct ad_fd *, void *, size_t, off_t)
Definition ad_read.c:38
int ad_open(struct adouble *ad, const char *path, int adflags,...)
Definition ad_open.c:2299
off_t ad_size(const struct adouble *, uint32_t)
Definition ad_size.c:18
int ad_getattr(const struct adouble *, uint16_t *)
Definition ad_attr.c:23
int ad_mode(const char *, mode_t)
Definition ad_open.c:2178
const char * ad_path_osx(const char *path, int adflags)
Definition ad_open.c:1982
int ad_refresh(const char *path, struct adouble *)
Definition ad_open.c:2457
void * ad_mmapwrite(struct adouble *, uint32_t, off_t, int, size_t)
int ad_copy_header(struct adouble *, struct adouble *)
Definition ad_flush.c:194
int ad_metadataat(int, const char *, int, struct adouble *)
Definition ad_open.c:2424
uint16_t ad_openforks(struct adouble *adp, uint16_t)
Definition ad_lock.c:671
int ad_metadata(const char *, int, struct adouble *)
open metadata, possibly as root
Definition ad_open.c:2403
ssize_t ad_pread(struct ad_fd *, void *, size_t, off_t)
void * ad_entry(const struct adouble *ad, int eid)
Definition ad_open.c:1928
#define AD_DATASZ_MAX
Definition adouble.h:141
int ad_flush(struct adouble *)
Definition ad_flush.c:439
int ad_close(struct adouble *, int)
Definition ad_flush.c:476
int ad_mkdir(const char *, mode_t)
Definition ad_open.c:2188
uint32_t ad_getid(struct adouble *, dev_t, ino_t, cnid_t, const void *)
off_t ad_getentryoff(const struct adouble *ad, int eid)
Definition ad_open.c:1952
const char * adflags2logstr(int adflags)
Definition ad_open.c:172
#define ADEID_MAX
Definition adouble.h:75
char * ad_dir(const char *)
Definition ad_open.c:2090
int ad_setdate(struct adouble *, unsigned int, uint32_t)
Definition ad_date.c:10
int ad_setname(struct adouble *, const char *)
Definition ad_attr.c:314
ssize_t adf_pwrite(struct ad_fd *, const void *, size_t, off_t)
Definition ad_write.c:25
mode_t ad_hf_mode(mode_t mode)
Definition ad_open.c:2566
int ad_setid(struct adouble *, dev_t dev, ino_t ino, uint32_t, uint32_t, const void *)
Definition ad_attr.c:113
uint32_t cnid_t
Definition adouble.h:156
ssize_t ad_write(struct adouble *, uint32_t, off_t, int, const char *, size_t)
Definition ad_write.c:53
void * ad_mmapread(struct adouble *, uint32_t, off_t, size_t)
int ad_init_offsets(struct adouble *ad)
Definition ad_open.c:374
int sys_ftruncate(int fd, off_t length)
Definition ad_write.c:118
int ad_stat(const char *, struct stat *)
Definition ad_open.c:2163
ssize_t ad_read(struct adouble *, uint32_t, off_t, char *, size_t)
Definition ad_read.c:65
int copy_fork(int eid, struct adouble *add, struct adouble *ads, uint8_t *buf, size_t buflen)
Definition ad_write.c:236
static int sock
Definition aecho.c:58
static char buf[MAXPATHLEN+1]
Definition afppasswd.c:66
static dbd_flags_t flags
Definition cmd_dbd.c:45
static enum op type
Definition nad_cp.c:95
off_t ade_off
Definition adouble.h:159
ssize_t ade_len
Definition adouble.h:160
char * adf_syml
Definition adouble.h:171
int adf_lockcount
Definition adouble.h:174
adf_lock_t * adf_lock
Definition adouble.h:173
int adf_flags
Definition adouble.h:172
int adf_refcount
Definition adouble.h:174
int adf_lockmax
Definition adouble.h:174
int adf_fd
Definition adouble.h:170
struct flock lock
Definition adouble.h:164
int * refcount
Definition adouble.h:166
int user
Definition adouble.h:165
int(* ad_rebuild_header)(struct adouble *)
Definition adouble.h:186
int(* ad_header_read)(const char *, struct adouble *, const struct stat *)
Definition adouble.h:187
int(* ad_mkrf)(const char *)
Definition adouble.h:185
int(* ad_header_upgrade)(struct adouble *, const char *)
Definition adouble.h:188
uint32_t ad_version
Definition adouble.h:195
struct ad_fd * ad_mdp
Definition adouble.h:208
int ad_meta_refcount
Definition adouble.h:218
uint32_t ad_inited
Definition adouble.h:213
int ad_vers
Definition adouble.h:210
size_t valid_data_len
Definition adouble.h:229
struct adouble_fops * ad_ops
Definition adouble.h:225
char ad_data[AD_DATASZ_MAX]
Definition adouble.h:230
int ad_adflags
Definition adouble.h:212
uint32_t ad_magic
Definition adouble.h:193
off_t ad_rlen
Definition adouble.h:222
int ad_reso_refcount
Definition adouble.h:219
struct ad_fd ad_resource_fork
Definition adouble.h:202
char * ad_name
Definition adouble.h:224
struct ad_entry ad_eid[ADEID_MAX]
Definition adouble.h:197
uint16_t ad_open_forks
Definition adouble.h:227
struct ad_fd * ad_rfp
Definition adouble.h:205
char ad_filler[16]
Definition adouble.h:196
int ad_options
Definition adouble.h:214
int ad_refcount
Definition adouble.h:216
int ad_data_refcount
Definition adouble.h:217
struct ad_fd ad_data_fork
Definition adouble.h:199
Definition include/atalk/directory.h:97
Definition include/atalk/volume.h:32