1.1 --- a/Hardware/HDD/HDDGroup.cs Sun Oct 17 19:13:26 2010 +0000
1.2 +++ b/Hardware/HDD/HDDGroup.cs Sun Oct 17 19:25:50 2010 +0000
1.3 @@ -68,10 +68,9 @@
1.4 continue;
1.5 }
1.6
1.7 - List<SMART.DriveAttribute> attributes =
1.8 - new List<SMART.DriveAttribute>(SMART.ReadSmart(handle, drive));
1.9 + SMART.DriveAttribute[] attributes = SMART.ReadSmart(handle, drive);
1.10
1.11 - if (!(attributes.Count > 0)) {
1.12 + if (attributes.Length < 1) {
1.13 SMART.CloseHandle(handle);
1.14 continue;
1.15 }
1.16 @@ -95,28 +94,29 @@
1.17 }
1.18 }
1.19
1.20 - private SMART.AttributeID GetSSDLifeID(List<SMART.DriveAttribute> attributes) {
1.21 - // ID E9 is present on Intel, JM, SF and Samsung
1.22 + private SMART.AttributeID GetSSDLifeID(SMART.DriveAttribute[] attributes) {
1.23 + // ID E9 is present on Intel, JM, SF and Samsung (different meanings)
1.24 // ID D2 is present on Indilinx
1.25 // Neither ID has been found on a mechanical hard drive (yet),
1.26 - // So this seems like a good way to check if it's an SSD.
1.27 + // so this seems like a good way to check if it's an SSD.
1.28 bool isKnownSSD = (
1.29 - attributes.Exists(attr => attr.ID == new SMART.AttributeID(0xE9)) ||
1.30 - attributes.Exists(attr => attr.ID == new SMART.AttributeID(0xD2))
1.31 + Array.Exists(attributes, attr => attr.ID == new SMART.AttributeID(0xE9)) ||
1.32 + Array.Exists(attributes, attr => attr.ID == new SMART.AttributeID(0xD2))
1.33 );
1.34
1.35 if (!isKnownSSD) return SMART.AttributeID.None;
1.36
1.37 // We start with a traditional loop, because there are 4 unique ID's
1.38 // that potentially identify one of the vendors
1.39 - for (int i = 0; i < attributes.Count; i++) {
1.40 -
1.41 + for (int i = 0; i < attributes.Length; i++) {
1.42 if (attributes[i].ID == SMART.SamsungAttributes.RemainingLife)
1.43 return SMART.SamsungAttributes.RemainingLife;
1.44 - else if (attributes[i].ID == new SMART.AttributeID(0xAB))
1.45 +
1.46 + if (attributes[i].ID == SMART.SandForceAttributes.ProgramFailCount)
1.47 return SMART.SandForceAttributes.RemainingLife;
1.48 - else if (attributes[i].ID == new SMART.AttributeID(0xD2))
1.49 - return SMART.IndilinxAttributes.RemainingLife;
1.50 +
1.51 + if (attributes[i].ID == SMART.IndilinxAttributes.UnknownUnique)
1.52 + return SMART.IndilinxAttributes.RemainingLife;
1.53 }
1.54
1.55 // TODO: Find out JMicron's Life attribute ID; their unique ID = 0xE4
1.56 @@ -126,9 +126,9 @@
1.57 // is whether we can find all 3; pointless to use Exists()
1.58 int intelRegisterCount = 0;
1.59 foreach (SMART.DriveAttribute attribute in attributes) {
1.60 - if (attribute.ID == new SMART.AttributeID(0xE1) ||
1.61 - attribute.ID == new SMART.AttributeID(0xE8) ||
1.62 - attribute.ID == new SMART.AttributeID(0xE9)
1.63 + if (attribute.ID == SMART.IntelAttributes.HostWrites ||
1.64 + attribute.ID == SMART.IntelAttributes.RemainingLife ||
1.65 + attribute.ID == SMART.IntelAttributes.MediaWearOutIndicator
1.66 )
1.67 intelRegisterCount++;
1.68 }
1.69 @@ -139,7 +139,7 @@
1.70 }
1.71
1.72 private SMART.AttributeID GetTemperatureIndex(
1.73 - List<SMART.DriveAttribute> attributes)
1.74 + SMART.DriveAttribute[] attributes)
1.75 {
1.76 SMART.AttributeID[] validIds = new[] {
1.77 SMART.CommonAttributes.Temperature,
1.78 @@ -149,7 +149,7 @@
1.79
1.80 foreach (SMART.AttributeID validId in validIds) {
1.81 SMART.AttributeID id = validId;
1.82 - if (attributes.Exists(attr => attr.ID == id))
1.83 + if (Array.Exists(attributes, attr => attr.ID == id))
1.84 return validId;
1.85 }
1.86
1.87 @@ -188,9 +188,9 @@
1.88 continue;
1.89 }
1.90
1.91 - List<SMART.DriveAttribute> attributes = SMART.ReadSmart(handle, drive);
1.92 + SMART.DriveAttribute[] attributes = SMART.ReadSmart(handle, drive);
1.93
1.94 - if (attributes != null) {
1.95 + if (attributes.Length > 0) {
1.96 r.AppendLine("Drive name: " + name);
1.97 r.AppendLine();
1.98 r.AppendFormat(CultureInfo.InvariantCulture, " {0}{1}{2}{3}{4}{5}",