netatalk  4.6.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
adouble.h
Go to the documentation of this file.
1/*
2* Copyright (c) 1990,1991 Regents of The University of Michigan.
3* All Rights Reserved.
4*
5* Permission to use, copy, modify, and distribute this software and
6* its documentation for any purpose and without fee is hereby granted,
7* provided that the above copyright notice appears in all copies and
8* that both that copyright notice and this permission notice appear
9* in supporting documentation, and that the name of The University
10* of Michigan not be used in advertising or publicity pertaining to
11* distribution of the software without specific, written prior
12* permission. This software is supplied as is without expressed or
13* implied warranties of any kind.
14*
15* Research Systems Unix Group
16* The University of Michigan
17* c/o Mike Clark
18* 535 W. William Street
19* Ann Arbor, Michigan
20* +1-313-763-0525
21* netatalk@itd.umich.edu
22*/
23
28
29#ifndef _ATALK_ADOUBLE_H
30#define _ATALK_ADOUBLE_H
31
32#ifdef HAVE_CONFIG_H
33#include "config.h"
34#endif
35
36#include <fcntl.h>
37#include <inttypes.h>
38#include <stdbool.h>
39#include <sys/mman.h>
40#include <sys/stat.h>
41#include <sys/time.h>
42#include <sys/types.h>
43#include <unistd.h>
44
45/* version info */
46#define AD_VERSION2 0x00020000
47#define AD_VERSION_EA 0x00020002
48
49/* default */
50#define AD_VERSION AD_VERSION_EA
51
52/*
53 * AppleDouble entry IDs.
54 */
55#define ADEID_DFORK 1
56#define ADEID_RFORK 2
57#define ADEID_NAME 3
58#define ADEID_COMMENT 4
59#define ADEID_ICONBW 5
60#define ADEID_ICONCOL 6
61#define ADEID_FILEI 7
62#define ADEID_FILEDATESI 8
63#define ADEID_FINDERI 9
64#define ADEID_MACFILEI 10
65#define ADEID_PRODOSFILEI 11
66#define ADEID_MSDOSFILEI 12
67#define ADEID_SHORTNAME 13
68#define ADEID_AFPFILEI 14
69#define ADEID_DID 15
70
71/* netatalk private note fileid reused DID */
72#define ADEID_PRIVDEV 16
73#define ADEID_PRIVINO 17
74#define ADEID_PRIVSYN 18
75#define ADEID_PRIVID 19
76#define ADEID_MAX (ADEID_PRIVID + 1)
77
78/* These are the real ids for these entries, as stored in the adouble file */
79#define AD_DEV 0x80444556
80#define AD_INO 0x80494E4F
81#define AD_SYN 0x8053594E
82#define AD_ID 0x8053567E
83
84/* magic */
85#define AD_APPLESINGLE_MAGIC 0x00051600
86#define AD_APPLEDOUBLE_MAGIC 0x00051607
87#define AD_MAGIC AD_APPLEDOUBLE_MAGIC
88
89/* sizes of relevant entry bits */
90#define ADEDLEN_MAGIC 4
91#define ADEDLEN_VERSION 4
92#define ADEDLEN_FILLER 16
93#define ADEDLEN_NENTRIES 2
94#define AD_HEADER_LEN (ADEDLEN_MAGIC + ADEDLEN_VERSION + ADEDLEN_FILLER + ADEDLEN_NENTRIES)
95#define AD_ENTRY_LEN 12
96
97/* field widths */
98#define ADEDLEN_NAME 255
99#define ADEDLEN_COMMENT 200
100#define ADEDLEN_FILEI 16
101#define ADEDLEN_FINDERI 32
102#define ADEDLEN_FILEDATESI 16
103#define ADEDLEN_SHORTNAME 12
104#define ADEDLEN_AFPFILEI 4
105#define ADEDLEN_MACFILEI 4
106#define ADEDLEN_PRODOSFILEI 8
107#define ADEDLEN_MSDOSFILEI 2
108#define ADEDLEN_ICONBW 128
109#define ADEDLEN_ICONCOL 1024
110#define ADEDLEN_DID 4
111#define ADEDLEN_PRIVDEV 8
112#define ADEDLEN_PRIVINO 8
113#define ADEDLEN_PRIVSYN 8
114#define ADEDLEN_PRIVID 4
115
116#define ADEID_NUM_V2 13
117#define ADEID_NUM_EA 8
118#define ADEID_NUM_OSX 2
119
120#define AD_DATASZ2 (AD_HEADER_LEN + ADEDLEN_NAME + ADEDLEN_COMMENT + ADEDLEN_FILEI + \
121 ADEDLEN_FINDERI + ADEDLEN_DID + ADEDLEN_AFPFILEI + ADEDLEN_SHORTNAME + \
122 ADEDLEN_PRODOSFILEI + ADEDLEN_PRIVDEV + ADEDLEN_PRIVINO + \
123 ADEDLEN_PRIVSYN + ADEDLEN_PRIVID + (ADEID_NUM_V2 * AD_ENTRY_LEN))
124#if AD_DATASZ2 != 741
125#error bad size for AD_DATASZ2
126#endif
127
128#define AD_DATASZ_EA (AD_HEADER_LEN + (ADEID_NUM_EA * AD_ENTRY_LEN) + \
129 ADEDLEN_FINDERI + ADEDLEN_COMMENT + ADEDLEN_FILEDATESI + ADEDLEN_AFPFILEI + \
130 ADEDLEN_PRIVDEV + ADEDLEN_PRIVINO + ADEDLEN_PRIVSYN + ADEDLEN_PRIVID)
131
132#if AD_DATASZ_EA != 402
133#error bad size for AD_DATASZ_EA
134#endif
135
136#define AD_DATASZ_OSX (AD_HEADER_LEN + (ADEID_NUM_OSX * AD_ENTRY_LEN) + ADEDLEN_FINDERI)
137
138#if AD_DATASZ_OSX != 82
139#error bad size for AD_DATASZ_OSX
140#endif
141
142#define AD_DATASZ_MAX 1024
143
144#if AD_VERSION == AD_VERSION2
145#define AD_DATASZ AD_DATASZ2
146#elif AD_VERSION == AD_VERSION_EA
147#define AD_DATASZ AD_DATASZ_EA
148#endif
149
150/* fallback for ad:ea on filesystems without fds for EAs, like old adouble:osx */
151#define ADEDOFF_FINDERI_OSX (AD_HEADER_LEN + ADEID_NUM_OSX*AD_ENTRY_LEN)
152#define ADEDOFF_RFORK_OSX (ADEDOFF_FINDERI_OSX + ADEDLEN_FINDERI)
153
155#define AD_SYMLINK -2
156
157typedef uint32_t cnid_t;
158
159struct ad_entry {
160 off_t ade_off;
161 ssize_t ade_len;
162};
163
169
175
183
184/* some header protection */
185#define AD_INITED 0xad494e54
186#define AD_CLOSED 0xadc10ced
187
188struct adouble;
189
191 const char *(*ad_path)(const char *, int);
192 int (*ad_mkrf)(const char *);
193 int (*ad_rebuild_header)(struct adouble *);
194 int (*ad_header_read)(const char *, struct adouble *, const struct stat *);
195 int (*ad_header_upgrade)(struct adouble *, const char *);
196};
197
231
232#define ADFLAGS_DF (1<<0)
233#define ADFLAGS_RF (1<<1)
234#define ADFLAGS_HF (1<<2)
235#define ADFLAGS_DIR (1<<3)
236#define ADFLAGS_NOHF (1<<4)
237#define ADFLAGS_NORF (1<<5)
238#define ADFLAGS_CHECK_OF (1<<6)
239#define ADFLAGS_SETSHRMD (1<<7)
245#define ADFLAGS_RDWR (1<<8)
246#define ADFLAGS_RDONLY (1<<9)
247#define ADFLAGS_CREATE (1<<10)
248#define ADFLAGS_EXCL (1<<11)
249#define ADFLAGS_TRUNC (1<<12)
250
251#define ADVOL_NODEV (1 << 0)
252#define ADVOL_RO (1 << 1)
253#define ADVOL_UNIXPRIV (1 << 2)
254#define ADVOL_INVDOTS (1 << 3)
255#define ADVOL_FOLLO_SYML (1 << 4)
256#define ADVOL_FORCE_STICKY_XATTR (1 << 5)
257
258/* lock flags */
259#define ADLOCK_CLR (0)
260#define ADLOCK_RD (1<<0)
261#define ADLOCK_WR (1<<1)
262#define ADLOCK_MASK (ADLOCK_RD | ADLOCK_WR)
263#define ADLOCK_UPGRADE (1<<2)
264#define ADLOCK_FILELOCK (1<<3)
265
266/* we use this so that we can use the same mechanism for both byte
267 * locks and file synchronization locks. */
268#if _FILE_OFFSET_BITS == 64
269#define AD_FILELOCK_BASE (UINT64_C(0x7FFFFFFFFFFFFFFF) - 9)
270#else
271#define AD_FILELOCK_BASE (UINT32_C(0x7FFFFFFF) - 9)
272#endif
273
274#define BYTELOCK_MAX (AD_FILELOCK_BASE - 1)
275
276/* datafork and rsrcfork sharemode locks */
277#define AD_FILELOCK_OPEN_WR (AD_FILELOCK_BASE + 0)
278#define AD_FILELOCK_OPEN_RD (AD_FILELOCK_BASE + 1)
279#define AD_FILELOCK_RSRC_OPEN_WR (AD_FILELOCK_BASE + 2)
280#define AD_FILELOCK_RSRC_OPEN_RD (AD_FILELOCK_BASE + 3)
281
282#define AD_FILELOCK_DENY_WR (AD_FILELOCK_BASE + 4)
283#define AD_FILELOCK_DENY_RD (AD_FILELOCK_BASE + 5)
284#define AD_FILELOCK_RSRC_DENY_WR (AD_FILELOCK_BASE + 6)
285#define AD_FILELOCK_RSRC_DENY_RD (AD_FILELOCK_BASE + 7)
286
287#define AD_FILELOCK_OPEN_NONE (AD_FILELOCK_BASE + 8)
288#define AD_FILELOCK_RSRC_OPEN_NONE (AD_FILELOCK_BASE + 9)
289
290/* share-mode band as a bitmap: bit n == AD_FILELOCK_BASE + n */
291#define AD_FILELOCK_BAND_BITS 10
292
293#define OPEN_WR_BIT (1U << (AD_FILELOCK_OPEN_WR - AD_FILELOCK_BASE))
294#define OPEN_RD_BIT (1U << (AD_FILELOCK_OPEN_RD - AD_FILELOCK_BASE))
295#define RSRC_OPEN_WR_BIT (1U << (AD_FILELOCK_RSRC_OPEN_WR - AD_FILELOCK_BASE))
296#define RSRC_OPEN_RD_BIT (1U << (AD_FILELOCK_RSRC_OPEN_RD - AD_FILELOCK_BASE))
297#define DENY_WR_BIT (1U << (AD_FILELOCK_DENY_WR - AD_FILELOCK_BASE))
298#define DENY_RD_BIT (1U << (AD_FILELOCK_DENY_RD - AD_FILELOCK_BASE))
299#define RSRC_DENY_WR_BIT (1U << (AD_FILELOCK_RSRC_DENY_WR - AD_FILELOCK_BASE))
300#define RSRC_DENY_RD_BIT (1U << (AD_FILELOCK_RSRC_DENY_RD - AD_FILELOCK_BASE))
301#define OPEN_NONE_BIT (1U << (AD_FILELOCK_OPEN_NONE - AD_FILELOCK_BASE))
302#define RSRC_OPEN_NONE_BIT (1U << (AD_FILELOCK_RSRC_OPEN_NONE - AD_FILELOCK_BASE))
303
304#define ALL_BAND_BITS ((1U << AD_FILELOCK_BAND_BITS) - 1)
305#define OPEN_BITS (OPEN_WR_BIT | OPEN_RD_BIT \
306 | RSRC_OPEN_WR_BIT | RSRC_OPEN_RD_BIT)
307/* band bits that block a delete, one mask for every holder (this session or
308 * a peer): only explicit deny modes. An OPEN_* marker (NONE/RD/WR, data or
309 * rsrc) records access, not a claim against others; the declared claims are
310 * deny modes and content byte-range locks (checked separately, always
311 * block). Same model as SMB/Samba share modes, whose conflict engine never
312 * blocks on an existing handle's READ/WRITE access, only on a withheld
313 * share mode — and the engine runs identically for same-client and
314 * cross-client handles. */
315#define DELETE_BLOCKING_BAND_BITS \
316 (DENY_WR_BIT | DENY_RD_BIT | RSRC_DENY_WR_BIT | RSRC_DENY_RD_BIT)
317
318/* time stuff. we overload the bits a little. */
319#define AD_DATE_CREATE 0
320#define AD_DATE_MODIFY 4
321#define AD_DATE_BACKUP 8
322#define AD_DATE_ACCESS 12
323#define AD_DATE_MASK (AD_DATE_CREATE | AD_DATE_MODIFY | \
324 AD_DATE_BACKUP | AD_DATE_ACCESS)
325#define AD_DATE_UNIX (1 << 10)
326#define AD_DATE_START htonl(0x80000000)
327#define AD_DATE_DELTA 946684800
328#define AD_DATE_FROM_UNIX(x) htonl((x) - AD_DATE_DELTA)
329#define AD_DATE_TO_UNIX(x) (ntohl(x) + AD_DATE_DELTA)
330#define AD_DATE_MAC_DELTA 3029529600U
331#define AD_DATE_FROM_MAC(x) htonl(ntohl(x) - AD_DATE_MAC_DELTA)
332#define AD_DATE_TO_MAC(x) htonl(ntohl(x) + AD_DATE_MAC_DELTA)
333
338
339/* various finder offset and info bits */
340#define FINDERINFO_FRTYPEOFF 0
341#define FINDERINFO_FRCREATOFF 4
342#define FINDERINFO_FRFLAGOFF 8
343
344/* FinderInfo Flags, char in `ad ls`, valid for files|dirs */
345#define FINDERINFO_ISONDESK (1)
346#define FINDERINFO_COLOR (0x0e)
347#define FINDERINFO_HIDEEXT (1<<4)
348#define FINDERINFO_ISHARED (1<<6)
349#define FINDERINFO_HASNOINITS (1<<7)
350#define FINDERINFO_HASBEENINITED (1<<8)
351#define FINDERINFO_HASCUSTOMICON (1<<10)
352#define FINDERINFO_ISSTATIONNERY (1<<11)
353#define FINDERINFO_NAMELOCKED (1<<12)
354#define FINDERINFO_HASBUNDLE (1<<13)
355#define FINDERINFO_INVISIBLE (1<<14)
356#define FINDERINFO_ISALIAS (1<<15)
357
358#define FINDERINFO_FRVIEWOFF 14
359#define FINDERINFO_CUSTOMICON 0x4
360#define FINDERINFO_CLOSEDVIEW 0x100
361
362/*
363 The "shared" and "invisible" attributes are opaque and stored and
364 retrieved from the FinderFlags. This fixes Bug #2802236:
365 <https://sourceforge.net/tracker/?func=detail&aid=2802236&group_id=8642&atid=108642>
366*/
367
368/* AFP attributes, char in `ad ls`, valid for files|dirs */
369#define ATTRBIT_INVISIBLE (1<<0)
370#define ATTRBIT_MULTIUSER (1<<1)
371#define ATTRBIT_SYSTEM (1<<2)
372#define ATTRBIT_DOPEN (1<<3)
373#define ATTRBIT_ROPEN (1<<4)
374#define ATTRBIT_NOWRITE (1<<5)
375#define ATTRBIT_BACKUP (1<<6)
376#define ATTRBIT_NORENAME (1<<7)
377#define ATTRBIT_NODELETE (1<<8)
378#define ATTRBIT_NOCOPY (1<<10)
379#define ATTRBIT_SETCLR (1<<15)
380
381/* AFP attributes for dirs. These should probably be computed on the fly.
382 * We don't do that, nor does e.g. OS S X 10.5 Server */
383#define ATTRBIT_EXPFLDR (1<<1)
384#define ATTRBIT_MOUNTED (1<<3)
385#define ATTRBIT_SHARED (1<<4)
386
387/* private AFPFileInfo bits */
388#define AD_AFPFILEI_OWNER (1 << 0)
389#define AD_AFPFILEI_GROUP (1 << 1)
390#define AD_AFPFILEI_BLANKACCESS (1 << 2)
391
392/*
393 * String identifiers for the 16 AppleDouble filler bytes
394 */
395#define AD_FILLER_NETATALK "Netatalk "
396#define AD_FILLER_OSX "Mac OS X"
397
398#define ad_data_fileno(ad) ((ad)->ad_data_fork.adf_fd)
399#define ad_reso_fileno(ad) ((ad)->ad_rfp->adf_fd)
400#define ad_meta_fileno(ad) ((ad)->ad_mdp->adf_fd)
401
402/* fd states: -1 = not open, AD_SYMLINK (-2) = it's a symlink */
403static inline int ad_data_open(const struct adouble *ad)
404{
405 return ad->ad_data_refcount && ad_data_fileno(ad) >= 0;
406}
407
408static inline int ad_meta_open(const struct adouble *ad)
409{
410 return ad->ad_meta_refcount && ad_meta_fileno(ad) >= 0;
411}
412
413static inline int ad_rsrc_open(const struct adouble *ad)
414{
415 return ad->ad_reso_refcount && ad_reso_fileno(ad) >= 0;
416}
417
423static inline int ad_meta_loaded(const struct adouble *ad)
424{
425 return ad->ad_meta_refcount > 0
426 && ad_meta_fileno(ad) != AD_SYMLINK
427 && ad_data_fileno(ad) != AD_SYMLINK;
428}
429
430#define ad_getversion(ad) ((ad)->ad_version)
431
432#define ad_getentrylen(ad,eid) ((ad)->ad_eid[(eid)].ade_len)
433#define ad_setentrylen(ad,eid,len) ((ad)->ad_eid[(eid)].ade_len = (len))
434#define ad_setentryoff(ad,eid,off) ((ad)->ad_eid[(eid)].ade_off = (off))
435
436#define ad_get_RF_flags(ad) ((ad)->ad_rfp->adf_flags)
437#define ad_get_MD_flags(ad) ((ad)->ad_mdp->adf_flags)
438
439/* Refcounting open forks using one struct adouble */
440#define ad_ref(ad) (ad)->ad_refcount++
441#define ad_unref(ad) --((ad)->ad_refcount)
442
443#define ad_get_syml_opt(ad) (((ad)->ad_options & ADVOL_FOLLO_SYML) ? 0 : O_NOFOLLOW)
444
445/* ad_flush.c */
446extern int ad_rebuild_adouble_header_v2(struct adouble *);
447extern int ad_rebuild_adouble_header_ea(struct adouble *);
448extern int ad_rebuild_adouble_header_osx(struct adouble *ad, char *adbuf);
449extern int ad_copy_header(struct adouble *, struct adouble *);
450extern int ad_flush(struct adouble *);
451extern int ad_close(struct adouble *, int);
452extern int fsetrsrcea(struct adouble *ad, int fd, const char *eaname,
453 const void *value, size_t size, int flags);
454
455/* ad_lock.c */
456extern int ad_testlock(struct adouble *adp, int eid, off_t off);
457extern int ad_testlock_range(struct adouble *adp, int eid, off_t off,
458 off_t len);
459extern int ad_testlock_whole(struct adouble *adp, int eid);
460extern uint16_t ad_openforks(struct adouble *adp, uint16_t);
461extern int ad_lock(struct adouble *, uint32_t eid, int type, off_t off,
462 off_t len, int fork);
463extern void ad_unlock(struct adouble *, int fork);
464extern void adf_lock_init(struct ad_fd *adf);
465extern void adf_lock_free(struct ad_fd *adf);
466extern int ad_tmplock(struct adouble *, uint32_t eid, int type, off_t off,
467 off_t len, int fork);
468
469/* ad_open.c */
470extern void *ad_entry(const struct adouble *ad, int eid);
471extern bool ad_entry_fits(const struct adouble *ad, int eid, uint32_t len);
472extern off_t ad_getentryoff(const struct adouble *ad, int eid);
473extern const char *adflags2logstr(int adflags);
474extern int ad_setfuid(const uid_t);
475extern uid_t ad_getfuid(void);
476extern char *ad_dir(const char *);
477extern const char *ad_path(const char *, int);
478extern const char *ad_path_ea(const char *, int);
479extern const char *ad_path_osx(const char *path, int adflags);
480extern int ad_mode(const char *, mode_t);
481extern int ad_mkdir(const char *, mode_t);
482struct vol;
483extern void ad_init(struct adouble *, const struct vol *);
484extern void ad_init_old(struct adouble *ad, int flags, int options);
485extern int ad_init_offsets(struct adouble *ad);
486extern int ad_open(struct adouble *ad, const char *path, int adflags, ...);
487#ifdef __APPLE__
488extern int ad_open_native_finderinfo(const char *path, char *ret);
489#endif
490extern int ad_openat(struct adouble *, int dirfd, const char *path,
491 int adflags, ...);
492extern int ad_refresh(const char *path, struct adouble *);
493extern int ad_stat(const char *, struct stat *);
494extern int ad_metadata(const char *, int, struct adouble *);
495extern int ad_metadataat(int, const char *, int, struct adouble *);
496extern mode_t ad_hf_mode(mode_t mode);
497extern int ad_valid_header_osx(const char *path);
498extern off_t ad_reso_size(const char *path, int adflags, struct adouble *ad);
499
500/* ad_conv.c */
501extern int ad_convert(const char *path, const struct stat *sp,
502 const struct vol *vol, const char **newpath);
503
504/* ad_read.c/ad_write.c */
505extern int sys_ftruncate(int fd, off_t length);
506extern ssize_t ad_read(struct adouble *, uint32_t, off_t, char *, size_t);
507extern ssize_t ad_pread(struct ad_fd *, void *, size_t, off_t);
508extern ssize_t ad_write(struct adouble *, uint32_t, off_t, int, const char *,
509 size_t);
510extern ssize_t adf_pread(struct ad_fd *, void *, size_t, off_t);
511extern ssize_t adf_pwrite(struct ad_fd *, const void *, size_t, off_t);
512extern int ad_dtruncate(struct adouble *, off_t);
513extern int ad_rtruncate(struct adouble *, const char *, off_t);
514extern int copy_fork(int eid, struct adouble *add, struct adouble *ads,
515 uint8_t *buf, size_t buflen);
516
517/* ad_size.c */
518extern off_t ad_size(const struct adouble *, uint32_t);
519
520/* ad_date.c */
521extern int ad_setdate(struct adouble *, unsigned int, uint32_t);
522extern int ad_getdate(const struct adouble *, unsigned int, uint32_t *);
523extern int set_utc_offset(uint32_t *, ad_time_offset_dir_t);
524
525/* ad_attr.c */
526extern int ad_setattr(const struct adouble *, const uint16_t);
527extern int ad_getattr(const struct adouble *, uint16_t *);
528extern int ad_setname(struct adouble *, const char *);
529extern int ad_setid(struct adouble *, dev_t dev, ino_t ino, uint32_t,
530 uint32_t, const void *);
531extern uint32_t ad_getid(struct adouble *, dev_t, ino_t, cnid_t, const void *);
532extern uint32_t ad_forcegetid(struct adouble *adp);
533
534#ifdef WITH_SENDFILE
535extern int ad_readfile_init(const struct adouble *ad, int eid, off_t *off,
536 int end);
537#endif
538#ifdef WITH_RECVFILE
539extern ssize_t ad_recvfile(struct adouble *ad, int eid, int sock, off_t off,
540 size_t len, int);
541#endif
542
543#endif /* _ATALK_ADOUBLE_H */
const char * ad_path_ea(const char *, int)
Definition ad_open.c:2050
int ad_lock(struct adouble *, uint32_t eid, int type, off_t off, off_t len, int fork)
Definition ad_lock.c:493
int ad_rebuild_adouble_header_osx(struct adouble *ad, char *adbuf)
Definition ad_flush.c:137
int ad_dtruncate(struct adouble *, off_t)
Definition ad_write.c:203
int ad_testlock(struct adouble *adp, int eid, off_t off)
Test for a share mode lock.
Definition ad_lock.c:789
uint32_t ad_forcegetid(struct adouble *adp)
Definition ad_attr.c:314
int ad_setfuid(const uid_t)
Definition ad_open.c:2221
int ad_setattr(const struct adouble *, const uint16_t)
Definition ad_attr.c:73
int ad_convert(const char *path, const struct stat *sp, const struct vol *vol, const char **newpath)
AppleDouble and encoding conversion on the fly.
Definition ad_conv.c:319
off_t ad_reso_size(const char *path, int adflags, struct adouble *ad)
Definition ad_open.c:1606
uid_t ad_getfuid(void)
Definition ad_open.c:2228
int set_utc_offset(uint32_t *, ad_time_offset_dir_t)
Convert an AFP date-time value between local time and UTC.
Definition ad_date.c:25
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:2633
static int ad_data_open(const struct adouble *ad)
Definition adouble.h:403
int ad_rebuild_adouble_header_v2(struct adouble *)
Definition ad_flush.c:54
#define ad_data_fileno(ad)
Definition adouble.h:398
int ad_tmplock(struct adouble *, uint32_t eid, int type, off_t off, off_t len, int fork)
Definition ad_lock.c:691
const char * ad_path(const char *, int)
Put the .AppleDouble where it needs to be:
Definition ad_open.c:2106
#define ad_meta_fileno(ad)
Definition adouble.h:400
int ad_valid_header_osx(const char *path)
Definition ad_open.c:597
void ad_init(struct adouble *, const struct vol *)
Definition ad_open.c:2314
static int ad_rsrc_open(const struct adouble *ad)
Definition adouble.h:413
int ad_rtruncate(struct adouble *, const char *, off_t)
Definition ad_write.c:179
void ad_init_old(struct adouble *ad, int flags, int options)
Definition ad_open.c:2306
int ad_rebuild_adouble_header_ea(struct adouble *)
Definition ad_flush.c:94
int ad_getdate(const struct adouble *, unsigned int, uint32_t *)
Definition ad_date.c:96
ssize_t ad_recvfile(struct adouble *ad, int eid, int sock, off_t off, size_t len, int)
Definition ad_recvfile.c:269
ssize_t adf_pread(struct ad_fd *, void *, size_t, off_t)
Definition ad_read.c:39
bool ad_entry_fits(const struct adouble *ad, int eid, uint32_t len)
Whether an entry of len bytes fits at eid's offset in ad.
Definition ad_open.c:2003
int ad_open(struct adouble *ad, const char *path, int adflags,...)
Open data-, metadata(header)- or resource fork.
Definition ad_open.c:2380
off_t ad_size(const struct adouble *, uint32_t)
Definition ad_size.c:17
void ad_unlock(struct adouble *, int fork)
Definition ad_lock.c:764
int ad_getattr(const struct adouble *, uint16_t *)
Definition ad_attr.c:30
int ad_mode(const char *, mode_t)
Definition ad_open.c:2251
struct adf_lock_shared adf_lock_shared_t
const char * ad_path_osx(const char *path, int adflags)
Definition ad_open.c:2055
int ad_refresh(const char *path, struct adouble *)
Definition ad_open.c:2571
int ad_copy_header(struct adouble *, struct adouble *)
Definition ad_flush.c:239
void adf_lock_init(struct ad_fd *adf)
Initialize lock tracking for an ad_fd structure.
Definition ad_lock.c:226
int ad_metadataat(int, const char *, int, struct adouble *)
Definition ad_open.c:2505
int ad_testlock_whole(struct adouble *adp, int eid)
GET-only whole-fd probe: does another process hold any lock on the fd?
Definition ad_lock.c:943
static int ad_meta_loaded(const struct adouble *ad)
Definition adouble.h:423
int ad_testlock_range(struct adouble *adp, int eid, off_t off, off_t len)
GET-only range probe: does another process hold a conflicting lock?
Definition ad_lock.c:849
uint16_t ad_openforks(struct adouble *adp, uint16_t)
Return if a file is open by another process.
Definition ad_lock.c:977
int ad_metadata(const char *, int, struct adouble *)
open metadata, possibly as root
Definition ad_open.c:2484
ssize_t ad_pread(struct ad_fd *, void *, size_t, off_t)
#define AD_DATASZ_MAX
Definition adouble.h:142
int ad_flush(struct adouble *)
Definition ad_flush.c:484
int ad_close(struct adouble *, int)
Definition ad_flush.c:521
int ad_mkdir(const char *, mode_t)
Definition ad_open.c:2261
ad_time_offset_dir_t
Definition adouble.h:334
@ TO_UTC
Definition adouble.h:335
@ TO_LOCALTIME
Definition adouble.h:336
#define ad_reso_fileno(ad)
Definition adouble.h:399
uint32_t ad_getid(struct adouble *, dev_t, ino_t, cnid_t, const void *)
Retrieve stored file / folder.
Definition ad_attr.c:238
int ad_readfile_init(const struct adouble *ad, int eid, off_t *off, int end)
Definition ad_sendfile.c:87
off_t ad_getentryoff(const struct adouble *ad, int eid)
Definition ad_open.c:2025
const char * adflags2logstr(int adflags)
Definition ad_open.c:171
#define ADEID_MAX
Definition adouble.h:76
char * ad_dir(const char *)
Support inherited protection modes for AppleDouble files. The supplied mode is ANDed with the parent ...
Definition ad_open.c:2163
int ad_setdate(struct adouble *, unsigned int, uint32_t)
Definition ad_date.c:67
int ad_setname(struct adouble *, const char *)
Definition ad_attr.c:341
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:2718
#define AD_SYMLINK
Definition adouble.h:155
int ad_setid(struct adouble *, dev_t dev, ino_t ino, uint32_t, uint32_t, const void *)
save file/folder ID in AppleDoubleV2 netatalk private parameters
Definition ad_attr.c:120
uint32_t cnid_t
Definition adouble.h:157
ssize_t ad_write(struct adouble *, uint32_t, off_t, int, const char *, size_t)
Definition ad_write.c:53
void adf_lock_free(struct ad_fd *adf)
Free all locks in an ad_fd structure.
Definition ad_lock.c:250
static int ad_meta_open(const struct adouble *ad)
Definition adouble.h:408
int ad_init_offsets(struct adouble *ad)
Definition ad_open.c:373
int sys_ftruncate(int fd, off_t length)
Definition ad_write.c:122
int ad_stat(const char *, struct stat *)
Definition ad_open.c:2236
ssize_t ad_read(struct adouble *, uint32_t, off_t, char *, size_t)
Definition ad_read.c:66
int copy_fork(int eid, struct adouble *add, struct adouble *ads, uint8_t *buf, size_t buflen)
Definition ad_write.c:240
static char buf[MAXPATHLEN+1]
Definition afppasswd.c:85
unsigned char sock
Definition etc/papd/main.c:74
Definition adouble.h:159
off_t ade_off
Definition adouble.h:160
ssize_t ade_len
Definition adouble.h:161
Definition adouble.h:176
char * adf_syml
Definition adouble.h:178
int adf_lockcount
Definition adouble.h:181
adf_lock_t * adf_lock
Definition adouble.h:180
int adf_flags
Definition adouble.h:179
int adf_refcount
Definition adouble.h:181
int adf_lockmax
Definition adouble.h:181
int adf_fd
Definition adouble.h:177
Definition adouble.h:164
int count
Definition adouble.h:165
off_t start
Definition adouble.h:166
off_t end
Definition adouble.h:167
Definition adouble.h:170
struct flock lock
Definition adouble.h:171
int user
Definition adouble.h:172
adf_lock_shared_t * refcount
Definition adouble.h:173
Definition adouble.h:190
int(*) ad_header_read(const char *, struct adouble *, const struct stat *)
Definition adouble.h:194
int(*) ad_rebuild_header(struct adouble *)
Definition adouble.h:193
int(*) ad_header_upgrade(struct adouble *, const char *)
Definition adouble.h:195
int(*) ad_mkrf(const char *)
Definition adouble.h:192
Definition adouble.h:198
uint32_t ad_version
Definition adouble.h:200
struct ad_fd * ad_mdp
Definition adouble.h:212
int ad_meta_refcount
Definition adouble.h:221
uint32_t ad_inited
Definition adouble.h:217
int ad_vers
Definition adouble.h:215
size_t valid_data_len
Definition adouble.h:228
struct adouble_fops * ad_ops
Definition adouble.h:226
char ad_data[AD_DATASZ_MAX]
Definition adouble.h:229
int ad_adflags
Definition adouble.h:216
uint32_t ad_magic
Definition adouble.h:199
off_t ad_rlen
Definition adouble.h:223
int ad_reso_refcount
Definition adouble.h:222
struct ad_fd ad_resource_fork
Definition adouble.h:206
char * ad_name
Definition adouble.h:225
struct ad_entry ad_eid[ADEID_MAX]
Definition adouble.h:202
uint16_t ad_open_forks
Definition adouble.h:227
struct ad_fd * ad_rfp
Definition adouble.h:209
char ad_filler[16]
Definition adouble.h:201
int ad_options
Definition adouble.h:218
int ad_refcount
Definition adouble.h:219
int ad_data_refcount
Definition adouble.h:220
struct ad_fd ad_data_fork
Definition adouble.h:204
Definition include/atalk/directory.h:140
Definition include/atalk/volume.h:33