Magellan Linux

Annotation of /trunk/hal/patches/hal-0.5.7.1-indirection-fix.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 144 - (hide annotations) (download)
Tue May 8 20:06:05 2007 UTC (17 years ago) by niro
File size: 4548 byte(s)
-import

1 niro 144 diff -uNr hal-0.5.7.orig/hald/device_info.c hal-0.5.7/hald/device_info.c
2     --- hal-0.5.7.orig/hald/device_info.c 2006-01-21 07:36:51.000000000 +0100
3     +++ hal-0.5.7/hald/device_info.c 2006-10-26 23:00:26.000000000 +0200
4     @@ -1114,56 +1114,22 @@
5     pc->merge_type, pc->merge_type));
6     break;
7     }
8     - } else if (pc->curelem == CURELEM_APPEND && pc->match_ok &&
9     + } else if ((pc->curelem == CURELEM_APPEND || pc->curelem == CURELEM_PREPEND) && pc->match_ok &&
10     (hal_device_property_get_type (pc->device, pc->merge_key) == HAL_PROPERTY_TYPE_STRING ||
11     hal_device_property_get_type (pc->device, pc->merge_key) == HAL_PROPERTY_TYPE_STRLIST ||
12     hal_device_property_get_type (pc->device, pc->merge_key) == HAL_PROPERTY_TYPE_INVALID)) {
13     char buf[256];
14     char buf2[256];
15    
16     - /* As soon as we are appending, we have matched the device... */
17     + /* As soon as we are appending/prepending, we have matched the device... */
18     pc->device_matched = TRUE;
19    
20     if (pc->merge_type == MERGE_TYPE_STRLIST) {
21     - hal_device_property_strlist_append (pc->device, pc->merge_key, pc->cdata_buf);
22     - } else {
23     - const char *existing_string;
24     -
25     - switch (pc->merge_type) {
26     - case MERGE_TYPE_STRING:
27     - strncpy (buf, pc->cdata_buf, sizeof (buf));
28     - break;
29     -
30     - case MERGE_TYPE_COPY_PROPERTY:
31     - hal_device_property_get_as_string (pc->device, pc->cdata_buf, buf, sizeof (buf));
32     - break;
33     -
34     - default:
35     - HAL_ERROR (("Unknown merge_type=%d='%c'", pc->merge_type, pc->merge_type));
36     - break;
37     - }
38     -
39     - existing_string = hal_device_property_get_string (pc->device, pc->merge_key);
40     - if (existing_string != NULL) {
41     - strncpy (buf2, existing_string, sizeof (buf2));
42     - strncat (buf2, buf, sizeof (buf2) - strlen(buf2));
43     + if (pc->curelem == CURELEM_APPEND){
44     + hal_device_property_strlist_append (pc->device, pc->merge_key, pc->cdata_buf);
45     } else {
46     - strncpy (buf2, buf, sizeof (buf2));
47     + hal_device_property_strlist_prepend (pc->device, pc->merge_key, pc->cdata_buf);
48     }
49     - hal_device_property_set_string (pc->device, pc->merge_key, buf2);
50     - }
51     - } else if (pc->curelem == CURELEM_PREPEND && pc->match_ok &&
52     - (hal_device_property_get_type (pc->device, pc->merge_key) == HAL_PROPERTY_TYPE_STRING ||
53     - hal_device_property_get_type (pc->device, pc->merge_key) == HAL_PROPERTY_TYPE_STRLIST ||
54     - hal_device_property_get_type (pc->device, pc->merge_key) == HAL_PROPERTY_TYPE_INVALID)) {
55     - char buf[256];
56     - char buf2[256];
57     -
58     - /* As soon as we are prepending, we have matched the device... */
59     - pc->device_matched = TRUE;
60     -
61     - if (pc->merge_type == MERGE_TYPE_STRLIST) {
62     - hal_device_property_strlist_prepend (pc->device, pc->merge_key, pc->cdata_buf);
63     } else {
64     const char *existing_string;
65    
66     @@ -1173,8 +1139,34 @@
67     break;
68    
69     case MERGE_TYPE_COPY_PROPERTY:
70     - hal_device_property_get_as_string (pc->device, pc->cdata_buf, buf, sizeof (buf));
71     + {
72     + char udi_to_merge_from[256];
73     + char prop_to_merge[256];
74     +
75     + /* Resolve key paths like 'someudi/foo/bar/baz:prop.name'
76     + * '@prop.here.is.an.udi:with.prop.name'
77     + */
78     + if (!resolve_udiprop_path (pc->cdata_buf,
79     + pc->device->udi,
80     + udi_to_merge_from, sizeof (udi_to_merge_from),
81     + prop_to_merge, sizeof (prop_to_merge))) {
82     + HAL_ERROR (("Could not resolve keypath '%s' on udi '%s'", pc->cdata_buf, pc->device->udi));
83     + } else {
84     + HalDevice *d;
85     +
86     + d = hal_device_store_find (hald_get_gdl (), udi_to_merge_from);
87     + if (d == NULL) {
88     + d = hal_device_store_find (hald_get_tdl (), udi_to_merge_from);
89     + }
90     + if (d == NULL) {
91     + HAL_ERROR (("Could not find device with udi '%s'", udi_to_merge_from));
92     + } else {
93     + hal_device_property_get_as_string (d, prop_to_merge, buf, sizeof (buf));
94     + }
95     + }
96     +
97     break;
98     + }
99    
100     default:
101     HAL_ERROR (("Unknown merge_type=%d='%c'", pc->merge_type, pc->merge_type));
102     @@ -1183,8 +1175,13 @@
103    
104     existing_string = hal_device_property_get_string (pc->device, pc->merge_key);
105     if (existing_string != NULL) {
106     - strncpy (buf2, buf, sizeof (buf2));
107     - strncat (buf2, existing_string, sizeof (buf2) - strlen(buf2));
108     + if (pc->curelem == CURELEM_APPEND){
109     + strncpy (buf2, existing_string, sizeof (buf2));
110     + strncat (buf2, buf, sizeof (buf2) - strlen(buf2));
111     + } else {
112     + strncpy (buf2, buf, sizeof (buf2));
113     + strncat (buf2, existing_string, sizeof (buf2) - strlen(buf2));
114     + }
115     } else {
116     strncpy (buf2, buf, sizeof (buf2));
117     }