From 6acb3b073a02d68e56654623999de1d21b7059c8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= Date: Wed, 9 Oct 2013 14:05:57 +0200 Subject: [PATCH] Better behaviour for test-access: - updateReplica() do nothing and don't fail - exception from access(..., R_OK) with code DMLITE_NO_SUCH_REPLICA - more verbose exception messages --- src/VfsNs.cpp | 15 ++++++++++----- src/VfsNs.h | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/VfsNs.cpp b/src/VfsNs.cpp index 50106c9..7732a4a 100644 --- a/src/VfsNs.cpp +++ b/src/VfsNs.cpp @@ -102,9 +102,9 @@ bool VfsCatalog::access(const std::string& path, int mode) throw (DmException) if (errno == ENOENT) { // throw exeption up only if there was not requested test for existence (F_OK) if (mode & F_OK) return false; - else vfsThrowErrno("stat() failed on '" + path + "' (stat)"); + else vfsThrow(DMLITE_NO_SUCH_REPLICA, "stat() failed on '" + path + "': " + strerror(errno)); } else - vfsThrowErrno("stat() failed on '" + path + "' (stat)"); + vfsThrowErrno("stat() failed on '" + path + "'"); } if (::access(path.c_str(), mode) == -1) { @@ -119,17 +119,22 @@ bool VfsCatalog::access(const std::string& path, int mode) throw (DmException) } +bool VfsCatalog::accessReplica(const std::string& replica, int mode) throw (DmException) +{ + return access(replica, mode); +} + void VfsCatalog::addReplica(const Replica& replica) throw (DmException) { - throw DmException(EACCES, "Write mode not supported"); + vfsThrow(EACCES, "write mode not supported"); } void VfsCatalog::deleteReplica(const Replica& replica) throw (DmException) { - throw DmException(EACCES, "Write mode not supported"); + vfsThrow(EACCES, "write mode not supported"); } @@ -396,5 +401,5 @@ Replica VfsCatalog::getReplicaByRFN(const std::string& rfn) throw (DmException) void VfsCatalog::updateReplica(const Replica& replica) throw (DmException) { - throw DmException(EACCES, "Write mode not supported"); + // Nothing } diff --git a/src/VfsNs.h b/src/VfsNs.h index 9bc4f87..54ff1ec 100644 --- a/src/VfsNs.h +++ b/src/VfsNs.h @@ -41,6 +41,7 @@ namespace dmlite { ExtendedStat extendedStat(const std::string&, bool) throw (DmException); bool access(const std::string& path, int mode) throw (DmException); + bool accessReplica(const std::string& replica, int mode) throw (DmException); SymLink readLink(ino_t) throw (DmException); -- 1.8.2.3