mirror of
https://github.com/aaru-dps/aaruremote.git
synced 2025-12-16 19:24:37 +00:00
Merge pull request #12 from kkaisershot/2.6.26-scsi-fix
Detect SCSI devices on 2.6.26 kernel PowerPC system.
This commit is contained in:
@@ -164,6 +164,7 @@ int32_t GetDeviceType(void* device_ctx)
|
|||||||
char* fc_path;
|
char* fc_path;
|
||||||
char* sas_path;
|
char* sas_path;
|
||||||
int ret;
|
int ret;
|
||||||
|
char delim;
|
||||||
char* chrptr;
|
char* chrptr;
|
||||||
char* sysfs_path_scr;
|
char* sysfs_path_scr;
|
||||||
FILE* file;
|
FILE* file;
|
||||||
@@ -242,11 +243,15 @@ int32_t GetDeviceType(void* device_ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
chrptr = strchr(dev_path, ':');
|
delim = '.';
|
||||||
|
chrptr = strrchr(dev_path, delim);
|
||||||
|
|
||||||
if(!chrptr)
|
if(!chrptr)
|
||||||
{
|
{
|
||||||
chrptr = strrchr(dev_path, '.');
|
delim = ':';
|
||||||
|
chrptr = strrchr(dev_path, delim);
|
||||||
|
}
|
||||||
|
|
||||||
if(!chrptr)
|
if(!chrptr)
|
||||||
{
|
{
|
||||||
free((void*)sysfs_path);
|
free((void*)sysfs_path);
|
||||||
@@ -259,7 +264,6 @@ int32_t GetDeviceType(void* device_ctx)
|
|||||||
free((void*)sas_path);
|
free((void*)sas_path);
|
||||||
return dev_type;
|
return dev_type;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
chrptr--;
|
chrptr--;
|
||||||
|
|
||||||
@@ -270,8 +274,15 @@ int32_t GetDeviceType(void* device_ctx)
|
|||||||
chrptr++;
|
chrptr++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else if(chrptr[0] == delim)
|
||||||
|
{
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
ret++;
|
ret++;
|
||||||
|
}
|
||||||
|
|
||||||
chrptr--;
|
chrptr--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ DeviceInfoList* ListDevices()
|
|||||||
|
|
||||||
udev = udev_new();
|
udev = udev_new();
|
||||||
has_udev = udev != 0;
|
has_udev = udev != 0;
|
||||||
|
#else
|
||||||
|
DeviceContext tmp_ctx;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
dir = opendir(PATH_SYS_DEVBLOCK);
|
dir = opendir(PATH_SYS_DEVBLOCK);
|
||||||
@@ -58,7 +60,7 @@ DeviceInfoList* ListDevices()
|
|||||||
|
|
||||||
while(dirent)
|
while(dirent)
|
||||||
{
|
{
|
||||||
if(dirent->d_type != DT_REG && dirent->d_type != DT_LNK)
|
if((dirent->d_type != DT_DIR && dirent->d_type != DT_LNK) || dirent->d_name[0] == '.')
|
||||||
{
|
{
|
||||||
dirent = readdir(dir);
|
dirent = readdir(dir);
|
||||||
continue;
|
continue;
|
||||||
@@ -137,11 +139,10 @@ DeviceInfoList* ListDevices()
|
|||||||
#else // Use sysfs
|
#else // Use sysfs
|
||||||
if(!has_udev && !strstr(dirent->d_name, "loop"))
|
if(!has_udev && !strstr(dirent->d_name, "loop"))
|
||||||
{
|
{
|
||||||
tmp_string = malloc(1024);
|
memset((void*)tmp_ctx.device_path, 0, 4096);
|
||||||
memset((void*)tmp_string, 0, 1024);
|
snprintf((char*)tmp_ctx.device_path, 4096, "/dev/%s", dirent->d_name);
|
||||||
snprintf((char*)tmp_string, 1024, "/dev/%s", dirent->d_name);
|
|
||||||
|
|
||||||
switch(GetDeviceType(tmp_string))
|
switch(GetDeviceType(&tmp_ctx))
|
||||||
{
|
{
|
||||||
case AARUREMOTE_DEVICE_TYPE_ATA: strncpy(list_next->this.bus, "ATA", 256); break;
|
case AARUREMOTE_DEVICE_TYPE_ATA: strncpy(list_next->this.bus, "ATA", 256); break;
|
||||||
case AARUREMOTE_DEVICE_TYPE_ATAPI: strncpy(list_next->this.bus, "ATAPI", 256); break;
|
case AARUREMOTE_DEVICE_TYPE_ATAPI: strncpy(list_next->this.bus, "ATAPI", 256); break;
|
||||||
@@ -149,6 +150,7 @@ DeviceInfoList* ListDevices()
|
|||||||
case AARUREMOTE_DEVICE_TYPE_SECURE_DIGITAL: strncpy(list_next->this.bus, "MMC/SD", 256); break;
|
case AARUREMOTE_DEVICE_TYPE_SECURE_DIGITAL: strncpy(list_next->this.bus, "MMC/SD", 256); break;
|
||||||
case AARUREMOTE_DEVICE_TYPE_NVME: strncpy(list_next->this.bus, "NVMe", 256); break;
|
case AARUREMOTE_DEVICE_TYPE_NVME: strncpy(list_next->this.bus, "NVMe", 256); break;
|
||||||
case AARUREMOTE_DEVICE_TYPE_SCSI:
|
case AARUREMOTE_DEVICE_TYPE_SCSI:
|
||||||
|
tmp_string = malloc(1024);
|
||||||
memset((void*)tmp_string, 0, 1024);
|
memset((void*)tmp_string, 0, 1024);
|
||||||
snprintf((char*)tmp_string, 1024, "%s/%s/device", PATH_SYS_DEVBLOCK, dirent->d_name);
|
snprintf((char*)tmp_string, 1024, "%s/%s/device", PATH_SYS_DEVBLOCK, dirent->d_name);
|
||||||
line_str = malloc(1024);
|
line_str = malloc(1024);
|
||||||
@@ -208,11 +210,10 @@ DeviceInfoList* ListDevices()
|
|||||||
free(line_str);
|
free(line_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free((void*)tmp_string);
|
||||||
break;
|
break;
|
||||||
default: memset(&list_next->this.bus, 0, 256); break;
|
default: memset(&list_next->this.bus, 0, 256); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
free((void*)tmp_string);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user