chiark / gitweb /
Export ID_WWN_VENDOR_EXTENSION and ID_WWN_WITH_EXTENSION
authorDavid Zeuthen <davidz@redhat.com>
Fri, 4 Dec 2009 16:25:09 +0000 (11:25 -0500)
committerDavid Zeuthen <davidz@redhat.com>
Fri, 4 Dec 2009 16:40:00 +0000 (11:40 -0500)
Some SCSI devices use the same WWN and have a WWN extension that we
need to take into account when creating the /dev/disk/by-id/wwn
symlinks. Thus, introduce ID_WWN_WITH_EXTENSION. This property will
contain either the WWN (if no extension is present) or the WWN with
the vendor extension appended.

Example:

 # /lib/udev/ata_id/ata_id --export /dev/sda |grep WWN
 ID_WWN=0x5001517387d61905
 ID_WWN_WITH_EXTENSION=0x5001517387d61905

 # /lib/udev/scsi_id --whitelisted --export -d /dev/sdb |grep WWN
 ID_WWN=0x600508b400105df7
 ID_WWN_VENDOR_EXTENSION=0x0000e00000d80000
 ID_WWN_WITH_EXTENSION=0x600508b400105df70000e00000d80000

 # /lib/udev/scsi_id --whitelisted --export -d /dev/sdc |grep WWN
 ID_WWN=0x600508b400105df7
 ID_WWN_VENDOR_EXTENSION=0x0000e00000db0000
 ID_WWN_WITH_EXTENSION=0x600508b400105df70000e00000db0000

Signed-off-by: David Zeuthen <davidz@redhat.com>
extras/ata_id/ata_id.c
extras/scsi_id/scsi_id.c
extras/scsi_id/scsi_id.h
extras/scsi_id/scsi_serial.c
rules/rules.d/60-persistent-storage.rules

index cbd3b5b8d2a58517bef3c8c85921cbd6568fa5f6..25c771012710faa3fe0a5262b8013b8e55d3d1ba 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
  * ata_id - reads product/serial number from ATA drives
  *
  * Copyright (C) 2005-2008 Kay Sievers <kay.sievers@vrfy.org>
  * ata_id - reads product/serial number from ATA drives
  *
  * Copyright (C) 2005-2008 Kay Sievers <kay.sievers@vrfy.org>
@@ -520,6 +521,8 @@ int main(int argc, char *argv[])
                        wwwn <<= 16;
                        wwwn  |= *((uint16_t *) identify + 111);
                        printf("ID_WWN=0x%llx\n", (unsigned long long int) wwwn);
                        wwwn <<= 16;
                        wwwn  |= *((uint16_t *) identify + 111);
                        printf("ID_WWN=0x%llx\n", (unsigned long long int) wwwn);
