11#include "diskio.h"
22#include "common/io/io.h"
3- #include "util/windows/registry.h"
43#include "util/windows/unicode.h"
54
5+ #include <windows.h>
66#include <winioctl.h>
77
88const char * ffDiskIOGetIoCounters (FFlist * result , FFDiskIOOptions * options )
@@ -52,13 +52,18 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options)
5252 ffStrbufTrimRight (& device -> name , ' ' );
5353 }
5454
55+ if (!device -> name .length )
56+ ffStrbufAppendF (& device -> name , "PhysicalDrive%u" , (unsigned ) idev );
57+
5558 if (options -> namePrefix .length && !ffStrbufStartsWith (& device -> name , & options -> namePrefix ))
5659 {
5760 ffStrbufDestroy (& device -> name );
5861 result -> length -- ;
5962 continue ;
6063 }
6164
65+ ffStrbufInitWS (& device -> devPath , szDevice );
66+
6267 DISK_PERFORMANCE dp = {};
6368 if (DeviceIoControl (hDevice , IOCTL_DISK_PERFORMANCE , NULL , 0 , & dp , sizeof (dp ), & retSize , NULL ))
6469 {
@@ -73,74 +78,6 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options)
7378 result -> length -- ;
7479 continue ;
7580 }
76-
77- ffStrbufInitWS (& device -> devPath , szDevice );
78- ffStrbufInit (& device -> serial );
79- if (sdd -> SerialNumberOffset != 0 )
80- {
81- ffStrbufSetS (& device -> serial , (const char * ) sddBuffer + sdd -> SerialNumberOffset );
82- ffStrbufTrim (& device -> serial , ' ' );
83- }
84-
85- device -> removable = !!sdd -> RemovableMedia ;
86-
87- ffStrbufInit (& device -> interconnect );
88- switch (sdd -> BusType )
89- {
90- case BusTypeUnknown : ffStrbufSetStatic (& device -> interconnect , "Unknown" ); break ;
91- case BusTypeScsi : ffStrbufSetStatic (& device -> interconnect , "Scsi" ); break ;
92- case BusTypeAtapi : ffStrbufSetStatic (& device -> interconnect , "Atapi" ); break ;
93- case BusTypeAta : ffStrbufSetStatic (& device -> interconnect , "Ata" ); break ;
94- case BusType1394 : ffStrbufSetStatic (& device -> interconnect , "1394" ); break ;
95- case BusTypeSsa : ffStrbufSetStatic (& device -> interconnect , "Ssa" ); break ;
96- case BusTypeFibre : ffStrbufSetStatic (& device -> interconnect , "Fibra" ); break ;
97- case BusTypeUsb : ffStrbufSetStatic (& device -> interconnect , "Usb" ); break ;
98- case BusTypeRAID : ffStrbufSetStatic (& device -> interconnect , "RAID" ); break ;
99- case BusTypeiScsi : ffStrbufSetStatic (& device -> interconnect , "iScsi" ); break ;
100- case BusTypeSas : ffStrbufSetStatic (& device -> interconnect , "Sas" ); break ;
101- case BusTypeSata : ffStrbufSetStatic (& device -> interconnect , "Sata" ); break ;
102- case BusTypeSd : ffStrbufSetStatic (& device -> interconnect , "Sd" ); break ;
103- case BusTypeMmc : ffStrbufSetStatic (& device -> interconnect , "Mmc" ); break ;
104- case BusTypeVirtual : ffStrbufSetStatic (& device -> interconnect , "Virtual" ); break ;
105- case BusTypeFileBackedVirtual : ffStrbufSetStatic (& device -> interconnect , "FileBackedVirtual" ); break ;
106- case BusTypeSpaces : ffStrbufSetStatic (& device -> interconnect , "Spaces" ); break ;
107- case BusTypeNvme : ffStrbufSetStatic (& device -> interconnect , "Nvme" ); break ;
108- case BusTypeSCM : ffStrbufSetStatic (& device -> interconnect , "SCM" ); break ;
109- case BusTypeUfs : ffStrbufSetStatic (& device -> interconnect , "Ufs" ); break ;
110- default : ffStrbufSetF (& device -> interconnect , "Unknown (%d)" , (int ) sdd -> BusType ); break ;
111- }
112-
113- DEVICE_SEEK_PENALTY_DESCRIPTOR dspd = {};
114- if (DeviceIoControl (
115- hDevice ,
116- IOCTL_STORAGE_QUERY_PROPERTY ,
117- & (STORAGE_PROPERTY_QUERY ) {
118- .PropertyId = StorageDeviceSeekPenaltyProperty ,
119- .QueryType = PropertyStandardQuery ,
120- },
121- sizeof (STORAGE_PROPERTY_QUERY ),
122- & dspd ,
123- sizeof (dspd ),
124- & retSize ,
125- NULL
126- ) && retSize == sizeof (dspd ))
127- device -> type = dspd .IncursSeekPenalty ? FF_DISKIO_PHYSICAL_TYPE_HDD : FF_DISKIO_PHYSICAL_TYPE_SSD ;
128- else
129- device -> type = FF_DISKIO_PHYSICAL_TYPE_UNKNOWN ;
130-
131- DISK_GEOMETRY_EX dge = {};
132- if (DeviceIoControl (
133- hDevice ,
134- IOCTL_DISK_GET_DRIVE_GEOMETRY_EX ,
135- NULL ,
136- 0 ,
137- & dge ,
138- sizeof (dge ),
139- & retSize ,
140- NULL ))
141- device -> size = (uint64_t ) dge .DiskSize .QuadPart ;
142- else
143- device -> size = 0 ;
14481 }
14582
14683 return NULL ;
0 commit comments