[Filesystem] Fix for TCT test.
authorPawel Andruszkiewicz <p.andruszkie@samsung.com>
Wed, 20 May 2015 11:18:26 +0000 (13:18 +0200)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Wed, 20 May 2015 11:18:26 +0000 (13:18 +0200)
Resolve should report InvalidValuesError if application does not have access to a file/directory.

[Verification] FileSystemManager_resolve_wgt_package_of_another_app passes.

Change-Id: I9ccc2dd0dea6775f769e8f9f2ad50a6427a0622a
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
src/filesystem/filesystem_instance.cc
src/filesystem/filesystem_manager.cc
src/filesystem/filesystem_stat.cc
src/filesystem/filesystem_stat.h
src/filesystem/filesystem_utils.h

index 3bc2de06becc663a5a43b80daf43c99608c424e0..3a351735a3c76e739b58f79e2e12c597a698bf30 100644 (file)
@@ -597,6 +597,9 @@ void FilesystemInstance::PrepareError(const FilesystemError& error, picojson::ob
     case FilesystemError::Other:
       ReportError(UnknownException("PLATFORM ERROR"), out);
       break;
+    case FilesystemError::InvalidValue:
+      ReportError(InvalidValuesException("PLATFORM ERROR"), out);
+      break;
     default:
       ReportError(UnknownException("PLATFORM ERROR"), out);
       break;
index 8fbe22d7a03cac151187819e31662c4115f5ce14..d3a3a16f935165ff5b5be050990dc1c3011c67f2 100644 (file)
@@ -228,7 +228,7 @@ void FilesystemManager::StatPath(
 
   FilesystemStat statData = FilesystemStat::getStat(path);
   if (!statData.valid) {
-    error_cb(FilesystemError::NotFound);
+    error_cb(statData.error);
     return;
   }
 
index 90e7333c6f695411da034a0737b0bb30b839cb5e..ce919bf573d5c91035f69c38243538764232af95 100644 (file)
@@ -14,7 +14,7 @@
 namespace extension {
 namespace filesystem {
 
-FilesystemStat::FilesystemStat() : valid(false) {}
+FilesystemStat::FilesystemStat() : error(FilesystemError::None), valid(false) {}
 
 picojson::value FilesystemStat::toJSON() const {
   picojson::value retval = picojson::value(picojson::object());
@@ -34,14 +34,20 @@ picojson::value FilesystemStat::toJSON() const {
 
 FilesystemStat FilesystemStat::getStat(const std::string& path) {
   struct stat aStatObj;
+  FilesystemStat _result;
+
   LoggerD("enter");
+
   if (0 != stat(path.c_str(), &aStatObj)) {
     LoggerE("Failed to stat: (%d) %s", errno, strerror(errno));
-    return FilesystemStat();
+    if (ENOENT == errno) {
+      _result.error = FilesystemError::NotFound;
+    } else {
+      _result.error = FilesystemError::InvalidValue;
+    }
+    return _result;
   }
 
-  FilesystemStat _result;
-
   _result.path = path;
   _result.readOnly = true;
   if (getuid() == aStatObj.st_uid && (aStatObj.st_mode & S_IWUSR) == S_IWUSR) {
index 7358045f9a5c8ce435d108443f5dc3bbe03feec1..0120e0490674dadb545edd6c7275aa4c40349f17 100644 (file)
@@ -6,7 +6,10 @@
 #define FILESYSTEM_FILESYSTEM_STAT_H
 
 #include <string>
-#include <common/picojson.h>
+
+#include "common/picojson.h"
+
+#include "filesystem/filesystem_utils.h"
 
 namespace extension {
 namespace filesystem {
@@ -15,6 +18,7 @@ class FilesystemStat {
   FilesystemStat();
 
  public:
+  FilesystemError error;
   bool valid;
 
   std::string path;
index 0375087126f9d8a5f12f83e0896be4cdb98d6f0a..42d834f4ad3e03ff37c1f1c7d7922c72122b25a4 100644 (file)
@@ -19,6 +19,7 @@ enum class FilesystemError {
   DirectoryExists,
   PermissionDenied,
   IOError,
+  InvalidValue,
   Other
 };
 }  // namespace filesystem