/*
- * $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.
#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 ];
/*
- * $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.
*
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;
/* 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)
#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 */
/*
- * $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)) {
#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
/* ----------------- */
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);
#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
/*
- * $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. */