bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GPT name overflow


From: Richard Hirst
Subject: Re: GPT name overflow
Date: Mon, 18 Mar 2002 15:56:12 +0000
User-agent: Mutt/1.3.24i

On Sun, Mar 10, 2002 at 02:40:02PM -0700, Andreas Dilger wrote:
> +static int
> +bsd_partition_set_type_name (const PedPartition* part, const char* name)
> +{
> +     int ret = 0;
> +
> +     if (part && name) {
> +             BSDPartitionData*       bsd_part_data = part->disk_specific;
> +             BSDPartitionTypeName*   tmp;
> +
> +             if (!strcmp(name, "type-")) {

In several places that needs to be strncmp()

> +                     if (isdigit(name[5])) {
> +                             bsd_part_data->type = name[5] - '0';

Decimal conversion of type, see below..

> +                             ret = 1;
> +                     }
> +             } else if ((tmp = _bsd_partition_find_type_name(name))) {
> +                     bsd_part_data->type = tmp->type;
> +                     ret = 1;
> +             }
> +     }
> +
> +     return ret;
> +}
> +
> +static const char *
> +bsd_partition_get_type_name (const PedPartition* part)
> +{
> +     static char             type_name[42];
> +     const char*             ret = NULL;
> +
> +     if (part) {
> +             BSDPartitionData*       bsd_part_data = part->disk_specific;
> +             BSDPartitionTypeName*   tmp;
> +
> +             tmp = _bsd_partition_find_type_id(bsd_part_data->type);
> +
> +             if (tmp)
> +                     ret = tmp->name;
> +             else {
> +                     sprintf(type_name, "type-%x", bsd_part_data->type);

hex conversion of type..

hex/dec may not matter; I don't know bsd.

API docs also need to note that the string returned from
partition_get_type_name() is only valid until such time as someone calls
the function again.

>From a UI point of view, we would presumably need some way of querying
each disk_*.c module for it's supported type names.

Richard




reply via email to

[Prev in Thread] Current Thread [Next in Thread]