/* try to open both forks at once */
adflags = ADFLAGS_DF;
- if (ad_openat(&ad, dirfd, file, adflags | ADFLAGS_HF | ADFLAGS_NOHF | ADFLAGS_RDONLY) < 0 ) {
+ if (ad_openat(&ad, dirfd, file, adflags | ADFLAGS_RF | ADFLAGS_NORF | ADFLAGS_RDONLY) < 0 ) {
switch (errno) {
case ENOENT:
err = AFPERR_NOOBJ;
adp = &ad;
}
- if ( adp && ad_reso_fileno( adp ) != -1 ) { /* there's a resource fork */
- adflags |= ADFLAGS_HF;
+ if ( adp && AD_RSRC_OPEN(adp) != -1 ) { /* there's a resource fork */
+ adflags |= ADFLAGS_RF;
/* FIXME we have a pb here because we want to know if a file is open
* there's a 'priority inversion' if you can't open the ressource fork RW
* you can delete it if it's open because you can't get a write lock.
#define ADFLAGS_RF (1<<1)
#define ADFLAGS_HF (1<<2)
#define ADFLAGS_DIR (1<<3)
-#define ADFLAGS_NOHF (1<<4) /* not an error if no ressource fork */
+#define ADFLAGS_NOHF (1<<4) /* not an error if no metadata fork */
+#define ADFLAGS_NORF (1<<4) /* not an error if no ressource fork */
#define ADFLAGS_CHECK_OF (1<<6) /* check for open forks from us and other afpd's */
#define ADFLAGS_SETSHRMD (1<<7) /* setting share mode must be done with excl fcnt lock,
which implies that the file must be openend rw.
ad_reso_fileno(ad) = -1;
ad->ad_rfp->adf_refcount = 0;
}
- int err = errno;
- (void)ad_close(ad, closeflags);
- errno = err;
+ if (adflags & ADFLAGS_NORF) {
+ ret = 0;
+ } else {
+ int err = errno;
+ (void)ad_close(ad, closeflags);
+ errno = err;
+ }
ad->ad_rlen = 0;
}
* ADFLAGS_DF: open data fork
* ADFLAGS_RF: open ressource fork
* ADFLAGS_HF: open header (metadata) file
- * ADFLAGS_NOHF: it's not an error if header file couldn't be created
+ * ADFLAGS_NOHF: it's not an error if header file couldn't be opened
+ * ADFLAGS_NORF: it's not an error if reso fork couldn't be opened
* ADFLAGS_DIR: if path is a directory you MUST or ADFLAGS_DIR to adflags
*
* Access mode for the forks:
/* Checking for open forks requires sharemode lock support (ie RDWR instead of RDONLY) */
adflags |= ADFLAGS_SETSHRMD;
+ if ((ad->ad_vers == AD_VERSION2) && (adflags & ADFLAGS_RF)) {
+ adflags |= ADFLAGS_HF;
+ if (adflags & ADFLAGS_NORF)
+ adflags |= ADFLAGS_NOHF;
+ }
+
if ((ad->ad_vers == AD_VERSION_EA) && (adflags & ADFLAGS_SETSHRMD))
/* adouble:ea sets sharemode locks on the datafork */
adflags |= ADFLAGS_DF;