+                       /* ATA devices have no vendor extension */
+                       printf("ID_WWN_WITH_EXTENSION=0x%llx\n", (unsigned long long int) wwwn);
                }
        } else {
                if (serial[0] != '\0')
                }
        } else {
                if (serial[0] != '\0')
index 9c5b2c3a3c7a442f1924c2832bb1bb0f3ad20005..5c406585561a32fdce20b5684898d2bb72265014 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
  * scsi_id.c
  *
  * Main section of the scsi_id program
  * scsi_id.c
  *
  * Main section of the scsi_id program
@@ -566,6 +567,12 @@ static int scsi_id(struct udev *udev, char *maj_min_dev)
                }
                if (dev_scsi.wwn[0] != '\0') {
                        printf("ID_WWN=0x%s\n", dev_scsi.wwn);
                }
                if (dev_scsi.wwn[0] != '\0') {
                        printf("ID_WWN=0x%s\n", dev_scsi.wwn);
+                       if (dev_scsi.wwn_vendor_extension[0] != '\0') {
+                               printf("ID_WWN_VENDOR_EXTENSION=0x%s\n", dev_scsi.wwn_vendor_extension);
+                               printf("ID_WWN_WITH_EXTENSION=0x%s%s\n", dev_scsi.wwn, dev_scsi.wwn_vendor_extension);
+                       } else {
+                               printf("ID_WWN_WITH_EXTENSION=0x%s\n", dev_scsi.wwn);
+                       }
                }
                if (dev_scsi.unit_serial_number[0] != '\0') {
                        printf("ID_SCSI_SERIAL=%s\n", dev_scsi.unit_serial_number);
                }
                if (dev_scsi.unit_serial_number[0] != '\0') {
                        printf("ID_SCSI_SERIAL=%s\n", dev_scsi.unit_serial_number);
index 4536cfd4f2596f260aa277296837d68c5f6fa21d..3b8b236368e50c9461681c73e5ed1529e3af3e98 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/*  -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
  * scsi_id.h
  *
  * General defines and such for scsi_id
  * scsi_id.h
  *
  * General defines and such for scsi_id
@@ -45,6 +46,9 @@ struct scsi_id_device {
 
         /* NULs if not set - otherwise hex encoding using lower-case e.g. '50014ee0016eb572' */
         char wwn[17];
 
         /* NULs if not set - otherwise hex encoding using lower-case e.g. '50014ee0016eb572' */
         char wwn[17];
+
+        /* NULs if not set - otherwise hex encoding using lower-case e.g. '0xe00000d80000' */
+        char wwn_vendor_extension[17];
 };
 
 extern int scsi_std_inquiry(struct udev *udev, struct scsi_id_device *dev_scsi, const char *devname);
 };
 
 extern int scsi_std_inquiry(struct udev *udev, struct scsi_id_device *dev_scsi, const char *devname);
