]> arthur.barton.de Git - netatalk.git/blobdiff - include/atalk/adouble.h
Merge remote branch 'sf/branch-allea' into branch-allea
[netatalk.git] / include / atalk / adouble.h
index a417db37c87f0c712f6dc973142b04530032de73..5b276a5a27a2e8255266eb5bbf810e3c0b19c2b8 100644 (file)
@@ -53,7 +53,7 @@
 #define AD_VERSION_EA   0x00020002
 
 /* default */
-#define AD_VERSION      AD_VERSION2
+#define AD_VERSION      AD_VERSION_EA
 
 /*
  * AppleDouble entry IDs.
 #define ADEDLEN_PRIVID          4
 
 #define ADEID_NUM_V2            13
-#define ADEID_NUM_EA            6
+#define ADEID_NUM_EA            8
 #define ADEID_NUM_OSX           2
 
 #define AD_DATASZ2 (AD_HEADER_LEN + ADEDLEN_NAME + ADEDLEN_COMMENT + ADEDLEN_FILEI + \
 #error bad size for AD_DATASZ2
 #endif
 
-#define AD_DATASZ_EA (AD_HEADER_LEN + (ADEID_NUM_EA * AD_ENTRY_LEN) + ADEDLEN_FINDERI + \
-                      ADEDLEN_COMMENT + ADEDLEN_FILEDATESI + ADEDLEN_AFPFILEI + ADEDLEN_PRIVID)
+#define AD_DATASZ_EA (AD_HEADER_LEN + (ADEID_NUM_EA * AD_ENTRY_LEN) + \
+                      ADEDLEN_FINDERI + ADEDLEN_COMMENT + ADEDLEN_FILEDATESI + ADEDLEN_AFPFILEI + \
+                      ADEDLEN_PRIVDEV + ADEDLEN_PRIVINO + ADEDLEN_PRIVSYN + ADEDLEN_PRIVID)
 
-#if AD_DATASZ_EA != 354
+#if AD_DATASZ_EA != 402
 #error bad size for AD_DATASZ_EA
 #endif
 
@@ -185,7 +186,7 @@ struct adouble_fops {
     const char *(*ad_path)(const char *, int);
     int  (*ad_mkrf)(const char *);
     int  (*ad_rebuild_header)(struct adouble *);
-    int  (*ad_header_read)(const char *, struct adouble *, struct stat *);
+    int  (*ad_header_read)(const char *, struct adouble *, const struct stat *);
     int  (*ad_header_upgrade)(struct adouble *, const char *);
 };
 
@@ -216,8 +217,7 @@ struct adouble {
     int                 ad_refcount;       /* multiple forks may open one adouble     */
     off_t               ad_rlen;           /* ressource fork len with AFP 3.0         *
                                             * the header parameter size is too small. */
-    char                *ad_m_name;        /* mac name for open fork                  */
-    int                 ad_m_namelen;
+    char                *ad_name;          /* name in server encoding (usually UTF8)  */
     struct adouble_fops *ad_ops;
     uint16_t            ad_open_forks;     /* open forks (by others)                  */
     char                ad_data[AD_DATASZ_MAX];
