ioctl question(s)

Madison Kelly linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org
Tue Sep 12 00:23:21 UTC 2006


Hi all,

   I am afraid I am asking pretty n00b-ish questions :).

   I have been trying to find ways of identifying partitions and I have 
*finally* found that it *is* possible to read the hard drive serial 
number of a drive behind a USB/IDE adapter. The 'scsiinfo -a /dev/sda' 
call returns it, though slightly mangled (ie: real s/n is "abcdefgh" but 
is shown as "badcfehg"). Regardless, I now know it _is_ possible!

   So I've been doing more research and I keep seeing references to the 
'ioctl' call, but I know very little (though at least some) C. For 
example, I have read that 'hdparm' finds an IDE disk's serial number by 
calling "ioctl 0x30d". Of course I am not sure how to do this or how to 
use 'strace' on 'scsiinfo' to figure out where/what it is calling when 
it gets the serial number off the disk behind the USB/IDE adapter 
(probably a scsi call?).

   So then, given the many dire warnings I have read about messing with 
ioctl, I was hoping someone here could give me a hand with some sample 
code (I am not trying to be lazy, just cautious!).

   How could I, for example, call "getsn /dev/hda" and have it return 
what is returned when "ioctl 0x30d" is called? I am looking only for the 
most simple, basic working code that I can build on.

  In the meantime I am going to try to learn 'strace' enough to see how 
'scsiinfo' gets the HDD's serial number! :)

Thanks all!!

Madi
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list