@@ -25,60 +25,13 @@ static void detectFsInfo(struct statfs* fs, FFDisk* disk)
2525
2626#include <sys/attr.h>
2727#include <unistd.h>
28- #include <IOKit/IOKitLib.h>
29- #include <IOKit/storage/IOStorageDeviceCharacteristics.h>
3028
3129struct VolAttrBuf {
3230 uint32_t length ;
3331 attrreference_t volNameRef ;
3432 char volNameSpace [MAXPATHLEN ];
3533} __attribute__((aligned (4 ), packed ));
3634
37- void detectDiskType (FFDisk * disk ) // Not thread safe
38- {
39- if (!ffStrbufStartsWithS (& disk -> mountFrom , "/dev/disk" )) return ;
40-
41- static uint8_t cache [100 ]; // disk_id => physical_type + 1
42- const char * numStart = disk -> mountFrom .chars + strlen ("/dev/disk" );
43- char * numEnd = NULL ;
44- unsigned long diskId = strtoul (numStart , & numEnd , 10 );
45- if (numEnd == numStart || diskId >= 100 )
46- return ;
47-
48- if (cache [diskId ])
49- {
50- disk -> physicalType = cache [diskId ] - 1 ;
51- return ;
52- }
53-
54- io_iterator_t iterator ;
55- char temp = * numEnd ; * numEnd = '\0' ; // Check for root disk directly
56- * numEnd = temp ;
57- if (IOServiceGetMatchingServices (MACH_PORT_NULL , IOBSDNameMatching (MACH_PORT_NULL , 0 , disk -> mountFrom .chars + strlen ("/dev/" )), & iterator ) == kIOReturnSuccess )
58- {
59- for (io_registry_entry_t registryEntry = IOIteratorNext (iterator ); registryEntry ; IORegistryEntryGetParentEntry (registryEntry , kIOServicePlane , & registryEntry ))
60- {
61- FF_CFTYPE_AUTO_RELEASE CFDictionaryRef deviceCharacteristics = (CFDictionaryRef ) IORegistryEntryCreateCFProperty (registryEntry , CFSTR (kIOPropertyDeviceCharacteristicsKey ), kCFAllocatorDefault , kNilOptions );
62- if (!deviceCharacteristics )
63- continue ;
64-
65- CFStringRef diskType = (CFStringRef ) CFDictionaryGetValue (deviceCharacteristics , CFSTR (kIOPropertyMediumTypeKey ));
66- if (diskType )
67- {
68- if (CFStringCompare (diskType , CFSTR (kIOPropertyMediumTypeSolidStateKey ), 0 ) == 0 )
69- disk -> physicalType = FF_DISK_PHYSICAL_TYPE_SSD ;
70- else if (CFStringCompare (diskType , CFSTR (kIOPropertyMediumTypeRotationalKey ), 0 ) == 0 )
71- disk -> physicalType = FF_DISK_PHYSICAL_TYPE_HDD ;
72- }
73- break ;
74- }
75-
76- IOObjectRelease (iterator );
77- }
78-
79- cache [diskId ] = (uint8_t ) (disk -> physicalType + 1 );
80- }
81-
8235void detectFsInfo (struct statfs * fs , FFDisk * disk )
8336{
8437 if (fs -> f_flags & MNT_DONTBROWSE )
@@ -94,8 +47,6 @@ void detectFsInfo(struct statfs* fs, FFDisk* disk)
9447 .volattr = ATTR_VOL_INFO | ATTR_VOL_NAME ,
9548 }, & attrBuf , sizeof (attrBuf ), 0 ) == 0 )
9649 ffStrbufInitNS (& disk -> name , attrBuf .volNameRef .attr_length - 1 /* excluding '\0' */ , attrBuf .volNameSpace );
97-
98- detectDiskType (disk );
9950}
10051#endif
10152
@@ -122,7 +73,6 @@ const char* ffDetectDisksImpl(FFlist* disks)
12273 #endif
12374
12475 FFDisk * disk = ffListAdd (disks );
125- disk -> physicalType = FF_DISK_PHYSICAL_TYPE_UNKNOWN ;
12676
12777 disk -> bytesTotal = fs -> f_blocks * fs -> f_bsize ;
12878 disk -> bytesFree = (uint64_t )fs -> f_bfree * fs -> f_bsize ;
0 commit comments