Gonglei | bc74112 | 2014-10-07 16:00:05 +0800 | [diff] [blame] | 1 | /* |
| 2 | * QEMU Boot Device Implement |
| 3 | * |
Gonglei | fe75270 | 2015-03-26 20:57:43 +0800 | [diff] [blame] | 4 | * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO., LTD. |
Gonglei | bc74112 | 2014-10-07 16:00:05 +0800 | [diff] [blame] | 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to deal |
| 8 | * in the Software without restriction, including without limitation the rights |
| 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | * copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in |
| 14 | * all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 | * THE SOFTWARE. |
| 23 | */ |
| 24 | |
Peter Maydell | d38ea87 | 2016-01-29 17:50:05 +0000 | [diff] [blame] | 25 | #include "qemu/osdep.h" |
Markus Armbruster | da34e65 | 2016-03-14 09:01:28 +0100 | [diff] [blame] | 26 | #include "qapi/error.h" |
Gonglei | bc74112 | 2014-10-07 16:00:05 +0800 | [diff] [blame] | 27 | #include "sysemu/sysemu.h" |
Gonglei | 12da309 | 2014-10-07 16:00:11 +0800 | [diff] [blame] | 28 | #include "qapi/visitor.h" |
Gonglei | 54086fe | 2014-10-07 16:00:38 +0800 | [diff] [blame] | 29 | #include "qemu/error-report.h" |
Thomas Huth | 5ddc648 | 2017-06-26 07:22:57 +0200 | [diff] [blame] | 30 | #include "sysemu/reset.h" |
Paolo Bonzini | 3b3d264 | 2015-12-04 11:10:27 +0100 | [diff] [blame] | 31 | #include "hw/qdev-core.h" |
Mark Cave-Ayland | 907aac2 | 2018-08-10 13:40:27 +0100 | [diff] [blame] | 32 | #include "hw/boards.h" |
Gonglei | bc74112 | 2014-10-07 16:00:05 +0800 | [diff] [blame] | 33 | |
| 34 | typedef struct FWBootEntry FWBootEntry; |
| 35 | |
| 36 | struct FWBootEntry { |
| 37 | QTAILQ_ENTRY(FWBootEntry) link; |
| 38 | int32_t bootindex; |
| 39 | DeviceState *dev; |
| 40 | char *suffix; |
| 41 | }; |
| 42 | |
| 43 | static QTAILQ_HEAD(, FWBootEntry) fw_boot_order = |
| 44 | QTAILQ_HEAD_INITIALIZER(fw_boot_order); |
Gonglei | 9816833 | 2014-12-03 16:49:46 +0000 | [diff] [blame] | 45 | static QEMUBootSetHandler *boot_set_handler; |
| 46 | static void *boot_set_opaque; |
| 47 | |
| 48 | void qemu_register_boot_set(QEMUBootSetHandler *func, void *opaque) |
| 49 | { |
| 50 | boot_set_handler = func; |
| 51 | boot_set_opaque = opaque; |
| 52 | } |
| 53 | |
Gonglei | f183993 | 2014-12-03 18:20:58 +0000 | [diff] [blame] | 54 | void qemu_boot_set(const char *boot_order, Error **errp) |
Gonglei | 9816833 | 2014-12-03 16:49:46 +0000 | [diff] [blame] | 55 | { |
Gonglei | 3b08098 | 2014-12-03 18:25:46 +0000 | [diff] [blame] | 56 | Error *local_err = NULL; |
| 57 | |
Gonglei | 9816833 | 2014-12-03 16:49:46 +0000 | [diff] [blame] | 58 | if (!boot_set_handler) { |
Gonglei | f183993 | 2014-12-03 18:20:58 +0000 | [diff] [blame] | 59 | error_setg(errp, "no function defined to set boot device list for" |
| 60 | " this architecture"); |
| 61 | return; |
Gonglei | 9816833 | 2014-12-03 16:49:46 +0000 | [diff] [blame] | 62 | } |
Gonglei | f183993 | 2014-12-03 18:20:58 +0000 | [diff] [blame] | 63 | |
Gonglei | 3b08098 | 2014-12-03 18:25:46 +0000 | [diff] [blame] | 64 | validate_bootdevices(boot_order, &local_err); |
| 65 | if (local_err) { |
| 66 | error_propagate(errp, local_err); |
| 67 | return; |
| 68 | } |
| 69 | |
Gonglei | ddcd553 | 2014-12-03 19:04:02 +0000 | [diff] [blame] | 70 | boot_set_handler(boot_set_opaque, boot_order, errp); |
Gonglei | 9816833 | 2014-12-03 16:49:46 +0000 | [diff] [blame] | 71 | } |
| 72 | |
Gonglei | 703008e | 2014-12-03 17:11:39 +0000 | [diff] [blame] | 73 | void validate_bootdevices(const char *devices, Error **errp) |
Gonglei | 9816833 | 2014-12-03 16:49:46 +0000 | [diff] [blame] | 74 | { |
| 75 | /* We just do some generic consistency checks */ |
| 76 | const char *p; |
| 77 | int bitmap = 0; |
| 78 | |
| 79 | for (p = devices; *p != '\0'; p++) { |
| 80 | /* Allowed boot devices are: |
| 81 | * a-b: floppy disk drives |
| 82 | * c-f: IDE disk drives |
| 83 | * g-m: machine implementation dependent drives |
| 84 | * n-p: network devices |
| 85 | * It's up to each machine implementation to check if the given boot |
| 86 | * devices match the actual hardware implementation and firmware |
| 87 | * features. |
| 88 | */ |
| 89 | if (*p < 'a' || *p > 'p') { |
Gonglei | 703008e | 2014-12-03 17:11:39 +0000 | [diff] [blame] | 90 | error_setg(errp, "Invalid boot device '%c'", *p); |
| 91 | return; |
Gonglei | 9816833 | 2014-12-03 16:49:46 +0000 | [diff] [blame] | 92 | } |
| 93 | if (bitmap & (1 << (*p - 'a'))) { |
Gonglei | 703008e | 2014-12-03 17:11:39 +0000 | [diff] [blame] | 94 | error_setg(errp, "Boot device '%c' was given twice", *p); |
| 95 | return; |
Gonglei | 9816833 | 2014-12-03 16:49:46 +0000 | [diff] [blame] | 96 | } |
| 97 | bitmap |= 1 << (*p - 'a'); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | void restore_boot_order(void *opaque) |
| 102 | { |
| 103 | char *normal_boot_order = opaque; |
| 104 | static int first = 1; |
| 105 | |
| 106 | /* Restore boot order and remove ourselves after the first boot */ |
| 107 | if (first) { |
| 108 | first = 0; |
| 109 | return; |
| 110 | } |
| 111 | |
Gonglei | 76349f5 | 2015-01-29 13:13:47 +0000 | [diff] [blame] | 112 | if (boot_set_handler) { |
| 113 | qemu_boot_set(normal_boot_order, &error_abort); |
| 114 | } |
Gonglei | 9816833 | 2014-12-03 16:49:46 +0000 | [diff] [blame] | 115 | |
| 116 | qemu_unregister_reset(restore_boot_order, normal_boot_order); |
| 117 | g_free(normal_boot_order); |
| 118 | } |
Gonglei | bc74112 | 2014-10-07 16:00:05 +0800 | [diff] [blame] | 119 | |
Gonglei | 694fb85 | 2014-10-07 16:00:06 +0800 | [diff] [blame] | 120 | void check_boot_index(int32_t bootindex, Error **errp) |
| 121 | { |
| 122 | FWBootEntry *i; |
| 123 | |
| 124 | if (bootindex >= 0) { |
| 125 | QTAILQ_FOREACH(i, &fw_boot_order, link) { |
| 126 | if (i->bootindex == bootindex) { |
| 127 | error_setg(errp, "The bootindex %d has already been used", |
| 128 | bootindex); |
| 129 | return; |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | |
Gonglei | 9d27572 | 2014-10-07 16:00:07 +0800 | [diff] [blame] | 135 | void del_boot_device_path(DeviceState *dev, const char *suffix) |
| 136 | { |
| 137 | FWBootEntry *i; |
| 138 | |
| 139 | if (dev == NULL) { |
| 140 | return; |
| 141 | } |
| 142 | |
| 143 | QTAILQ_FOREACH(i, &fw_boot_order, link) { |
| 144 | if ((!suffix || !g_strcmp0(i->suffix, suffix)) && |
| 145 | i->dev == dev) { |
| 146 | QTAILQ_REMOVE(&fw_boot_order, i, link); |
| 147 | g_free(i->suffix); |
| 148 | g_free(i); |
| 149 | |
| 150 | break; |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | |
Gonglei | bc74112 | 2014-10-07 16:00:05 +0800 | [diff] [blame] | 155 | void add_boot_device_path(int32_t bootindex, DeviceState *dev, |
| 156 | const char *suffix) |
| 157 | { |
| 158 | FWBootEntry *node, *i; |
| 159 | |
| 160 | if (bootindex < 0) { |
Gonglei | a598f2f | 2014-10-07 16:00:10 +0800 | [diff] [blame] | 161 | del_boot_device_path(dev, suffix); |
Gonglei | bc74112 | 2014-10-07 16:00:05 +0800 | [diff] [blame] | 162 | return; |
| 163 | } |
| 164 | |
| 165 | assert(dev != NULL || suffix != NULL); |
| 166 | |
Gonglei | e614b54 | 2014-10-07 16:00:09 +0800 | [diff] [blame] | 167 | del_boot_device_path(dev, suffix); |
| 168 | |
Gonglei | bc74112 | 2014-10-07 16:00:05 +0800 | [diff] [blame] | 169 | node = g_malloc0(sizeof(FWBootEntry)); |
| 170 | node->bootindex = bootindex; |
| 171 | node->suffix = g_strdup(suffix); |
| 172 | node->dev = dev; |
| 173 | |
| 174 | QTAILQ_FOREACH(i, &fw_boot_order, link) { |
| 175 | if (i->bootindex == bootindex) { |
Gonglei | 54086fe | 2014-10-07 16:00:38 +0800 | [diff] [blame] | 176 | error_report("Two devices with same boot index %d", bootindex); |
Gonglei | bc74112 | 2014-10-07 16:00:05 +0800 | [diff] [blame] | 177 | exit(1); |
| 178 | } else if (i->bootindex < bootindex) { |
| 179 | continue; |
| 180 | } |
| 181 | QTAILQ_INSERT_BEFORE(i, node, link); |
| 182 | return; |
| 183 | } |
| 184 | QTAILQ_INSERT_TAIL(&fw_boot_order, node, link); |
| 185 | } |
| 186 | |
| 187 | DeviceState *get_boot_device(uint32_t position) |
| 188 | { |
| 189 | uint32_t counter = 0; |
| 190 | FWBootEntry *i = NULL; |
| 191 | DeviceState *res = NULL; |
| 192 | |
| 193 | if (!QTAILQ_EMPTY(&fw_boot_order)) { |
| 194 | QTAILQ_FOREACH(i, &fw_boot_order, link) { |
| 195 | if (counter == position) { |
| 196 | res = i->dev; |
| 197 | break; |
| 198 | } |
| 199 | counter++; |
| 200 | } |
| 201 | } |
| 202 | return res; |
| 203 | } |
| 204 | |
Sam Eiderman | 42f0680 | 2019-10-16 19:41:43 +0300 | [diff] [blame] | 205 | static char *get_boot_device_path(DeviceState *dev, bool ignore_suffixes, |
| 206 | const char *suffix) |
| 207 | { |
| 208 | char *devpath = NULL, *s = NULL, *d, *bootpath; |
| 209 | |
| 210 | if (dev) { |
| 211 | devpath = qdev_get_fw_dev_path(dev); |
| 212 | assert(devpath); |
| 213 | } |
| 214 | |
| 215 | if (!ignore_suffixes) { |
| 216 | if (dev) { |
| 217 | d = qdev_get_own_fw_dev_path_from_handler(dev->parent_bus, dev); |
| 218 | if (d) { |
| 219 | assert(!suffix); |
| 220 | s = d; |
| 221 | } else { |
| 222 | s = g_strdup(suffix); |
| 223 | } |
| 224 | } else { |
| 225 | s = g_strdup(suffix); |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | bootpath = g_strdup_printf("%s%s", |
| 230 | devpath ? devpath : "", |
| 231 | s ? s : ""); |
| 232 | g_free(devpath); |
| 233 | g_free(s); |
| 234 | |
| 235 | return bootpath; |
| 236 | } |
| 237 | |
Gonglei | bc74112 | 2014-10-07 16:00:05 +0800 | [diff] [blame] | 238 | /* |
| 239 | * This function returns null terminated string that consist of new line |
| 240 | * separated device paths. |
| 241 | * |
| 242 | * memory pointed by "size" is assigned total length of the array in bytes |
| 243 | * |
| 244 | */ |
Mark Cave-Ayland | 907aac2 | 2018-08-10 13:40:27 +0100 | [diff] [blame] | 245 | char *get_boot_devices_list(size_t *size) |
Gonglei | bc74112 | 2014-10-07 16:00:05 +0800 | [diff] [blame] | 246 | { |
| 247 | FWBootEntry *i; |
| 248 | size_t total = 0; |
| 249 | char *list = NULL; |
Mark Cave-Ayland | 907aac2 | 2018-08-10 13:40:27 +0100 | [diff] [blame] | 250 | MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine()); |
| 251 | bool ignore_suffixes = mc->ignore_boot_device_suffixes; |
Gonglei | bc74112 | 2014-10-07 16:00:05 +0800 | [diff] [blame] | 252 | |
| 253 | QTAILQ_FOREACH(i, &fw_boot_order, link) { |
Gonglei | 0be6390 | 2015-01-29 15:08:51 +0800 | [diff] [blame] | 254 | char *bootpath; |
Gonglei | bc74112 | 2014-10-07 16:00:05 +0800 | [diff] [blame] | 255 | size_t len; |
| 256 | |
Sam Eiderman | 42f0680 | 2019-10-16 19:41:43 +0300 | [diff] [blame] | 257 | bootpath = get_boot_device_path(i->dev, ignore_suffixes, i->suffix); |
Gonglei | 0be6390 | 2015-01-29 15:08:51 +0800 | [diff] [blame] | 258 | |
Gonglei | bc74112 | 2014-10-07 16:00:05 +0800 | [diff] [blame] | 259 | if (total) { |
| 260 | list[total-1] = '\n'; |
| 261 | } |
| 262 | len = strlen(bootpath) + 1; |
| 263 | list = g_realloc(list, total + len); |
| 264 | memcpy(&list[total], bootpath, len); |
| 265 | total += len; |
| 266 | g_free(bootpath); |
| 267 | } |
| 268 | |
| 269 | *size = total; |
| 270 | |
| 271 | if (boot_strict && *size > 0) { |
| 272 | list[total-1] = '\n'; |
| 273 | list = g_realloc(list, total + 5); |
| 274 | memcpy(&list[total], "HALT", 5); |
| 275 | *size = total + 5; |
| 276 | } |
| 277 | return list; |
| 278 | } |
Gonglei | 12da309 | 2014-10-07 16:00:11 +0800 | [diff] [blame] | 279 | |
| 280 | typedef struct { |
| 281 | int32_t *bootindex; |
| 282 | const char *suffix; |
| 283 | DeviceState *dev; |
| 284 | } BootIndexProperty; |
| 285 | |
Eric Blake | d7bce99 | 2016-01-29 06:48:55 -0700 | [diff] [blame] | 286 | static void device_get_bootindex(Object *obj, Visitor *v, const char *name, |
| 287 | void *opaque, Error **errp) |
Gonglei | 12da309 | 2014-10-07 16:00:11 +0800 | [diff] [blame] | 288 | { |
| 289 | BootIndexProperty *prop = opaque; |
Eric Blake | 51e72bc | 2016-01-29 06:48:54 -0700 | [diff] [blame] | 290 | visit_type_int32(v, name, prop->bootindex, errp); |
Gonglei | 12da309 | 2014-10-07 16:00:11 +0800 | [diff] [blame] | 291 | } |
| 292 | |
Eric Blake | d7bce99 | 2016-01-29 06:48:55 -0700 | [diff] [blame] | 293 | static void device_set_bootindex(Object *obj, Visitor *v, const char *name, |
| 294 | void *opaque, Error **errp) |
Gonglei | 12da309 | 2014-10-07 16:00:11 +0800 | [diff] [blame] | 295 | { |
| 296 | BootIndexProperty *prop = opaque; |
| 297 | int32_t boot_index; |
| 298 | Error *local_err = NULL; |
| 299 | |
Markus Armbruster | 1421703 | 2020-07-07 18:05:47 +0200 | [diff] [blame] | 300 | if (!visit_type_int32(v, name, &boot_index, errp)) { |
| 301 | return; |
Gonglei | 12da309 | 2014-10-07 16:00:11 +0800 | [diff] [blame] | 302 | } |
| 303 | /* check whether bootindex is present in fw_boot_order list */ |
| 304 | check_boot_index(boot_index, &local_err); |
| 305 | if (local_err) { |
| 306 | goto out; |
| 307 | } |
| 308 | /* change bootindex to a new one */ |
| 309 | *prop->bootindex = boot_index; |
| 310 | |
Gonglei | d749e10 | 2014-10-07 16:00:36 +0800 | [diff] [blame] | 311 | add_boot_device_path(*prop->bootindex, prop->dev, prop->suffix); |
| 312 | |
Gonglei | 12da309 | 2014-10-07 16:00:11 +0800 | [diff] [blame] | 313 | out: |
Eduardo Habkost | 621ff94 | 2016-06-13 18:57:56 -0300 | [diff] [blame] | 314 | error_propagate(errp, local_err); |
Gonglei | 12da309 | 2014-10-07 16:00:11 +0800 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | static void property_release_bootindex(Object *obj, const char *name, |
| 318 | void *opaque) |
| 319 | |
| 320 | { |
| 321 | BootIndexProperty *prop = opaque; |
Gonglei | 4aca8a8 | 2014-10-07 16:00:37 +0800 | [diff] [blame] | 322 | |
| 323 | del_boot_device_path(prop->dev, prop->suffix); |
Gonglei | 12da309 | 2014-10-07 16:00:11 +0800 | [diff] [blame] | 324 | g_free(prop); |
| 325 | } |
| 326 | |
| 327 | void device_add_bootindex_property(Object *obj, int32_t *bootindex, |
| 328 | const char *name, const char *suffix, |
Markus Armbruster | 40c2281 | 2020-05-05 17:29:23 +0200 | [diff] [blame] | 329 | DeviceState *dev) |
Gonglei | 12da309 | 2014-10-07 16:00:11 +0800 | [diff] [blame] | 330 | { |
Gonglei | 12da309 | 2014-10-07 16:00:11 +0800 | [diff] [blame] | 331 | BootIndexProperty *prop = g_malloc0(sizeof(*prop)); |
| 332 | |
| 333 | prop->bootindex = bootindex; |
| 334 | prop->suffix = suffix; |
| 335 | prop->dev = dev; |
| 336 | |
| 337 | object_property_add(obj, name, "int32", |
| 338 | device_get_bootindex, |
| 339 | device_set_bootindex, |
| 340 | property_release_bootindex, |
Markus Armbruster | d262312 | 2020-05-05 17:29:22 +0200 | [diff] [blame] | 341 | prop); |
Gonglei | 12da309 | 2014-10-07 16:00:11 +0800 | [diff] [blame] | 342 | |
Gonglei | 12da309 | 2014-10-07 16:00:11 +0800 | [diff] [blame] | 343 | /* initialize devices' bootindex property to -1 */ |
Markus Armbruster | 5325cc3 | 2020-07-07 18:05:54 +0200 | [diff] [blame] | 344 | object_property_set_int(obj, name, -1, NULL); |
Gonglei | 12da309 | 2014-10-07 16:00:11 +0800 | [diff] [blame] | 345 | } |
Sam Eiderman | f7209ea | 2019-10-16 19:41:40 +0300 | [diff] [blame] | 346 | |
| 347 | typedef struct FWLCHSEntry FWLCHSEntry; |
| 348 | |
| 349 | struct FWLCHSEntry { |
| 350 | QTAILQ_ENTRY(FWLCHSEntry) link; |
| 351 | DeviceState *dev; |
| 352 | char *suffix; |
| 353 | uint32_t lcyls; |
| 354 | uint32_t lheads; |
| 355 | uint32_t lsecs; |
| 356 | }; |
| 357 | |
| 358 | static QTAILQ_HEAD(, FWLCHSEntry) fw_lchs = |
| 359 | QTAILQ_HEAD_INITIALIZER(fw_lchs); |
| 360 | |
| 361 | void add_boot_device_lchs(DeviceState *dev, const char *suffix, |
| 362 | uint32_t lcyls, uint32_t lheads, uint32_t lsecs) |
| 363 | { |
| 364 | FWLCHSEntry *node; |
| 365 | |
| 366 | if (!lcyls && !lheads && !lsecs) { |
| 367 | return; |
| 368 | } |
| 369 | |
| 370 | assert(dev != NULL || suffix != NULL); |
| 371 | |
| 372 | node = g_malloc0(sizeof(FWLCHSEntry)); |
| 373 | node->suffix = g_strdup(suffix); |
| 374 | node->dev = dev; |
| 375 | node->lcyls = lcyls; |
| 376 | node->lheads = lheads; |
| 377 | node->lsecs = lsecs; |
| 378 | |
| 379 | QTAILQ_INSERT_TAIL(&fw_lchs, node, link); |
| 380 | } |
| 381 | |
| 382 | void del_boot_device_lchs(DeviceState *dev, const char *suffix) |
| 383 | { |
| 384 | FWLCHSEntry *i; |
| 385 | |
| 386 | if (dev == NULL) { |
| 387 | return; |
| 388 | } |
| 389 | |
| 390 | QTAILQ_FOREACH(i, &fw_lchs, link) { |
| 391 | if ((!suffix || !g_strcmp0(i->suffix, suffix)) && |
| 392 | i->dev == dev) { |
| 393 | QTAILQ_REMOVE(&fw_lchs, i, link); |
| 394 | g_free(i->suffix); |
| 395 | g_free(i); |
| 396 | |
| 397 | break; |
| 398 | } |
| 399 | } |
| 400 | } |
Sam Eiderman | aea60a1 | 2019-10-16 19:41:44 +0300 | [diff] [blame] | 401 | |
| 402 | char *get_boot_devices_lchs_list(size_t *size) |
| 403 | { |
| 404 | FWLCHSEntry *i; |
| 405 | size_t total = 0; |
| 406 | char *list = NULL; |
| 407 | |
| 408 | QTAILQ_FOREACH(i, &fw_lchs, link) { |
| 409 | char *bootpath; |
| 410 | char *chs_string; |
| 411 | size_t len; |
| 412 | |
| 413 | bootpath = get_boot_device_path(i->dev, false, i->suffix); |
| 414 | chs_string = g_strdup_printf("%s %" PRIu32 " %" PRIu32 " %" PRIu32, |
| 415 | bootpath, i->lcyls, i->lheads, i->lsecs); |
| 416 | |
| 417 | if (total) { |
| 418 | list[total - 1] = '\n'; |
| 419 | } |
| 420 | len = strlen(chs_string) + 1; |
| 421 | list = g_realloc(list, total + len); |
| 422 | memcpy(&list[total], chs_string, len); |
| 423 | total += len; |
| 424 | g_free(chs_string); |
| 425 | g_free(bootpath); |
| 426 | } |
| 427 | |
| 428 | *size = total; |
| 429 | |
| 430 | return list; |
| 431 | } |