* grub-core/kern/partition.c (grub_partition_get_name): Fix reverse
iteration of partitions.
This commit is contained in:
parent
9c4b5c13e6
commit
0e1c1f61b6
2 changed files with 23 additions and 7 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2012-02-08 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
* grub-core/kern/partition.c (grub_partition_get_name): Fix reverse
|
||||||
|
iteration of partitions.
|
||||||
|
|
||||||
2012-02-08 Vladimir Serbinenko <phcoder@gmail.com>
|
2012-02-08 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
Improve gettext support. Stylistic fixes and error handling fixes while
|
Improve gettext support. Stylistic fixes and error handling fixes while
|
||||||
|
|
|
@ -224,22 +224,33 @@ char *
|
||||||
grub_partition_get_name (const grub_partition_t partition)
|
grub_partition_get_name (const grub_partition_t partition)
|
||||||
{
|
{
|
||||||
char *out = 0, *ptr;
|
char *out = 0, *ptr;
|
||||||
grub_size_t needlen = 0;
|
grub_size_t needlen;
|
||||||
grub_partition_t part;
|
grub_partition_t part;
|
||||||
|
if (!partition)
|
||||||
|
return grub_strdup ("");
|
||||||
for (part = partition; part; part = part->parent)
|
for (part = partition; part; part = part->parent)
|
||||||
/* Even on 64-bit machines this buffer is enough to hold
|
/* Even on 64-bit machines this buffer is enough to hold
|
||||||
longest number. */
|
longest number. */
|
||||||
needlen += grub_strlen (part->partmap->name) + 27;
|
needlen += grub_strlen (part->partmap->name) + 1 + 27;
|
||||||
out = grub_malloc (needlen);
|
out = grub_malloc (needlen + 1);
|
||||||
if (!out)
|
if (!out)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ptr = out;
|
ptr = out + needlen;
|
||||||
|
*ptr = 0;
|
||||||
for (part = partition; part; part = part->parent)
|
for (part = partition; part; part = part->parent)
|
||||||
{
|
{
|
||||||
grub_snprintf (ptr, needlen - (out - ptr), "%s%d", part->partmap->name,
|
char buf[27];
|
||||||
part->number + 1);
|
grub_size_t len;
|
||||||
ptr += grub_strlen (ptr);
|
grub_snprintf (buf, sizeof (buf), "%d", part->number + 1);
|
||||||
|
len = grub_strlen (buf);
|
||||||
|
ptr -= len;
|
||||||
|
grub_memcpy (ptr, buf, len);
|
||||||
|
len = grub_strlen (part->partmap->name);
|
||||||
|
ptr -= len;
|
||||||
|
grub_memcpy (ptr, part->partmap->name, len);
|
||||||
|
*--ptr = ',';
|
||||||
}
|
}
|
||||||
|
grub_memmove (out, ptr + 1, out + needlen - ptr);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue