Better behaviour for test-access:
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Wed, 9 Oct 2013 12:05:57 +0000 (14:05 +0200)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Wed, 9 Oct 2013 12:05:57 +0000 (14:05 +0200)
- 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
src/VfsNs.h

index 50106c9..7732a4a 100644 (file)
@@ -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
 }
index 9bc4f87..54ff1ec 100644 (file)
@@ -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);