X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=blobdiff_plain;f=libatalk%2Fadouble%2Fad_open.c;h=cd45fef2e20ddf9c526b08a07f7c2a6f9c8a5717;hp=3b641d66ef0eb9355a9365131431649a25a9836e;hb=c74dd3730ea1927d5083242fce4dc042f9a8646c;hpb=40ec781c1ddb2686c589e4184bc08fa266f28b40 diff --git a/libatalk/adouble/ad_open.c b/libatalk/adouble/ad_open.c index 3b641d66..cd45fef2 100644 --- a/libatalk/adouble/ad_open.c +++ b/libatalk/adouble/ad_open.c @@ -1247,12 +1247,32 @@ static int ad_open_rf_ea(const char *path, int adflags, int mode, struct adouble EC_FAIL; if ((ad_reso_fileno(ad) = sys_getxattrfd(ad_meta_fileno(ad), AD_EA_RESO, oflags)) == -1) { if (!(adflags & ADFLAGS_CREATE)) { - errno = ENOENT; - EC_FAIL; + switch (errno) { + case EACCES: + case EPERM: + case EROFS: + if (!(adflags & ADFLAGS_RDONLY)) { + LOG(log_error, logtype_ad, "ad_open_rf_ea(\"%s\"): \"%s\"", fullpathname(path), strerror(errno)); + EC_FAIL; + } + oflags &= ~O_RDWR; + oflags |= O_RDONLY; + if ((ad_reso_fileno(ad) = sys_getxattrfd(ad_meta_fileno(ad), AD_EA_RESO, oflags)) == -1) { + LOG(log_error, logtype_ad, "ad_open_rf_ea(\"%s\"): \"%s\"", fullpathname(path), strerror(errno)); + EC_FAIL; + } + break; + case ENOENT: + EC_EXIT_STATUS(0); + default: + LOG(log_error, logtype_ad, "ad_open_rf_ea(\"%s\"): \"%s\"", fullpathname(path), strerror(errno)); + EC_FAIL; + } + } else { + oflags |= O_CREAT; + EC_NEG1_LOG( ad_reso_fileno(ad) = sys_getxattrfd(ad_meta_fileno(ad), + AD_EA_RESO, oflags, 0666) ); } - oflags |= O_CREAT; - EC_NEG1_LOG( ad_reso_fileno(ad) = sys_getxattrfd(ad_meta_fileno(ad), - AD_EA_RESO, oflags, 0666) ); } #else EC_NULL_LOG( rfpath = ad->ad_ops->ad_path(path, adflags) );