Add some error reports in logs
authorJan Cybulski <j.cybulski@samsung.com>
Mon, 27 Jul 2015 10:18:30 +0000 (12:18 +0200)
committerStanislaw Wadas <s.wadas@samsung.com>
Wed, 2 Dec 2015 12:50:46 +0000 (13:50 +0100)
This might be useful in debugging.

Change-Id: Id516a10e539717e769923084cf06d730b577998a
Signed-off-by: Jan Cybulski <j.cybulski@samsung.com>
USD/src/client/usb-access-client.cpp
USD/src/common/usb-access-map.cpp

index 3d7f3bb60a8ee25cc963b550f10bc2b8d7abf9fd..d9083463ef1bfbba515af6c7f9aa17f65d6f4494 100644 (file)
@@ -110,7 +110,7 @@ int usd_open_usb_device(const char *devpath, int *fd)
 
 _USD_API_
 int usd_setup_usb_device_access(const char *topology, const char *smack, bool allow) {
-    LogDebug(" topology: " << topology << "smack: " << smack << "allow" << allow);
+
     using namespace USD;
     return try_catch([&] {
         MessageBuffer send;
@@ -123,6 +123,7 @@ int usd_setup_usb_device_access(const char *topology, const char *smack, bool al
             LogError("Error input param.");
             return USD_API_ERROR_INPUT_PARAM;
         }
+        LogDebug(" topology: " << topology << "smack: " << smack << "allow" << allow);
 
         Serialization::Serialize(send,
                                  static_cast<int>(USBAccessCall::USB_CALL_TYPE_SETUP_POLICY));
index ae951629dc83e2e0e41ef84b8e3cc4329cee8ff2..9d691e67cf928fee2cb4a36aec4a401f991185eb 100644 (file)
@@ -72,8 +72,10 @@ void USBDevicePath::initFromSysFS(const std::string &path)
         if (ret != 2)
             throw USD_API_ERROR_FILE_READ_FAILED;
 
-        if (maj != USB_DEVICE_MAJOR)
+        if (maj != USB_DEVICE_MAJOR) {
+            LogError("This is not an USB device");
             throw USD_API_ERROR_ACCESS_DENIED;
+        }
 
         m_dev = makedev(maj, min);
     }
@@ -110,8 +112,10 @@ void USBDevicePath::initFromDev(const std::string &path)
         throw USD_API_ERROR_FILE_READ_FAILED;
 
     if (!S_ISCHR(dev_st.st_mode) ||
-        major(dev_st.st_rdev) != USB_DEVICE_MAJOR)
+        major(dev_st.st_rdev) != USB_DEVICE_MAJOR) {
+        LogError("This is not an usb device");
         throw USD_API_ERROR_ACCESS_DENIED;
+    }
 
     m_dev = dev_st.st_rdev;
     ret = snprintf(buf, sizeof(buf),
@@ -193,13 +197,17 @@ void USBDeviceId::initDevId(const std::string &sys_path)
     path += sys_path + "/descriptors";
 
     fd = open(path.c_str(), O_RDONLY);
-    if (fd < 0)
+    if (fd < 0) {
+        LogError("Open failed for: " << path);
         throw USD_API_ERROR_FILE_OPEN_FAILED;
+    }
 
     ret = read(fd, &desc, sizeof(desc));
     close(fd);
-    if ((unsigned)ret < sizeof(desc))
+    if ((unsigned)ret < sizeof(desc)) {
+        LogError("Read failed for: " << path);
         throw USD_API_ERROR_FILE_READ_FAILED;
+    }
 
     m_bcdUSB = le16toh(desc.bcdUSB);
     m_bDeviceClass = desc.bDeviceClass;