]> arthur.barton.de Git - netatalk.git/commitdiff
The "shared" and "invisible" attributes are opaque and stored and retrieved from...
authorfranklahm <franklahm>
Wed, 10 Jun 2009 08:37:25 +0000 (08:37 +0000)
committerfranklahm <franklahm>
Wed, 10 Jun 2009 08:37:25 +0000 (08:37 +0000)
<https://sourceforge.net/tracker/?func=detail&aid=2802236&group_id=8642&atid=108642>
Also changed: move all ATTRBIT_XXX defines to adouble.h.

etc/afpd/file.h
include/atalk/adouble.h
libatalk/adouble/ad_attr.c
libatalk/adouble/ad_open.c

index 06fe64bea53ea3bd02f779199f04bacc361df7e6..f0aa5084e7aaee0d9f09cf888ca66c5b7ef1a757 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: file.h,v 1.20 2006-09-29 09:39:16 didg Exp $
+ * $Id: file.h,v 1.21 2009-06-10 08:37:25 franklahm Exp $
  *
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
  * All Rights Reserved.
@@ -54,25 +54,6 @@ extern const u_char  ufinderi[];
 #define FILPBIT_EXTRFLEN 14
 #define FILPBIT_UNIXPR   15
 
-/* attribute bits. (d) = directory attribute bit as well. */
-#define ATTRBIT_INVISIBLE (1<<0)  /* invisible (d) */
-#define ATTRBIT_MULTIUSER (1<<1)  /* multiuser */
-#define ATTRBIT_SYSTEM    (1<<2)  /* system (d) */
-
-#if 0
-/* define in adouble.h */
-#define ATTRBIT_DOPEN     (1<<3)  /* data fork already open */
-#define ATTRBIT_ROPEN     (1<<4)  /* resource fork already open */
-#endif
-
-#define ATTRBIT_SHARED    (1<<4)  /* shared area (d) */
-#define ATTRBIT_NOWRITE   (1<<5)  /* write inhibit(v2)/read-only(v1) bit */
-#define ATTRBIT_BACKUP    (1<<6)  /* backup needed (d) */
-#define ATTRBIT_NORENAME  (1<<7)  /* rename inhibit (d) */
-#define ATTRBIT_NODELETE  (1<<8)  /* delete inhibit (d) */
-#define ATTRBIT_NOCOPY    (1<<10) /* copy protect */
-#define ATTRBIT_SETCLR   (1<<15) /* set/clear bits (d) */
-
 struct extmap {
     char               *em_ext;
     char               em_creator[ 4 ];
index 9ff6498b94ce0208e79427ebccc7608c97a04a90..c1f293e7ce047cab859aca57120f9a82b8690f85 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: adouble.h,v 1.34 2009-05-22 20:48:44 franklahm Exp $
+ * $Id: adouble.h,v 1.35 2009-06-10 08:37:25 franklahm Exp $
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
  * All Rights Reserved.
  *
@@ -249,10 +249,6 @@ struct ad_fd {
     int          adf_refcount, adf_lockcount, adf_lockmax;
 };
 
-/* fork attribute */
-#define ATTRBIT_DOPEN     (1<<3)  /* data fork already open */
-#define ATTRBIT_ROPEN     (1<<4)  /* resource fork already open */
-
 /* some header protection */
 #define AD_INITED  0xad494e54  /* ad"INT" */
 struct adouble_fops;
@@ -373,8 +369,8 @@ struct adouble_fops {
 /* various finder offset and info bits */
 #define FINDERINFO_FRTYPEOFF   0
 #define FINDERINFO_FRCREATOFF  4
-
 #define FINDERINFO_FRFLAGOFF   8
+
 /* finderinfo flags */
 #define FINDERINFO_ISONDESK      (1)
 #define FINDERINFO_COLOR         (0x0e)
@@ -392,6 +388,29 @@ struct adouble_fops {
 #define FINDERINFO_CUSTOMICON 0x4
 #define FINDERINFO_CLOSEDVIEW 0x100   
 
+/* 
+   The "shared" and "invisible" attributes are opaque and stored and
+   retrieved from the FinderFlags. This fixes Bug #2802236:
+   <https://sourceforge.net/tracker/?func=detail&aid=2802236&group_id=8642&atid=108642>
+ */
+
+/* AFP attributes for files and dirs. (d) = only these are valid for directories */
+#define ATTRBIT_INVISIBLE (1<<0)  /* invisible ("v") (d) */
+#define ATTRBIT_MULTIUSER (1<<1)  /* multiuser ("m") */
+#define ATTRBIT_SYSTEM    (1<<2)  /* system ("y") (d) */
+#define ATTRBIT_DOPEN     (1<<3)  /* data fork already open */
+#define ATTRBIT_ROPEN     (1<<4)  /* resource fork already open */
+#define ATTRBIT_NOWRITE   (1<<5)  /* write inhibit(v2)/read-only(v1) bit ("") */
+#define ATTRBIT_BACKUP    (1<<6)  /* backup needed ("") (d) */
+#define ATTRBIT_NORENAME  (1<<7)  /* rename inhibit ("") (d) */
+#define ATTRBIT_NODELETE  (1<<8)  /* delete inhibit ("") (d) */
+#define ATTRBIT_NOCOPY    (1<<10) /* copy protect ("") */
+#define ATTRBIT_SETCLR    (1<<15) /* set/clear bits (d) */
+
+/* AFP attributes for dirs */
+#define ATTRBIT_EXPFLDR   (1<<1)  /* Folder is a sharepoint ("p") */
+#define ATTRBIT_MOUNTED   (1<<3)  /* Directory is mounted by a user ("") */
+#define ATTRBIT_SHARED    (1<<4)  /* shared area, called IsExpFolder in spec ("") */
  
 /* private AFPFileInfo bits */
 #define AD_AFPFILEI_OWNER       (1 << 0) /* any owner */
index 791682e256581f37060fa469121df3612ab91734..7a4ff2e37b8cd585d065bd6e7bbaddf5fa2ce573 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ad_attr.c,v 1.7 2009-05-22 20:48:44 franklahm Exp $
+ * $Id: ad_attr.c,v 1.8 2009-06-10 08:37:25 franklahm Exp $
  */
 
 #ifdef HAVE_CONFIG_H
 #define FILEIOFF_ATTR 14
 #define AFPFILEIOFF_ATTR 2
 
+/* 
+   Note:
+   the "shared" and "invisible" attributes are opaque and stored and
+   retrieved from the FinderFlags. This fixes Bug #2802236:
+   <https://sourceforge.net/tracker/?func=detail&aid=2802236&group_id=8642&atid=108642>
+ */
 int ad_getattr(const struct adouble *ad, u_int16_t *attr)
 {
     *attr = 0;
+    u_int16_t fflags;
 
     if (ad->ad_version == AD_VERSION1) {
         if (ad_getentryoff(ad, ADEID_FILEI)) {
@@ -25,8 +32,30 @@ int ad_getattr(const struct adouble *ad, u_int16_t *attr)
 #if AD_VERSION == AD_VERSION2
     else if (ad->ad_version == AD_VERSION2) {
         if (ad_getentryoff(ad, ADEID_AFPFILEI)) {
-            memcpy(attr, ad_entry(ad, ADEID_AFPFILEI) + AFPFILEIOFF_ATTR,
-                   sizeof(u_int16_t));
+            memcpy(attr, ad_entry(ad, ADEID_AFPFILEI) + AFPFILEIOFF_ATTR, 2);
+
+            /* Now get opaque flags from FinderInfo */
+            memcpy(&fflags, ad_entry(ad, ADEID_FINDERI) + FINDERINFO_FRFLAGOFF, 2);
+            if (fflags & htons(FINDERINFO_INVISIBLE))
+                *attr |= htons(ATTRBIT_INVISIBLE);
+            else
+                *attr &= htons(~ATTRBIT_INVISIBLE);
+ /*
+   Although technically correct to check if its a directory because FINDERINFO_ISHARED and
+   ATTRBIT_MULTIUSER are only valid then, at least 10.4 doesn't mind and sets FINDERINFO_ISHARED
+   for directories if told so with e.g. SetFile -a M <directory>. The check would cause an
+   out of sync, so I disabled it.
+ */
+#if 0
+            if ( ! (ad->ad_flags & ADFLAGS_DIR) ) {
+#endif
+                if (fflags & htons(FINDERINFO_ISHARED))
+                    *attr |= htons(ATTRBIT_MULTIUSER);
+                else
+                    *attr &= htons(~ATTRBIT_MULTIUSER);
+#if 0
+            }
+#endif
         }
     }
 #endif
@@ -41,6 +70,9 @@ int ad_getattr(const struct adouble *ad, u_int16_t *attr)
 /* ----------------- */
 int ad_setattr(const struct adouble *ad, const u_int16_t attribute)
 {
+    u_int16_t *fflags;
+    u_int16_t hostattr;
+
     /* we don't save open forks indicator */
     u_int16_t attr = attribute & ~htons(ATTRBIT_DOPEN | ATTRBIT_ROPEN);
 
@@ -53,8 +85,27 @@ int ad_setattr(const struct adouble *ad, const u_int16_t attribute)
 #if AD_VERSION == AD_VERSION2
     else if (ad->ad_version == AD_VERSION2) {
         if (ad_getentryoff(ad, ADEID_AFPFILEI)) {
-            memcpy(ad_entry(ad, ADEID_AFPFILEI) + AFPFILEIOFF_ATTR, &attr,
-                   sizeof(attr));
+            memcpy(ad_entry(ad, ADEID_AFPFILEI) + AFPFILEIOFF_ATTR, &attr, sizeof(attr));
+            
+            /* Now set opaque flags in FinderInfo too */
+            fflags = (u_int16_t *)ad_entry(ad, ADEID_FINDERI) + FINDERINFO_FRFLAGOFF;
+            if (hostattr & htons(ATTRBIT_INVISIBLE))
+                *fflags |= htons(FINDERINFO_INVISIBLE);
+            else
+                *fflags &= htons(~FINDERINFO_INVISIBLE);
+/*
+  See above comment at ad_getattr()
+*/
+#if 0
+            if ( ! (ad->ad_flags & ADFLAGS_DIR) ) {
+#endif
+                if (hostattr & htons(ATTRBIT_MULTIUSER))
+                    *fflags |= htons(FINDERINFO_ISHARED);
+                else
+                    *fflags &= htons(~FINDERINFO_ISHARED);
+#if 0
+            }
+#endif
         }
     }
 #endif
index a7155d59bebbafc782f7e8927072a3bba39b8483..043cd1f1629a8fa514128db766fb25db1b6d781f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ad_open.c,v 1.40 2009-04-25 06:44:48 franklahm Exp $
+ * $Id: ad_open.c,v 1.41 2009-06-10 08:37:25 franklahm Exp $
  *
  * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu)
  * Copyright (c) 1990,1991 Regents of The University of Michigan.
 /* we keep local copies of a bunch of stuff so that we can initialize things 
  * correctly. */
 
-/* invisible bit for dot files */
-#define ATTRBIT_INVISIBLE     (1 << 0)
-
 /* this is to prevent changing timezones from causing problems with
    localtime volumes. the screw-up is 30 years. we use a delta of 5
    years.  */