是否有可靠、快速、确定的方法(即不是基准)来检查系统驱动器Mac是否是固态驱动器?
是否有其他指示磁盘处理并行访问的能力?我试图调整我的程序将用于磁盘绑定操作的线程数量。
我不感兴趣的原始速度或寻找时间,只有哪种类型的访问-串行或并行-是更快的驱动器。我不期望我的程序的用户使用iSCSI或RAID。SSD是我的重点,其他的都是很好的选择。
Device Characteristics
of IOAHCIBlockStorageDevice
包含此信息。如何以编程方式阅读?
到目前为止,我已经知道它是这样的:(下面是伪代码)
match = IOBSDNameMatching(kIOMasterPortDefault,0,"disk0s2");
IOServiceGetMatchingServices(kIOMasterPortDefault, match, &iterator);
while(entry = IOIteratorNext(iterator)) {
do {
entry = IORegistryEntryGetParentEntry(nextMedia, kIOServicePlane, &entry);
dict = IORegistryEntryCreateCFProperty(nextMedia,
CFSTR(kIOPropertyDeviceCharacteristicsKey), kCFAllocatorDefault, 0);
[dict objectForKey:CFSTR(kIOPropertyMediumTypeKey)];
}
while(!dict && entry);
}
编辑:以下是完整的源代码.我已经证实它与Intel SSD和OCZ顶点一起工作。
发布于 2010-01-17 19:29:00
如果你想得到这样的信息,最好的猜测是IOKit。
您可以使用ioreg命令行工具或IORegistryExplorer来尝试它的一些功能。
以下是一些可能对你有帮助的代码。它获取所有不是RAID和分区的硬盘驱动器。这不是你想要的,但它可能会让你开始。
#import "TWDevice.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <paths.h>
#include <sys/param.h>
#include <IOKit/IOKitLib.h>
#include <IOKit/IOBSD.h>
#include <IOKit/storage/IOMedia.h>
#include <CoreFoundation/CoreFoundation.h>
#include <IOKit/Kext/KextManager.h>
@implementation TWDevice
@synthesize name, devicePath, size, blockSize, writable, icon;
+ (NSArray *)allDevices {
// create matching dictionary
CFMutableDictionaryRef classesToMatch;
classesToMatch = IOServiceMatching(kIOMediaClass);
if (classesToMatch == NULL) {
[NSException raise:@"TWError" format:@"Classes to match could not be created"];
}
// get iterator of matching services
io_iterator_t mediaIterator;
kern_return_t kernResult;
kernResult = IOServiceGetMatchingServices(kIOMasterPortDefault,
classesToMatch,
&mediaIterator);
if (kernResult != KERN_SUCCESS) {
[NSException raise:@"TWError" format:@"Matching services did not succed."];
}
// iterate over all found medias
io_object_t nextMedia;
NSMutableArray *detectedDevices = [NSMutableArray array];
while (nextMedia = IOIteratorNext(mediaIterator)) {
NSMutableDictionary *properties;
kernResult = IORegistryEntryCreateCFProperties(nextMedia,
(CFMutableDictionaryRef *)&properties,
kCFAllocatorDefault, 0);
if (kernResult != KERN_SUCCESS) {
[NSException raise:@"TWError" format:@"Getting properties threw error."];
}
// is it a whole device or just a partition?
if ([[properties valueForKey:@"Whole"] boolValue] &&
![[properties valueForKey:@"RAID"] boolValue]) {
TWDevice *device = [[[TWDevice alloc] init] autorelease];
device.devicePath = [NSString stringWithFormat:@"%sr%@", _PATH_DEV, [properties valueForKey:@"BSD Name"]];
device.blockSize = [[properties valueForKey:@"Preferred Block Size"] unsignedLongLongValue];
device.writable = [[properties valueForKey:@"Writable"] boolValue];
device.size = [[properties valueForKey:@"Size"] unsignedLongLongValue];
io_name_t name;
IORegistryEntryGetName(nextMedia, name);
device.name = [NSString stringWithCString:name encoding:NSASCIIStringEncoding];
…
[detectedDevices addObject:device];
}
// tidy up
IOObjectRelease(nextMedia);
CFRelease(properties);
}
IOObjectRelease(mediaIterator);
return detectedDevices;
}
@end
发布于 2010-01-17 18:10:54
实际上,我认为你应该走基准测试的路线,因为它更准确地回答了你的问题--你并不真的关心磁盘碰巧是一个SSD,你只是关心磁盘非常快。如果用户正在使用快速RAID设置、光纤通道数组,或者使用iSCSI,怎么办?
只需从基础/dev/diskX中读取一堆随机扇区,如果它符合您的要求,您可以将其视为“快速”驱动器
发布于 2019-08-12 23:08:34
这似乎只可能在内部驱动器。我找不到一种方法使用IOKit查询三星T5外部USB3SSD的SSD (也没有东芝Canvio )。不过,我确实设法在我的MBP中实现了内部驱动。
磁盘实用程序也不认为三星是一个SSD,所以这让我认为可能没有其他方法,除了衡量实际的性能。
https://stackoverflow.com/questions/2081941
复制相似问题