From c74dd3730ea1927d5083242fce4dc042f9a8646c Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Sat, 9 Mar 2013 13:50:37 +0100 Subject: [PATCH] Solaris fixes for bugs #501 and #502 --- libatalk/adouble/ad_open.c | 30 +++++++++++++++++++++++++----- libatalk/vfs/extattr.c | 1 + 2 files changed, 26 insertions(+), 5 deletions(-) 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) ); diff --git a/libatalk/vfs/extattr.c b/libatalk/vfs/extattr.c index 5206aa6d..73724d53 100644 --- a/libatalk/vfs/extattr.c +++ b/libatalk/vfs/extattr.c @@ -910,6 +910,7 @@ static int solaris_openat(int fildes, const char *path, int oflag, mode_t mode) switch (errno) { case ENOENT: case EEXIST: + case EACCES: break; default: LOG(log_debug, logtype_default, "openat(\"%s\"): %s", -- 2.39.2