~psusi/ubuntu/precise/dmraid/fix-gpt

« back to all changes in this revision

Viewing changes to debian/patches/14_isw-serial-fix.patch

  • Committer: Bazaar Package Importer
  • Author(s): Artur Rona
  • Date: 2010-02-04 21:34:22 UTC
  • mfrom: (1.1.4 upstream) (2.4.3 sid)
  • Revision ID: james.westby@ubuntu.com-20100204213422-tdag8lcxpr7ahmg4
Tags: 1.0.0.rc16-3ubuntu1
* Merge from debian testing. (LP: #503136)  Remaining changes:
  - debian/dmraid-activate: Remove the special-casing of the root
    device which breaks in many situations and leaves the raw devices
    exposed. This was introduced in Debian to accommodate some broken
    configurations which wanted to access "partitions" on the raid
    raw devices. In Ubuntu, broken configurations has not been supported.
  - debian/dmraid.postinst: Comment out "udevadm trigger" call in postinst
    for now as it has severeconsequences when mountall is installed
    (clears /tmp).  If dmraid is installed, then presumably the important
    system devices are up and one canbe bothered with a reboot to take 
    the change into account. Let update-initramfs flag the system
    as needing a reboot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
3
 
                (LP: #267953)
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)
8
 
 }
9
 
 
10
 
 /* Find a disk table slot by serial number. */
11
 
+static const char *dev_info_serial_to_isw(const char *di_serial)
12
 
+{
13
 
+       static char isw_serial[1024];
14
 
+
15
 
+       int i, isw_serial_len = 0;
16
 
+
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] = ';';
23
 
+                       else
24
 
+                               isw_serial[isw_serial_len] = di_serial[i];
25
 
+                       isw_serial_len++;
26
 
+               }
27
 
+       }
28
 
+       isw_serial[isw_serial_len] = 0;
29
 
+
30
 
+       if (isw_serial_len > MAX_RAID_SERIAL_LEN)
31
 
+               memmove(isw_serial,
32
 
+                       isw_serial + (isw_serial_len - MAX_RAID_SERIAL_LEN),
33
 
+                       MAX_RAID_SERIAL_LEN);
34
 
+
35
 
+       return isw_serial;
36
 
+}
37
 
+
38
 
 static struct isw_disk *
39
 
 _get_disk(struct isw *isw, struct dev_info *di)
40
 
 {
41
 
        if (di->serial) {
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);
45
 
 
46
 
                while (i--) {
47
 
-                       if (!strncmp(di->serial, (const char *) disk[i].serial,
48
 
+                       if (!strncmp(isw_serial, (const char *) disk[i].serial,
49
 
                                     MAX_RAID_SERIAL_LEN))
50
 
                                return disk + i;
51
 
                }
52
 
@@ -866,7 +894,8 @@ rd_by_serial(struct raid_set *rs, const 
53
 
 
54
 
        list_for_each_entry(rd, &rs->devs, devs) {
55
 
                if (rd->di &&
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))
59
 
                        return rd;
60
 
        }
61
 
 
62
 
@@ -1297,7 +1326,8 @@ isw_config_disks(struct lib_context *lc,
63
 
        struct raid_dev *rd;
64
 
 
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),
69
 
                        MAX_RAID_SERIAL_LEN);
70
 
                disk[i].totalBlocks = rd->di->sectors;
71
 
 
72
 
@@ -2420,7 +2450,8 @@ update_metadata(struct lib_context *lc, 
73
 
        while (i--) {
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,
79
 
                                     MAX_RAID_SERIAL_LEN))
80
 
                                goto goon;
81
 
                }
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);
89
 
 
90
 
        /* build new isw_disk array */
91
 
        for (i = 0; i < isw->num_disks; i++) {