Fix device's minor and major reading from stat
authorJan Cybulski <j.cybulski@samsung.com>
Thu, 9 Jul 2015 14:33:03 +0000 (16:33 +0200)
committerJan Cybulski <j.cybulski@samsung.com>
Thu, 9 Jul 2015 14:36:11 +0000 (16:36 +0200)
USB device files are special files.
st_rdev field is used for obtaining special files' minor and major,
not st_dev as it was done in the code so far.

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

index 17e112fa2d82d3e2d40559602e960287bed08e35..586141385986e3120ea88e49f146a497b671d2a9 100644 (file)
@@ -110,12 +110,12 @@ 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_dev) != USB_DEVICE_MAJOR)
+        major(dev_st.st_rdev) != USB_DEVICE_MAJOR)
         throw USD_API_ERROR_ACCESS_DENIED;
 
-    m_dev = dev_st.st_dev;
+    m_dev = dev_st.st_rdev;
     ret = snprintf(buf, sizeof(buf),
-                   "/sys/dev/chr/%d:%d", major(m_dev), minor(m_dev));
+                   "/sys/dev/char/%d:%d", major(m_dev), minor(m_dev));
     /*
      * If this happened we have really big troubles,
      * probably it end of the world