_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;
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));
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);
}
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),
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;