1.1 --- a/Hardware/HDD/AbstractHarddrive.cs Sat Dec 31 17:31:04 2011 +0000
1.2 +++ b/Hardware/HDD/AbstractHarddrive.cs Sun Jan 01 10:14:42 2012 +0000
1.3 @@ -16,7 +16,7 @@
1.4
1.5 The Initial Developer of the Original Code is
1.6 Michael Möller <m.moeller@gmx.ch>.
1.7 - Portions created by the Initial Developer are Copyright (C) 2009-2011
1.8 + Portions created by the Initial Developer are Copyright (C) 2009-2012
1.9 the Initial Developer. All Rights Reserved.
1.10
1.11 Contributor(s):
1.12 @@ -57,6 +57,7 @@
1.13 typeof(GenericHarddisk)
1.14 };
1.15
1.16 + private string firmwareRevision;
1.17 private readonly ISmart smart;
1.18
1.19 private readonly IntPtr handle;
1.20 @@ -66,11 +67,13 @@
1.21 private IList<SmartAttribute> smartAttributes;
1.22 private IDictionary<SmartAttribute, Sensor> sensors;
1.23
1.24 - protected AbstractHarddrive(ISmart smart, string name, int index,
1.25 + protected AbstractHarddrive(ISmart smart, string name,
1.26 + string firmwareRevision, int index,
1.27 IEnumerable<SmartAttribute> smartAttributes, ISettings settings)
1.28 : base(name, new Identifier("hdd",
1.29 index.ToString(CultureInfo.InvariantCulture)), settings)
1.30 {
1.31 + this.firmwareRevision = firmwareRevision;
1.32 this.smart = smart;
1.33 handle = smart.OpenDrive(index);
1.34
1.35 @@ -92,7 +95,10 @@
1.36 if (deviceHandle == smart.InvalidHandle)
1.37 return null;
1.38
1.39 - string name = smart.ReadName(deviceHandle, driveIndex);
1.40 + string name;
1.41 + string firmwareRevision;
1.42 + bool nameValid = smart.ReadNameAndFirmwareRevision(deviceHandle,
1.43 + driveIndex, out name, out firmwareRevision);
1.44 bool smartEnabled = smart.EnableSmart(deviceHandle, driveIndex);
1.45
1.46 DriveAttributeValue[] values = {};
1.47 @@ -101,7 +107,7 @@
1.48
1.49 smart.CloseHandle(deviceHandle);
1.50
1.51 - if (string.IsNullOrEmpty(name))
1.52 + if (!nameValid || string.IsNullOrEmpty(name))
1.53 return null;
1.54
1.55 foreach (Type type in hddTypes) {
1.56 @@ -136,8 +142,8 @@
1.57 // check if there is a matching name prefix for this type
1.58 foreach (NamePrefixAttribute prefix in namePrefixes) {
1.59 if (name.StartsWith(prefix.Prefix, StringComparison.InvariantCulture))
1.60 - return Activator.CreateInstance(type, smart, name, driveIndex,
1.61 - settings) as AbstractHarddrive;
1.62 + return Activator.CreateInstance(type, smart, name, firmwareRevision,
1.63 + driveIndex, settings) as AbstractHarddrive;
1.64 }
1.65 }
1.66
1.67 @@ -222,6 +228,7 @@
1.68 r.AppendLine(this.GetType().Name);
1.69 r.AppendLine();
1.70 r.AppendLine("Drive name: " + name);
1.71 + r.AppendLine("Firmware version: " + firmwareRevision);
1.72 r.AppendLine();
1.73 r.AppendFormat(CultureInfo.InvariantCulture,
1.74 " {0}{1}{2}{3}{4}{5}{6}{7}",