@@ -243,10 +243,8 @@ struct adouble {
 #define ADFLAGS_TRUNC     (1<<12) /* truncate, open called with O_TRUNC */
 
 #define ADVOL_NODEV      (1 << 0)
-#define ADVOL_CACHE      (1 << 1)
 #define ADVOL_UNIXPRIV   (1 << 2) /* adouble unix priv */
 #define ADVOL_INVDOTS    (1 << 3) /* dot files (.DS_Store) are invisible) */
-#define ADVOL_NOADOUBLE  (1 << 4)
 
 /* lock flags */
 #define ADLOCK_CLR      (0)
@@ -277,7 +275,6 @@ struct adouble {
 #define AD_FILELOCK_RSRC_DENY_WR   (AD_FILELOCK_BASE + 6)
 #define AD_FILELOCK_RSRC_DENY_RD   (AD_FILELOCK_BASE + 7)
 
-
 #define AD_FILELOCK_OPEN_NONE      (AD_FILELOCK_BASE + 8)
 #define AD_FILELOCK_RSRC_OPEN_NONE (AD_FILELOCK_BASE + 9)
 
@@ -351,15 +348,15 @@ struct adouble {
 #define ad_reso_fileno(ad)  ((ad)->ad_rfp->adf_fd)
 #define ad_meta_fileno(ad)  ((ad)->ad_mdp->adf_fd)
 
-#define AD_DATA_OPEN(ad) ((ad)->ad_data_fork.adf_fd != -1)
-#define AD_META_OPEN(ad) ((ad)->ad_mdp->adf_fd != -1)
-#define AD_RSRC_OPEN(ad) ((ad)->ad_rfp->adf_fd != -1)
+/* -1 means not open, -2 is a symlink */
+#define AD_DATA_OPEN(ad) ((ad)->ad_data_fork.adf_fd >= 0)
+#define AD_META_OPEN(ad) ((ad)->ad_mdp->adf_fd >= 0)
+#define AD_RSRC_OPEN(ad) ((ad)->ad_rfp->adf_fd >= 0)
 
 #define ad_getversion(ad)   ((ad)->ad_version)
 
 #define ad_getentrylen(ad,eid)     ((ad)->ad_eid[(eid)].ade_len)
 #define ad_setentrylen(ad,eid,len) ((ad)->ad_eid[(eid)].ade_len = (len))
-#define ad_getentryoff(ad,eid)     ((ad)->ad_eid[(eid)].ade_off)
 #define ad_setentryoff(ad,eid,off) ((ad)->ad_eid[(eid)].ade_off = (off))
 #define ad_entry(ad,eid)           ((caddr_t)(ad)->ad_data + (ad)->ad_eid[(eid)].ade_off)
 
@@ -371,7 +368,8 @@ struct adouble {
 #define ad_unref(ad) --((ad)->ad_refcount)
 
 /* ad_flush.c */
-extern int ad_rebuild_adouble_header (struct adouble *);
+extern int ad_rebuild_adouble_header_v2(struct adouble *);
+extern int ad_rebuild_adouble_header_ea(struct adouble *);
 extern int ad_copy_header (struct adouble *, struct adouble *);
 extern int ad_flush (struct adouble *);
 extern int ad_close (struct adouble *, int);
@@ -380,11 +378,12 @@ extern int fsetrsrcea(struct adouble *ad, int fd, const char *eaname, const void
 /* ad_lock.c */
 extern int ad_testlock      (struct adouble *adp, int eid, off_t off);
 extern uint16_t ad_openforks(struct adouble *adp, uint16_t);
-extern int ad_lock(struct adouble *, uint32_t eid, int type, off_t off, off_t len, int user);
-extern void ad_unlock(struct adouble *, int user);
-extern int ad_tmplock(struct adouble *, uint32_t eid, int type, off_t off, off_t len, int user);
+extern int ad_lock(struct adouble *, uint32_t eid, int type, off_t off, off_t len, int fork);
+extern void ad_unlock(struct adouble *, int fork, int unlckbrl);
+extern int ad_tmplock(struct adouble *, uint32_t eid, int type, off_t off, off_t len, int fork);
 
 /* ad_open.c */
+extern off_t ad_getentryoff(const struct adouble *ad, int eid);
 extern const char *adflags2logstr(int adflags);
 extern int ad_setfuid     (const uid_t );
 extern uid_t ad_getfuid   (void );
@@ -403,32 +402,9 @@ extern int ad_refresh     (const char *path, struct adouble *);
 extern int ad_stat        (const char *, struct stat *);
 extern int ad_metadata    (const char *, int, struct adouble *);
 extern int ad_metadataat  (int, const char *, int, struct adouble *);
-
-/* build a resource fork mode from the data fork mode:
- * remove X mode and extend header to RW if R or W (W if R for locking),
- */
-static inline mode_t ad_hf_mode (mode_t mode)
-{
-    mode &= ~(S_IXUSR | S_IXGRP | S_IXOTH);
-    /* fnctl lock need write access */
-    if ((mode & S_IRUSR))
-        mode |= S_IWUSR;
-    if ((mode & S_IRGRP))
-        mode |= S_IWGRP;
-    if ((mode & S_IROTH))
-        mode |= S_IWOTH;
-
-    /* if write mode set add read mode */
-    if ((mode & S_IWUSR))
-        mode |= S_IRUSR;
-    if ((mode & S_IWGRP))
-        mode |= S_IRGRP;
-    if ((mode & S_IWOTH))
-        mode |= S_IROTH;
-
-    return mode;
-}
-
+extern mode_t ad_hf_mode(mode_t mode);
+extern int ad_convert(const char *path, const struct stat *sp, const struct vol *vol);
+extern int ad_valid_header_osx(const char *path);
 /* ad_read.c/ad_write.c */
 extern int     sys_ftruncate(int fd, off_t length);
 extern ssize_t ad_read(struct adouble *, uint32_t, off_t, char *, size_t);
@@ -438,6 +414,7 @@ extern ssize_t adf_pread(struct ad_fd *, void *, size_t, off_t);
 extern ssize_t adf_pwrite(struct ad_fd *, const void *, size_t, off_t);
 extern int     ad_dtruncate(struct adouble *, off_t);
 extern int     ad_rtruncate(struct adouble *, off_t);
+extern int     copy_fork(int eid, struct adouble *add, struct adouble *ads);
 
 /* ad_size.c */
 extern off_t ad_size (const struct adouble *, uint32_t );