mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: Andrey Polovov <andrey.polovov@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Getting HDD serial in kernel space
Date: Sat, 14 Nov 2009 15:28:26 +0000	[thread overview]
Message-ID: <20091114152826.014cfc35@lxorguk.ukuu.org.uk> (raw)
In-Reply-To: <4AFE95DE.3070308@gmail.com>

On Sat, 14 Nov 2009 14:34:54 +0300
Andrey Polovov <andrey.polovov@gmail.com> wrote:

> Hello.
> 
> I had a necessity to get HDD serial number in my kernel module.
> In user space I can do it so:
> 
>     fd = open( "/dev/sda", O_RDONLY|O_NONBLOCK );
>     ioctl( fd, HDIO_GET_IDENTITY, &id );
>     printf( "Serial: %s", id.serial_no );
> 
> How can I do it in kernel space (it is one hdd in machine, plugged with
> SATA)?

The identity when probed is all in the struct ata_device, although be
aware that it may not be unique per device and also that hotplug means
you need to be careful how you access it. Now and then you meet a device
where the serial number changes randomly each boot just to really annoy.

What are you actually trying to do ?

  reply	other threads:[~2009-11-14 15:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-14 11:34 Andrey Polovov
2009-11-14 15:28 ` Alan Cox [this message]
2009-11-15 14:03 ` Andrey Polovov
2009-11-15 17:05   ` Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091114152826.014cfc35@lxorguk.ukuu.org.uk \
    --to=alan@lxorguk.ukuu.org.uk \
    --cc=andrey.polovov@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®