Re: [RFC PATCH v2 7/7] nvme: Add durable name for dev_printk

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

 



On Thu, May 14, 2020 at 12:13:36PM -0500, Tony Asleson wrote:
> On 5/13/20 6:04 PM, Keith Busch wrote:
> > On Wed, May 13, 2020 at 04:36:21PM -0500, Tony Asleson wrote:
> >> +static int dev_to_nvme_durable_name(const struct device *dev, char *buf, size_t len)
> >> +{
> >> +	char serial[128];
> >> +	ssize_t serial_len = wwid_show((struct device *)dev, NULL, serial);
> > 
> > wwid_show() can generate a serial larger than 128 bytes.
> 
> Looking at this again
> 
> return sprintf(buf, "nvme.%04x-%*phN-%*phN-%08x\n", 	
>     subsys->vendor_id,
>     serial_len, subsys->serial,
>     model_len, subsys->model,
>     subsys->ns_id);
> 
> 'nvme.' = 5
> vendor_id = 4
> '-' = 1
> serial (20 * 2) = 40
> '-' = 1
> model (40 * 2) = 80
> '-' = 1
> ns_id = 8
> '\n' = 1
> 
> 5 + 4 + 1 + 40 + 1 + 80 + 1 + 8 + 1 = 141
> 
> Does this match your understanding?

Yep, that looks like the correct max possible length. I didn't actually
count it out, but I just knew it could be larger than 128. :)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux