2009-04-22 09:57:39 +00:00
|
|
|
#include <stdio.h>
|
2009-05-04 23:13:53 +00:00
|
|
|
#include <string.h>
|
2009-04-22 09:57:39 +00:00
|
|
|
#include <grub/types.h>
|
|
|
|
#include <grub/util/deviceiter.h>
|
|
|
|
#include <grub/util/ofpath.h>
|
2009-05-04 23:13:53 +00:00
|
|
|
#include <grub/util/misc.h>
|
|
|
|
|
|
|
|
/* Since OF path names can have "," characters in them, and GRUB
|
|
|
|
internally uses "," to indicate partitions (unlike OF which uses
|
|
|
|
":" for this purpose) we escape such commas. */
|
|
|
|
|
|
|
|
static char *
|
|
|
|
escape_of_path (const char *orig_path)
|
|
|
|
{
|
|
|
|
char *new_path, *d, c;
|
|
|
|
const char *p;
|
|
|
|
|
|
|
|
if (!strchr (orig_path, ','))
|
|
|
|
return (char *) orig_path;
|
|
|
|
|
|
|
|
new_path = xmalloc (strlen (orig_path) * 2);
|
|
|
|
|
|
|
|
p = orig_path;
|
|
|
|
d = new_path;
|
|
|
|
while ((c = *p++) != '\0')
|
|
|
|
{
|
|
|
|
if (c == ',')
|
|
|
|
*d++ = '\\';
|
|
|
|
*d++ = c;
|
|
|
|
}
|
|
|
|
|
|
|
|
free ((char *) orig_path);
|
|
|
|
|
|
|
|
return new_path;
|
|
|
|
}
|
2009-04-22 09:57:39 +00:00
|
|
|
|
|
|
|
void
|
2009-12-20 13:09:16 +00:00
|
|
|
grub_util_emit_devicemap_entry (FILE *fp, char *name,
|
|
|
|
int is_floppy __attribute__((unused)),
|
|
|
|
int *num_fd __attribute__((unused)),
|
|
|
|
int *num_hd __attribute__((unused)))
|
2009-04-22 09:57:39 +00:00
|
|
|
{
|
2009-05-04 23:13:53 +00:00
|
|
|
const char *orig_path = grub_util_devname_to_ofpath (name);
|
|
|
|
char *ofpath = escape_of_path (orig_path);
|
2009-04-22 09:57:39 +00:00
|
|
|
|
|
|
|
fprintf(fp, "(%s)\t%s\n", ofpath, name);
|
2009-05-04 23:13:53 +00:00
|
|
|
|
|
|
|
free (ofpath);
|
2009-04-22 09:57:39 +00:00
|
|
|
}
|