1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-05 23:51:28 +03:00
systemd/extras/scsi_id/scsi_id.h
David Zeuthen 4e9fdfccbd scsi_id: Export WWN and Unit Serial Number
Since the Unit Serial Number and the WWN are useful bits of
information export them as properties in the udev database. These
bits of information are often printed on the physical disk, see

http://people.freedesktop.org/~david/FUJITSU-MAY2036RC-sas-disk-picture.jpg

and displaying them separately in the UI (or in /dev/disk) might help
users identify the physical disk. This patch exports these bits of
information as ID_WWN and ID_SCSI_SERIAL.

Note that ata_id also use the ID_WWN property since commit
66094a4a7f (2009-11-04).

Also print out ID_SCSI=1 so users of the udev database knows the disk
speaks SCSI.

Here's the scsi_id output from one of my SAS disks with these changes:

 ID_SCSI=1
 ID_VENDOR=FUJITSU
 ID_VENDOR_ENC=FUJITSU\x20
 ID_MODEL=MAY2036RC
 ID_MODEL_ENC=MAY2036RC\x20\x20\x20\x20\x20\x20\x20
 ID_REVISION=0103
 ID_TYPE=disk
 ID_SERIAL=3500000e01b83f520
 ID_SERIAL_SHORT=500000e01b83f520
 ID_WWN=0x500000e01b83f520
 ID_SCSI_SERIAL=B3G1P8500RWT

Unfortunately we can't overload ID_SERIAL for two reasons

 1. ID_SERIAL (and ID_SERIAL_SHORT) exported by scsi_id isn't really
    the unit serial number (as defined by SCSI) - it is sometimes the
    WWN (since it is more unique than the Unit Serial Number) and
    complex rules (to make the serial unique) govern what value to
    use.

 2. It would break existing setups if the value of ID_SERIAL changed

Signed-off-by: David Zeuthen <davidz@redhat.com>
2009-11-23 21:38:21 +01:00

64 lines
1.5 KiB
C

/*
* scsi_id.h
*
* General defines and such for scsi_id
*
* Copyright (C) IBM Corp. 2003
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation version 2 of the License.
*/
#define MAX_PATH_LEN 512
/*
* MAX_ATTR_LEN: maximum length of the result of reading a sysfs
* attribute.
*/
#define MAX_ATTR_LEN 256
/*
* MAX_SERIAL_LEN: the maximum length of the serial number, including
* added prefixes such as vendor and product (model) strings.
*/
#define MAX_SERIAL_LEN 256
/*
* MAX_BUFFER_LEN: maximum buffer size and line length used while reading
* the config file.
*/
#define MAX_BUFFER_LEN 256
struct scsi_id_device {
char vendor[9];
char model[17];
char revision[5];
char type[33];
char kernel[64];
char serial[MAX_SERIAL_LEN];
char serial_short[MAX_SERIAL_LEN];
int use_sg;
/* Always from page 0x80 e.g. 'B3G1P8500RWT' - may not be unique */
char unit_serial_number[MAX_SERIAL_LEN];
/* NULs if not set - otherwise hex encoding using lower-case e.g. '50014ee0016eb572' */
char wwn[17];
};
extern int scsi_std_inquiry(struct udev *udev, struct scsi_id_device *dev_scsi, const char *devname);
extern int scsi_get_serial (struct udev *udev, struct scsi_id_device *dev_scsi, const char *devname,
int page_code, int len);
/*
* Page code values.
*/
enum page_code {
PAGE_83_PRE_SPC3 = -0x83,
PAGE_UNSPECIFIED = 0x00,
PAGE_80 = 0x80,
PAGE_83 = 0x83,
};