[illumos-Developer] Webrev for bug 561: Strange characters when executing "format"

Gary Mills mills at cc.umanitoba.ca
Sat Jul 9 19:13:32 PDT 2011


On Fri, Jul 08, 2011 at 03:41:09PM -0500, Gary Mills wrote:
> On Fri, Jul 08, 2011 at 08:08:13AM -0700, Garrett D'Amore wrote:
> > 
> >    Oh right, strncpy vs strlcpy.   Ick.  I hate the non terminating
> >    behavior of strncpy.
> 
> The more I stare at the code just below my change, the more I see
> that it can't possibly work.  This is it, introduced in changeset
> 12610,5daa5746f6ae to fix Opensolaris bug #6957124:
> 
> 	(void) strncpy(p, inquiry.inq_vid, sizeof (inquiry.inq_vid));
> 	p += sizeof (inquiry.inq_vid) - 1;
> 	*p++ = '-';
> 	p = strncpy(p, inquiry.inq_pid, sizeof (inquiry.inq_pid));
> 	p += sizeof (inquiry.inq_pid) - 1;
> 	*p++ = '-';
> 	p = strncpy(p, inquiry.inq_revision, sizeof (inquiry.inq_revision));
> 
> The three values in the inquiry data are space-padded in fixed-length
> fields, not null terminated.  The code to create a disk name from this
> data already exists as the get_generic_disk_name() function in the
> `format' source.  I'll be posting a new webrev soon with this function
> substituted.  Unfortunately, I can't test it, but it pretty well has
> to work.

My new webrev is at:

    http://cr.illumos.org/view/4z5nj2vk/illumos561-1/

It now uses the internal function get_generic_disk_name() to format
the label for display.  As well, it now only prints the `Inquiry
failed' message if you supply the `-m' option of the format command.
This is reasonable because the USCSI ioctl will always fail when the
disk does not appear as a SCSI disk.  In that case, it will display
the disk type as `Unknown-Unknown-0001', but `format' will still work
normally.  From reading the source, I can't tell when, if ever, the
rest of get_disk_name() will be executed.  That's why I can't test
that code path,

-- 
-Gary Mills-        -Unix Group-        -Computer and Network Services-



More information about the Developer mailing list