[parted-devel] [PATCH v2] Read NVMe model names from sysfs

dann frazier dann.frazier at canonical.com
Wed Sep 26 21:44:04 BST 2018


Hi - any further comments on this one?

On Fri, Sep 7, 2018 at 1:31 PM dann frazier <dann.frazier at canonical.com> wrote:
>
> parted currently shows the same generic model name for all NVMe devices:
>
>   # parted /dev/nvme0n1 -s print | grep Model
>   Model: NVMe Device (nvme)
>
> If the model information is available in sysfs, display that instead:
>
>   # parted /dev/nvme0n1 -s print | grep Model
>   Model: THNSN5512GPU7 NVMe TOSHIBA 512GB (nvme)
> ---
>  libparted/arch/linux.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
> index 02d7a52c..7d83dfbb 100644
> --- a/libparted/arch/linux.c
> +++ b/libparted/arch/linux.c
> @@ -1405,6 +1405,22 @@ init_sdmmc (PedDevice* dev)
>          return init_generic(dev, id);
>  }
>
> +static int
> +init_nvme (PedDevice* dev)
> +{
> +        int ret;
> +        char *model = read_device_sysfs_file (dev, "model");
> +
> +        if (!model)
> +                ret = init_generic (dev, _("NVMe Device"));
> +        else {
> +                ret = init_generic (dev, model);
> +                free (model);
> +        }
> +
> +        return ret;
> +}
> +
>  static PedDevice*
>  linux_new (const char* path)
>  {
> @@ -1489,7 +1505,7 @@ linux_new (const char* path)
>                  break;
>
>          case PED_DEVICE_NVME:
> -                if (!init_generic (dev, _("NVMe Device")))
> +                if (!init_nvme (dev))
>                          goto error_free_arch_specific;
>                  break;
>
> --
> 2.19.0.rc2
>



More information about the parted-devel mailing list