[Lazarus] TurboPower OnGuard changes

Graeme Geldenhuys graemeg.lists at gmail.com
Wed Feb 10 16:12:04 CET 2010


Bogusław Brandys wrote:
> 
> Yep.I did the port.Currently I have no time to actively maintain it.It 
> worked some time ago and I added some new code to read HDD hardware 
> serial number but as I not needed this components I have no strong 
> motivation to continue the efforts.

How well did you test the reading of HDD serial number? I see you are
looking inside /proc/cmdline to fine a line with 'root=/dev/' to get the
boot device.

This already fails on my system (64bit Ubuntu 8.04.2) because I don't have
a 'root=/dev/xxx' line, in which case you default to device 'hda'. I
unfortunately only have a SATA device in my system, so that would be a
'sda' device under Linux.

To make matters worse, the 'root=' line in my /proc/cmdline looks as follows.

  root=UUID=ab4aeffc-8918-40a9-96ab-f84114949611 ro quiet splash

As you can see it rather uses the UUID of the partition. So a extra lookup
(not sure where yet - anybody with Linux knowledge please chip in) is
required before we know which /dev/XXX is the boot device.

For the UUID lookup, I think we can use the symlink target based on the
/dev/disk/by-uuid/ab4aeffc-8918-40a9-96ab-f84114949611 symlink file. On my
system this is a relative path and has a target '../../sda1'.

So hopefully this shouldn't be too hard to fix. Though I have heard that
reading SATA and SCSI hard drive serial numbers are not as easy as for ATA
(IDE) devices.

One more issue:
 * I don't have a /proc/scsi/model file in my system. I do have a
   /proc/scsi/scsi file, but it lists all scsi type devices, but no
   serial numbers.
 * I also have /proc/scsi/usb-device/5 which contains all the information
   required from my USB Strick, but unfortunately there is no entry for
   my boot hard drive (it's not USB). :-(



> The main problem with lazarus lcl is that after a few month such 
> components are full of nasty bugs due to internal inconsistencies in 
> code break by new features of compiler of lcl. For example there is a 
> lot of pointer operations without strict type checking.

I have already split the OnGuard components into two packages.
tponguard.lpk (runtime only) and tponguard_lcl.lpk (designtime only). Soon
I'll add tponguard_fpgui.lpk too.

Now that the GUI is separated from the core code, it should be easier to
keep stable or at least do unit testing against to make it stable.


BTW:
Doing some Google'ing and looking for information on how to extract the HDD
serial number from a SATA drive without root access is quite tough. I did
find an ingenious alternative though - something that will work on all
platforms too.

Query the date/time value of the '/bin' directory under Linux, or
'C:\Windows' or 'C:\WinNT' under Windows. Then work out how many seconds or
milliseconds since say 1980-01-01. You then have a pretty unique value. The
chances of somebody else running your software and having installed their
OS in the exact same millisecond as somebody else is pretty slim. :-)


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/





More information about the Lazarus mailing list