]> bbs.cooldavid.org Git - net-next-2.6.git/commit
virtio_blk: Add 'serial' attribute to virtio-blk devices (v2)
authorRyan Harper <ryanh@us.ibm.com>
Thu, 24 Jun 2010 03:19:57 +0000 (22:19 -0500)
committerRusty Russell <rusty@rustcorp.com.au>
Thu, 5 Aug 2010 03:35:30 +0000 (13:05 +0930)
commita5eb9e4ff18a33e43557d44b205f953b0c1efade
tree5b7a1bf70763c08ded665a341ea3cf2d9def9ef6
parent10bc310c27af1ed358e62351e7ac1d0110c3da27
virtio_blk: Add 'serial' attribute to virtio-blk devices (v2)

Create a new attribute for virtio-blk devices that will fetch the serial number
of the block device.  This attribute can be used by udev to create disk/by-id
symlinks for devices that don't have a UUID (filesystem) associated with them.

ATA_IDENTIFY strings are special in that they can be up to 20 chars long
and aren't required to be nul-terminated.  The buffer is also zero-padded
meaning that if the serial is 19 chars or less that we get a nul-terminated
string.  When copying this value into a string buffer, we must be careful to
copy up to the nul (if it present) and only 20 if it is longer and not to
attempt to nul terminate; this isn't needed.

Changes since v1:
- Added BUILD_BUG_ON() for PAGE_SIZE check
- Removed min() since BUILD_BUG_ON() handles the check
- Replaced serial_sysfs() by copying id directly to buffer

Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
Signed-off-by: john cooper <john.cooper@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
drivers/block/virtio_blk.c