diff --git a/linux/device.c b/linux/device.c index 58f287c..e91d55e 100644 --- a/linux/device.c +++ b/linux/device.c @@ -164,6 +164,7 @@ int32_t GetDeviceType(void* device_ctx) char* fc_path; char* sas_path; int ret; + char delim; char* chrptr; char* sysfs_path_scr; FILE* file; @@ -242,23 +243,26 @@ int32_t GetDeviceType(void* device_ctx) } ret = 0; - chrptr = strchr(dev_path, ':'); + delim = '.'; + chrptr = strrchr(dev_path, delim); if(!chrptr) { - chrptr = strrchr(dev_path, '.'); - if(!chrptr) - { - free((void*)sysfs_path); - free((void*)dev_path); - free((void*)host_no); - free((void*)iscsi_path); - free((void*)scsi_path); - free((void*)spi_path); - free((void*)fc_path); - free((void*)sas_path); - return dev_type; - } + delim = ':'; + chrptr = strrchr(dev_path, delim); + } + + if(!chrptr) + { + free((void*)sysfs_path); + free((void*)dev_path); + free((void*)host_no); + free((void*)iscsi_path); + free((void*)scsi_path); + free((void*)spi_path); + free((void*)fc_path); + free((void*)sas_path); + return dev_type; } chrptr--; @@ -270,8 +274,15 @@ int32_t GetDeviceType(void* device_ctx) chrptr++; break; } + else if(chrptr[0] == delim) + { + ret = 0; + } + else + { + ret++; + } - ret++; chrptr--; }