1
Author: Hans de Goede <hdegoede@redhat.com>
2
Description: Change the serial number scan to only look at the LAST 16 bytes rather than the first
4
https://bugzilla.redhat.com/show_bug.cgi?id=490121
5
--- a/1.0.0.rc15/lib/format/ataraid/isw.c
6
+++ b/1.0.0.rc15/lib/format/ataraid/isw.c
7
@@ -81,15 +81,43 @@ is_raid10(struct isw_dev *dev)
10
/* Find a disk table slot by serial number. */
11
+static const char *dev_info_serial_to_isw(const char *di_serial)
13
+ static char isw_serial[1024];
15
+ int i, isw_serial_len = 0;
17
+ for (i = 0; di_serial[i] && isw_serial_len < 1023; i++) {
18
+ if (((unsigned char)di_serial[i]) > 0x20) {
19
+ /* ':' is reserved for use in placeholder serial
20
+ * numbers for missing disks */
21
+ if (di_serial[i] == ':')
22
+ isw_serial[isw_serial_len] = ';';
24
+ isw_serial[isw_serial_len] = di_serial[i];
28
+ isw_serial[isw_serial_len] = 0;
30
+ if (isw_serial_len > MAX_RAID_SERIAL_LEN)
32
+ isw_serial + (isw_serial_len - MAX_RAID_SERIAL_LEN),
33
+ MAX_RAID_SERIAL_LEN);
38
static struct isw_disk *
39
_get_disk(struct isw *isw, struct dev_info *di)
42
int i = isw->num_disks;
43
struct isw_disk *disk = isw->disk;
44
+ const char *isw_serial = dev_info_serial_to_isw(di->serial);
47
- if (!strncmp(di->serial, (const char *) disk[i].serial,
48
+ if (!strncmp(isw_serial, (const char *) disk[i].serial,
52
@@ -866,7 +894,8 @@ rd_by_serial(struct raid_set *rs, const
54
list_for_each_entry(rd, &rs->devs, devs) {
56
- !strncmp(rd->di->serial, serial, MAX_RAID_SERIAL_LEN))
57
+ !strncmp(dev_info_serial_to_isw(rd->di->serial), serial,
58
+ MAX_RAID_SERIAL_LEN))
62
@@ -1297,7 +1326,8 @@ isw_config_disks(struct lib_context *lc,
65
list_for_each_entry(rd, &rs->devs, devs) {
66
- strncpy((char *) disk[i].serial, rd->di->serial,
67
+ strncpy((char *) disk[i].serial,
68
+ dev_info_serial_to_isw(rd->di->serial),
70
disk[i].totalBlocks = rd->di->sectors;
72
@@ -2420,7 +2450,8 @@ update_metadata(struct lib_context *lc,
74
/* Check if the disk is listed. */
75
list_for_each_entry(di, LC_DI(lc), list) {
76
- if (!strncmp(di->serial, (const char *) disk[i].serial,
77
+ if (!strncmp(dev_info_serial_to_isw(di->serial),
78
+ (const char *) disk[i].serial,
82
@@ -2516,7 +2547,8 @@ update_metadata(struct lib_context *lc,
83
new_disk->status = CONFIG_ON_DISK |
84
DISK_SMART_EVENT_SUPPORTED |
85
CLAIMED_DISK | DETECTED_DISK | USABLE_DISK | CONFIGURED_DISK;
86
- strncpy((char *) new_disk->serial, di->serial, MAX_RAID_SERIAL_LEN);
87
+ strncpy((char *) new_disk->serial, dev_info_serial_to_isw(di->serial),
88
+ MAX_RAID_SERIAL_LEN);
90
/* build new isw_disk array */
91
for (i = 0; i < isw->num_disks; i++) {