From 5d4fe5d328637414ce3540eb4cf55707fb112636 Mon Sep 17 00:00:00 2001 From: Frank Lahm Date: Sat, 21 Jan 2012 19:03:02 +0100 Subject: [PATCH] Fixes --- etc/afpd/file.c | 6 +++--- include/atalk/adouble.h | 3 ++- libatalk/adouble/ad_open.c | 19 +++++++++++++++---- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/etc/afpd/file.c b/etc/afpd/file.c index 69c3388b..51de7562 100644 --- a/etc/afpd/file.c +++ b/etc/afpd/file.c @@ -1619,7 +1619,7 @@ int deletefile(const struct vol *vol, int dirfd, char *file, int checkAttrib) /* 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; @@ -1638,8 +1638,8 @@ int deletefile(const struct vol *vol, int dirfd, char *file, int checkAttrib) 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. diff --git a/include/atalk/adouble.h b/include/atalk/adouble.h index 118dd613..50857df0 100644 --- a/include/atalk/adouble.h +++ b/include/atalk/adouble.h @@ -227,7 +227,8 @@ struct adouble { #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. diff --git a/libatalk/adouble/ad_open.c b/libatalk/adouble/ad_open.c index be149077..93372a86 100644 --- a/libatalk/adouble/ad_open.c +++ b/libatalk/adouble/ad_open.c @@ -1152,9 +1152,13 @@ EC_CLEANUP: 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; } @@ -1408,7 +1412,8 @@ void ad_init(struct adouble *ad, const struct vol * restrict vol) * 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: @@ -1444,6 +1449,12 @@ int ad_open(struct adouble *ad, const char *path, int adflags, ...) /* 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; -- 2.39.2