/* Convert a device name from IEEE1275 syntax to GRUB syntax. */ char * grub_ieee1275_encode_devname (const char *path) { char *device = grub_ieee1275_get_devname (path); char *partition = grub_ieee1275_parse_args (path, GRUB_PARSE_PARTITION); char *encoding; if (partition) { unsigned int partno = grub_strtoul (partition, 0, 0); if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS)) /* GRUB partition 1 is OF partition 0. */ partno++; /* Assume partno will require less than five bytes to encode. */ encoding = grub_malloc (grub_strlen (device) + 3 + 5); grub_sprintf (encoding, "(%s,%d)", device, partno); } else { encoding = grub_malloc (grub_strlen (device) + 2); grub_sprintf (encoding, "(%s)", device); } grub_free (partition); grub_free (device); return encoding; }
/* Convert a device name from IEEE1275 syntax to GRUB syntax. */ char * grub_ieee1275_encode_devname (const char *path) { char *device = grub_ieee1275_get_devname (path); char *partition = grub_ieee1275_parse_args (path, GRUB_PARSE_PARTITION); char *encoding; if (partition && partition[0]) { unsigned int partno = grub_strtoul (partition, 0, 0); if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS)) /* GRUB partition 1 is OF partition 0. */ partno++; encoding = grub_xasprintf ("(%s,%d)", device, partno); } else encoding = grub_xasprintf ("(%s)", device); grub_free (partition); grub_free (device); return encoding; }
char * grub_ieee1275_get_filename (const char *path) { return grub_ieee1275_parse_args (path, GRUB_PARSE_FILENAME); }
char * grub_ieee1275_get_aliasdevname (const char *path) { return grub_ieee1275_parse_args (path, GRUB_PARSE_DEVICE); }
char * grub_ieee1275_get_device_type (const char *path) { return grub_ieee1275_parse_args (path, GRUB_PARSE_DEVICE_TYPE); }