@@ -80,24 +80,28 @@ static void parsePhysicalDisk(int dfd, const char* devName, FFPhysicalDiskOption
8080
8181 {
8282 ffStrbufInit (& device -> interconnect );
83- char pathSysDeviceReal [ PATH_MAX ];
84- ssize_t pathLength = readlinkat ( dfd , "device" , pathSysDeviceReal , ARRAY_SIZE ( pathSysDeviceReal ) - 1 );
85- if ( pathLength > 0 )
83+ if ( ffStrStartsWith ( devName , "nvme" ))
84+ ffStrbufSetStatic ( & device -> interconnect , "NVMe" );
85+ else
8686 {
87- pathSysDeviceReal [pathLength ] = '\0' ;
88-
89- if (strstr (pathSysDeviceReal , "/usb" ) != NULL )
90- ffStrbufSetS (& device -> interconnect , "USB" );
91- else if (strstr (pathSysDeviceReal , "/nvme" ) != NULL )
92- ffStrbufSetS (& device -> interconnect , "NVMe" );
93- else if (strstr (pathSysDeviceReal , "/ata" ) != NULL )
94- ffStrbufSetS (& device -> interconnect , "ATA" );
95- else if (strstr (pathSysDeviceReal , "/scsi" ) != NULL )
96- ffStrbufSetS (& device -> interconnect , "SCSI" );
97- else
87+ char pathSysDeviceLink [64 ];
88+ snprintf (pathSysDeviceLink , ARRAY_SIZE (pathSysDeviceLink ), "/sys/block/%s/device" , devName );
89+ char pathSysDeviceReal [PATH_MAX ];
90+ if (realpath (pathSysDeviceLink , pathSysDeviceReal ))
9891 {
99- if (ffAppendFileBufferRelative (devfd , "transport" , & device -> interconnect ))
100- ffStrbufTrimRightSpace (& device -> interconnect );
92+ if (strstr (pathSysDeviceReal , "/usb" ) != NULL )
93+ ffStrbufSetStatic (& device -> interconnect , "USB" );
94+ else if (strstr (pathSysDeviceReal , "/ata" ) != NULL )
95+ ffStrbufSetStatic (& device -> interconnect , "ATA" );
96+ else if (strstr (pathSysDeviceReal , "/scsi" ) != NULL )
97+ ffStrbufSetStatic (& device -> interconnect , "SCSI" );
98+ else if (strstr (pathSysDeviceReal , "/nvme" ) != NULL )
99+ ffStrbufSetStatic (& device -> interconnect , "NVMe" );
100+ else
101+ {
102+ if (ffAppendFileBufferRelative (devfd , "transport" , & device -> interconnect ))
103+ ffStrbufTrimRightSpace (& device -> interconnect );
104+ }
101105 }
102106 }
103107 }
0 commit comments