static void insert_bootpath (void) { char *bootpath; grub_ssize_t bootpath_size; char *type; if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "bootpath", &bootpath_size) || bootpath_size <= 0) { /* Should never happen. */ grub_printf ("/chosen/bootpath property missing!\n"); return; } bootpath = (char *) grub_malloc ((grub_size_t) bootpath_size + 64); if (! bootpath) { grub_print_error (); return; } grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", bootpath, (grub_size_t) bootpath_size + 1, 0); bootpath[bootpath_size] = '\0'; /* Transform an OF device path to a GRUB path. */ type = grub_ieee1275_get_device_type (bootpath); if (!(type && grub_strcmp (type, "network") == 0)) { struct ofdisk_hash_ent *op; char *device = grub_ieee1275_get_devname (bootpath); op = ofdisk_hash_add (device, NULL); op->is_boot = 1; } grub_free (type); grub_free (bootpath); }
void grub_machine_get_bootlocation (char **device, char **path) { char *bootpath; grub_ssize_t bootpath_size; char *filename; char *type; if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, "bootpath", &bootpath_size) || bootpath_size <= 0) { /* Should never happen. */ grub_printf ("/chosen/bootpath property missing!\n"); return; } bootpath = (char *) grub_malloc ((grub_size_t) bootpath_size + 64); if (! bootpath) { grub_print_error (); return; } grub_ieee1275_get_property (grub_ieee1275_chosen, "bootpath", bootpath, (grub_size_t) bootpath_size + 1, 0); bootpath[bootpath_size] = '\0'; /* Transform an OF device path to a GRUB path. */ type = grub_ieee1275_get_device_type (bootpath); if (type && grub_strcmp (type, "network") == 0) { char *dev, *canon; char *ptr; dev = grub_ieee1275_get_aliasdevname (bootpath); canon = grub_ieee1275_canonicalise_devname (dev); ptr = canon + grub_strlen (canon) - 1; while (ptr > canon && (*ptr == ',' || *ptr == ':')) ptr--; ptr++; *ptr = 0; if (grub_ieee1275_net_config) grub_ieee1275_net_config (canon, device, path, bootpath); grub_free (dev); grub_free (canon); } else *device = grub_ieee1275_encode_devname (bootpath); grub_free (type); filename = grub_ieee1275_get_filename (bootpath); if (filename) { char *lastslash = grub_strrchr (filename, '\\'); /* Truncate at last directory. */ if (lastslash) { *lastslash = '\0'; grub_translate_ieee1275_path (filename); *path = filename; } } grub_free (bootpath); }