/*
- * $Id: directory.c,v 1.97 2009-04-17 04:24:20 didg Exp $
+ * $Id: directory.c,v 1.98 2009-06-19 13:38:32 franklahm Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
break;
case DIRPBIT_FINFO :
if (isad) {
+ /* Fixes #2802236 */
+ u_int16_t *fflags = (u_int16_t *)(finder_buf + FINDERINFO_FRFLAGOFF);
+ *fflags &= htons(~FINDERINFO_ISHARED);
+ /* #2802236 end */
if ( dir->d_did == DIRDID_ROOT ) {
/*
* Alright, we admit it, this is *really* sick!
/*
- * $Id: directory.h,v 1.24 2009-04-17 04:24:20 didg Exp $
+ * $Id: directory.h,v 1.25 2009-06-19 13:38:33 franklahm Exp $
*
* Copyright (c) 1990,1991 Regents of The University of Michigan.
* All Rights Reserved.
#define DIRPBIT_PDINFO 13 /* ProDOS Info */
#define DIRPBIT_UNIXPR 15
-/* directory attribute bits (see file.h for other bits) */
-#define ATTRBIT_EXPFOLDER (1 << 1) /* shared point */
-#define ATTRBIT_MOUNTED (1 << 3) /* mounted share point by non-admin */
-#define ATTRBIT_INEXPFOLDER (1 << 4) /* folder in a shared area */
-
#define FILDIRBIT_ISDIR (1 << 7) /* is a directory */
#define FILDIRBIT_ISFILE (0) /* is a file */
/*
- * $Id: adouble.h,v 1.35 2009-06-10 08:37:25 franklahm Exp $
+ * $Id: adouble.h,v 1.36 2009-06-19 13:38:33 franklahm Exp $
* Copyright (c) 1990,1991 Regents of The University of Michigan.
* All Rights Reserved.
*
struct adouble_fops;
struct adouble {
- u_int32_t ad_magic;
- u_int32_t ad_version;
- char ad_filler[ 16 ];
- struct ad_entry ad_eid[ ADEID_MAX ];
- struct ad_fd ad_data_fork, ad_resource_fork, ad_metadata_fork;
- struct ad_fd *ad_md; /* either ad_resource or ad_metadata */
-
- int ad_flags;
+ u_int32_t ad_magic;
+ u_int32_t ad_version;
+ char ad_filler[ 16 ];
+ struct ad_entry ad_eid[ ADEID_MAX ];
+ struct ad_fd ad_data_fork, ad_resource_fork, ad_metadata_fork;
+ struct ad_fd *ad_md; /* either ad_resource or ad_metadata */
+
+ int ad_flags; /* This really stores version info too (AD_VERSION*) */
+ int ad_adflags; /* ad_open flags adflags like ADFLAGS_DIR */
unsigned int ad_inited;
int ad_options;
+ int ad_fileordir;
int ad_refcount; /* used in afpd/ofork.c */
off_t ad_rlen; /* ressource fork len with AFP 3.0
the header parameter size is too small.
#define FINDERINFO_FRFLAGOFF 8
/* finderinfo flags */
-#define FINDERINFO_ISONDESK (1)
+#define FINDERINFO_ISONDESK (1) /* "d" */
#define FINDERINFO_COLOR (0x0e)
-#define FINDERINFO_ISHARED (1<<6)
-#define FINDERINFO_HASNOINITS (1<<7)
-#define FINDERINFO_HASBEENINITED (1<<8)
-#define FINDERINFO_HASCUSTOMICON (1<<10)
-#define FINDERINFO_ISSTATIONNERY (1<<11)
-#define FINDERINFO_NAMELOCKED (1<<12)
-#define FINDERINFO_HASBUNDLE (1<<13)
-#define FINDERINFO_INVISIBLE (1<<14)
-#define FINDERINFO_ISALIAS (1<<15)
+#define FINDERINFO_ISHARED (1<<6) /* "m" */
+#define FINDERINFO_HASNOINITS (1<<7) /* "n" */
+#define FINDERINFO_HASBEENINITED (1<<8) /* "i" */
+#define FINDERINFO_HASCUSTOMICON (1<<10) /* "c" */
+#define FINDERINFO_ISSTATIONNERY (1<<11) /* "t" */
+#define FINDERINFO_NAMELOCKED (1<<12) /* "s" */
+#define FINDERINFO_HASBUNDLE (1<<13) /* "b" */
+#define FINDERINFO_INVISIBLE (1<<14) /* "v" */
+#define FINDERINFO_ISALIAS (1<<15) /* "a" */
#define FINDERINFO_FRVIEWOFF 14
#define FINDERINFO_CUSTOMICON 0x4
*/
/* 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_INVISIBLE (1<<0) /* (d) */
+#define ATTRBIT_MULTIUSER (1<<1)
+#define ATTRBIT_SYSTEM (1<<2) /* "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_NOWRITE (1<<5) /* "w" write inhibit(v2)/read-only(v1) bit ("") */
+#define ATTRBIT_BACKUP (1<<6) /* "b" (d) */
+#define ATTRBIT_NORENAME (1<<7) /* "r" (d) */
+#define ATTRBIT_NODELETE (1<<8) /* "d" (d) */
+#define ATTRBIT_NOCOPY (1<<10) /* "c" */
#define ATTRBIT_SETCLR (1<<15) /* set/clear bits (d) */
/* AFP attributes for dirs */
/*
- * $Id: ad_attr.c,v 1.8 2009-06-10 08:37:25 franklahm Exp $
+ * $Id: ad_attr.c,v 1.9 2009-06-19 13:38:34 franklahm Exp $
*/
#ifdef HAVE_CONFIG_H
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.
+ This one is tricky, I actually got it wrong the first time:
+ for directories bit 1<<1 is ATTRBIT_EXPFLDR and is NOT opaque !
*/
-#if 0
- if ( ! (ad->ad_flags & ADFLAGS_DIR) ) {
-#endif
+ if ( ! (ad->ad_adflags & ADFLAGS_DIR)) {
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);
+ /* Proactively (10.4 does indeed try to set ATTRBIT_MULTIUSER (=ATTRBIT_EXPFLDR)
+ for dirs with SetFile -a M <dir> ) disable all flags not defined for dirs. */
+ if (ad->ad_adflags & ADFLAGS_DIR)
+ attr &= ~(ATTRBIT_MULTIUSER | ATTRBIT_NOWRITE | ATTRBIT_NOCOPY);
+
if (ad->ad_version == AD_VERSION1) {
if (ad_getentryoff(ad, ADEID_FILEI)) {
memcpy(ad_entry(ad, ADEID_FILEI) + FILEIOFF_ATTR, &attr,
/* Now set opaque flags in FinderInfo too */
fflags = (u_int16_t *)ad_entry(ad, ADEID_FINDERI) + FINDERINFO_FRFLAGOFF;
- if (hostattr & htons(ATTRBIT_INVISIBLE))
+ if (attr & 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))
+
+ /* See above comment in ad_getattr() */
+ if (attr & htons(ATTRBIT_MULTIUSER)) {
+ if ( ! (ad->ad_adflags & ADFLAGS_DIR) )
*fflags |= htons(FINDERINFO_ISHARED);
- else
+ } else
*fflags &= htons(~FINDERINFO_ISHARED);
-#if 0
- }
-#endif
}
}
#endif
/*
- * $Id: ad_open.c,v 1.41 2009-06-10 08:37:25 franklahm Exp $
+ * $Id: ad_open.c,v 1.42 2009-06-19 13:38:34 franklahm Exp $
*
* Copyright (c) 1999 Adrian Sun (asun@u.washington.edu)
* Copyright (c) 1990,1991 Regents of The University of Michigan.
ad->ad_inited = AD_INITED;
ad->ad_refcount = 1;
ad->ad_open_forks = 0;
+ ad->ad_adflags = adflags;
}
else {
ad->ad_open_forks = ((ad->ad_data_fork.adf_refcount > 0) ? ATTRBIT_DOPEN : 0);