index 5b18b225a5eb6e7e4e9bd0eb15e0a600e011abc1..0c9d9c3095e9723627c0f38740771329d6fcf976 100644 (file)
@@ -1,4 +1,5 @@
-/*
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
  * scsi_serial.c
  *
  * Code related to requesting and getting an id from a scsi device
  * scsi_serial.c
  *
  * Code related to requesting and getting an id from a scsi device
@@ -482,7 +483,8 @@ static int check_fill_0x83_id(struct udev *udev,
                              unsigned char *page_83,
                              const struct scsi_id_search_values
                              *id_search, char *serial, char *serial_short, int max_len,
                              unsigned char *page_83,
                              const struct scsi_id_search_values
                              *id_search, char *serial, char *serial_short, int max_len,
-                              char *wwn)
+                              char *wwn,
+                             char *wwn_vendor_extension)
 {
        int i, j, s, len;
 
 {
        int i, j, s, len;
 
@@ -569,6 +571,9 @@ static int check_fill_0x83_id(struct udev *udev,
 
         if (id_search->id_type == SCSI_ID_NAA && wwn != NULL) {
                 strncpy(wwn, &serial[s], 16);
 
         if (id_search->id_type == SCSI_ID_NAA && wwn != NULL) {
                 strncpy(wwn, &serial[s], 16);
+               if (wwn_vendor_extension != NULL) {
+                       strncpy(wwn_vendor_extension, &serial[s + 16], 16);
+               }
         }
        return 0;
 }
         }
        return 0;
 }
@@ -601,7 +606,8 @@ static int check_fill_0x83_prespc3(struct udev *udev,
 static int do_scsi_page83_inquiry(struct udev *udev,
                                  struct scsi_id_device *dev_scsi, int fd,
                                  char *serial, char *serial_short, int len,
 static int do_scsi_page83_inquiry(struct udev *udev,
                                  struct scsi_id_device *dev_scsi, int fd,
                                  char *serial, char *serial_short, int len,
-                                  char *unit_serial_number, char *wwn)
+                                  char *unit_serial_number, char *wwn,
+                                 char *wwn_vendor_extension)
 {
        int retval;
        unsigned int id_ind, j;
 {
        int retval;
        unsigned int id_ind, j;
@@ -671,7 +677,8 @@ static int do_scsi_page83_inquiry(struct udev *udev,
                                                    dev_scsi, &page_83[j],
                                                    &id_search_list[id_ind],
                                                    serial, serial_short, len,
                                                    dev_scsi, &page_83[j],
                                                    &id_search_list[id_ind],
                                                    serial, serial_short, len,
-                                                    wwn);
+                                                    wwn,
+                                                   wwn_vendor_extension);
                        dbg(udev, "%s id desc %d/%d/%d\n", dev_scsi->kernel,
                                id_search_list[id_ind].id_type,
                                id_search_list[id_ind].naa_type,
                        dbg(udev, "%s id desc %d/%d/%d\n", dev_scsi->kernel,
                                id_search_list[id_ind].id_type,
                                id_search_list[id_ind].naa_type,
@@ -885,7 +892,7 @@ int scsi_get_serial(struct udev *udev,
                        goto completed;
                }
        } else if (page_code == PAGE_83) {
                        goto completed;
                }
        } else if (page_code == PAGE_83) {
-               if (do_scsi_page83_inquiry(udev, dev_scsi, fd, dev_scsi->serial, dev_scsi->serial_short, len, dev_scsi->unit_serial_number, dev_scsi->wwn)) {
+               if (do_scsi_page83_inquiry(udev, dev_scsi, fd, dev_scsi->serial, dev_scsi->serial_short, len, dev_scsi->unit_serial_number, dev_scsi->wwn, dev_scsi->wwn_vendor_extension)) {
                        retval = 1;
                        goto completed;
                } else  {
                        retval = 1;
                        goto completed;
                } else  {
@@ -901,7 +908,7 @@ int scsi_get_serial(struct udev *udev,
                         * conform to pre-SPC3 expectations.
                         */
                        if (retval == 2) {
                         * conform to pre-SPC3 expectations.
                         */
                        if (retval == 2) {
-                               if (do_scsi_page83_inquiry(udev, dev_scsi, fd, dev_scsi->serial, dev_scsi->serial_short, len, dev_scsi->unit_serial_number, dev_scsi->wwn)) {
+                               if (do_scsi_page83_inquiry(udev, dev_scsi, fd, dev_scsi->serial, dev_scsi->serial_short, len, dev_scsi->unit_serial_number, dev_scsi->wwn, dev_scsi->wwn_vendor_extension)) {
                                        retval = 1;
                                        goto completed;
                                } else  {
                                        retval = 1;
                                        goto completed;
                                } else  {
@@ -941,7 +948,7 @@ int scsi_get_serial(struct udev *udev,
        for (ind = 4; ind <= page0[3] + 3; ind++)
                if (page0[ind] == PAGE_83)
                        if (!do_scsi_page83_inquiry(udev, dev_scsi, fd,
        for (ind = 4; ind <= page0[3] + 3; ind++)
                if (page0[ind] == PAGE_83)
                        if (!do_scsi_page83_inquiry(udev, dev_scsi, fd,
-                                                   dev_scsi->serial, dev_scsi->serial_short, len, dev_scsi->unit_serial_number, dev_scsi->wwn)) {
+                                                   dev_scsi->serial, dev_scsi->serial_short, len, dev_scsi->unit_serial_number, dev_scsi->wwn, dev_scsi->wwn_vendor_extension)) {
                                /*
                                 * Success
                                 */
                                /*
                                 * Success
                                 */
index c839f3bc064ac323a411d65fda74e78dd4427de6..89041a950b9cda75665179e056288a8d84ccaa82 100644 (file)
@@ -67,7 +67,7 @@ ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+
 ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"
 
 # by-id (World Wide Name)
 ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"
 
 # by-id (World Wide Name)
-ENV{DEVTYPE}=="disk", ENV{ID_WWN}=="?*", SYMLINK+="disk/by-id/wwn-$env{ID_WWN}"
-ENV{DEVTYPE}=="partition", ENV{ID_WWN}=="?*", SYMLINK+="disk/by-id/wwn-$env{ID_WWN}-part%n"
+ENV{DEVTYPE}=="disk", ENV{ID_WWN_WITH_EXTENSION}=="?*", SYMLINK+="disk/by-id/wwn-$env{ID_WWN_WITH_EXTENSION}"
+ENV{DEVTYPE}=="partition", ENV{ID_WWN_WITH_EXTENSION}=="?*", SYMLINK+="disk/by-id/wwn-$env{ID_WWN_WITH_EXTENSION}-part%n"
 
 LABEL="persistent_storage_end"
 
 LABEL="persistent_storage_end"