private NVMeGeneric(NVMeInfo info, int index, ISettings settings) : base(info.Model, info.Revision, "nvme", index, settings) { this.smart = new WindowsNVMeSmart(info.Index); this.info = info; CreateSensors(); }
public static AbstractStorage CreateInstance(StorageInfo storageInfo, ISettings settings) { NVMeInfo nvmeInfo = GetDeviceInfo(); if (nvmeInfo == null) { return(null); } return(new NVMeGeneric(nvmeInfo, storageInfo.Index, settings)); }
// \\.\ScsiY: is different from \\.\PhysicalDriveX private static NVMeInfo GetDeviceInfo() { while (nextDrive < MAX_DRIVES) { using (WindowsNVMeSmart smart = new WindowsNVMeSmart(nextDrive)) { nextDrive++; if (!smart.IsValid) { continue; } NVMeInfo info = smart.GetInfo(); if (info != null) { return(info); } } } return(null); }
public static AbstractStorage CreateInstance(StorageInfo storageInfo, NVMeGeneric previousNvme, ISettings settings) { NVMeInfo nvmeInfo = GetDeviceInfo(storageInfo, previousNvme != null ? previousNvme.info.LogicalDeviceNumber : -1); if (nvmeInfo == null) { Logging.LogInfo($"Device {storageInfo.Index} ({storageInfo.Name}) identifies as NVMe device, but does not support all requires features."); } IEnumerable <string> logicalDrives = WindowsStorage.GetLogicalDrives(storageInfo.Index); string name = nvmeInfo.Model; if (logicalDrives.Any()) { logicalDrives = logicalDrives.Select(x => $"{x}:"); name += " (" + string.Join(", ", logicalDrives) + ")"; } return(new NVMeGeneric(name, nvmeInfo, storageInfo.Index, settings)); }
// \\.\ScsiY: is different from \\.\PhysicalDriveX // We need to find the NvmeInfo that matches the drive we search. private static NVMeInfo GetDeviceInfo(StorageInfo infoToMatch, int previousDrive) { for (int nextDrive = previousDrive + 1; nextDrive <= MAX_DRIVES; nextDrive++) { using (WindowsNVMeSmart smart = new WindowsNVMeSmart(nextDrive)) { if (!smart.IsValid) { continue; } NVMeInfo info = smart.GetInfo(infoToMatch, nextDrive, false); if (info != null) { return(info); } } } // This is a bit tricky. If this fails for one drive, it will fail for all, because we start with 0 each time. // if we failed to obtain any useful information for any drive letter, we force creation - this will later try to use the alternate approach // when reading NVMe data. As we know it's an NVME drive for (int nextDrive = previousDrive + 1; nextDrive <= MAX_DRIVES; nextDrive++) { using (WindowsNVMeSmart smart = new WindowsNVMeSmart(nextDrive)) { if (!smart.IsValid) { continue; } NVMeInfo info = smart.GetInfo(infoToMatch, nextDrive, true); if (info != null) { return(info); } } } return(null); }