* why store the search type in the ieee name field?
@ 2003-02-10 22:45 Steven Dake
2003-02-10 23:12 ` James Bottomley
0 siblings, 1 reply; 6+ messages in thread
From: Steven Dake @ 2003-02-10 22:45 UTC (permalink / raw)
To: linux-scsi
Folks,
I was wondering the reasoning behind the code
scsi_scan:734
/*
* All OK - store ID
*/
name[0] = hex_str[id_search->id_type];
This corrupts a perfectly good IEEE unique identifier (WWN for FC
drives). Is there some usage for this in user space?
Thanks
-steve
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: why store the search type in the ieee name field?
2003-02-10 22:45 why store the search type in the ieee name field? Steven Dake
@ 2003-02-10 23:12 ` James Bottomley
2003-02-11 16:20 ` Patrick Mansfield
0 siblings, 1 reply; 6+ messages in thread
From: James Bottomley @ 2003-02-10 23:12 UTC (permalink / raw)
To: Steven Dake; +Cc: SCSI Mailing List
On Mon, 2003-02-10 at 16:45, Steven Dake wrote:
> Folks,
>
> I was wondering the reasoning behind the code
>
> scsi_scan:734
> /*
> * All OK - store ID
> */
> name[0] = hex_str[id_search->id_type];
>
> This corrupts a perfectly good IEEE unique identifier (WWN for FC
> drives). Is there some usage for this in user space?
Erm, it's appending the type to the beginning of the name string
(although it does seem to be relying on the sysfs name field being zero
filled). I don't see any corruption since the inquiry fields and unique
name name follows this byte.
You get the identifier it found from the sysfs name file for the
device. The first byte tells you what type of unique name you're
dealing with.
James
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: why store the search type in the ieee name field?
2003-02-10 23:12 ` James Bottomley
@ 2003-02-11 16:20 ` Patrick Mansfield
2003-02-11 16:43 ` James Bottomley
0 siblings, 1 reply; 6+ messages in thread
From: Patrick Mansfield @ 2003-02-11 16:20 UTC (permalink / raw)
To: James Bottomley; +Cc: Steven Dake, SCSI Mailing List
On Mon, Feb 10, 2003 at 05:12:54PM -0600, James Bottomley wrote:
> On Mon, 2003-02-10 at 16:45, Steven Dake wrote:
> > Folks,
> >
> > I was wondering the reasoning behind the code
> >
> > scsi_scan:734
> > /*
> > * All OK - store ID
> > */
> > name[0] = hex_str[id_search->id_type];
> >
> > This corrupts a perfectly good IEEE unique identifier (WWN for FC
> > drives). Is there some usage for this in user space?
>
> Erm, it's appending the type to the beginning of the name string
> (although it does seem to be relying on the sysfs name field being zero
> filled). I don't see any corruption since the inquiry fields and unique
> name name follows this byte.
It should fill in the rest of the 'name' and append a '\0', or return a
failure.
> You get the identifier it found from the sysfs name file for the
> device. The first byte tells you what type of unique name you're
> dealing with.
>
> James
And the identifiers are not unique across different identifier types, so
it has to store the id_type in order to have unique identifiers (at least
for scsi) across all types: for example, a vendor specific id could be the
same as a NAA (IEEE) id.
-- Patrick Mansfield
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: why store the search type in the ieee name field?
2003-02-11 16:20 ` Patrick Mansfield
@ 2003-02-11 16:43 ` James Bottomley
2003-02-11 16:46 ` Patrick Mansfield
2003-02-11 17:38 ` Steven Dake
0 siblings, 2 replies; 6+ messages in thread
From: James Bottomley @ 2003-02-11 16:43 UTC (permalink / raw)
To: Patrick Mansfield; +Cc: Steven Dake, SCSI Mailing List
On Tue, 2003-02-11 at 10:20, Patrick Mansfield wrote:
> On Mon, Feb 10, 2003 at 05:12:54PM -0600, James Bottomley wrote:
> > Erm, it's appending the type to the beginning of the name string
> > (although it does seem to be relying on the sysfs name field being zero
> > filled). I don't see any corruption since the inquiry fields and unique
> > name name follows this byte.
>
> It should fill in the rest of the 'name' and append a '\0', or return a
> failure.
No, look at the code. After doing name[0] = hex_str[...
it then does a strcat. If name is full of junk, strcat will append
after the first \0 it finds (which may be off the end of the name
field). It only works because name[1] is zero but nothing seems to
clear it. I'm hoping it's being cleared in a piece of code I haven't
found yet...
James
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: why store the search type in the ieee name field?
2003-02-11 16:43 ` James Bottomley
@ 2003-02-11 16:46 ` Patrick Mansfield
2003-02-11 17:38 ` Steven Dake
1 sibling, 0 replies; 6+ messages in thread
From: Patrick Mansfield @ 2003-02-11 16:46 UTC (permalink / raw)
To: James Bottomley; +Cc: Steven Dake, SCSI Mailing List
On Tue, Feb 11, 2003 at 10:43:57AM -0600, James Bottomley wrote:
> No, look at the code. After doing name[0] = hex_str[...
> it then does a strcat. If name is full of junk, strcat will append
> after the first \0 it finds (which may be off the end of the name
> field). It only works because name[1] is zero but nothing seems to
> clear it. I'm hoping it's being cleared in a piece of code I haven't
> found yet...
>
> James
Yes - there's a memset() in scsi_load_identifier, plus on error some of
the fields are re-zeroed (a bit ugly).
-- Patrick Mansfield
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: why store the search type in the ieee name field?
2003-02-11 16:43 ` James Bottomley
2003-02-11 16:46 ` Patrick Mansfield
@ 2003-02-11 17:38 ` Steven Dake
1 sibling, 0 replies; 6+ messages in thread
From: Steven Dake @ 2003-02-11 17:38 UTC (permalink / raw)
To: James Bottomley; +Cc: Patrick Mansfield, SCSI Mailing List
When I looked at this code originally, it looked correct, I was just
wondering why have an identifier field. I understand the reasoning now.
Thanks
-steve
James Bottomley wrote:
>On Tue, 2003-02-11 at 10:20, Patrick Mansfield wrote:
>
>
>>On Mon, Feb 10, 2003 at 05:12:54PM -0600, James Bottomley wrote:
>>
>>
>>>Erm, it's appending the type to the beginning of the name string
>>>(although it does seem to be relying on the sysfs name field being zero
>>>filled). I don't see any corruption since the inquiry fields and unique
>>>name name follows this byte.
>>>
>>>
>>It should fill in the rest of the 'name' and append a '\0', or return a
>>failure.
>>
>>
>
>No, look at the code. After doing name[0] = hex_str[...
>it then does a strcat. If name is full of junk, strcat will append
>after the first \0 it finds (which may be off the end of the name
>field). It only works because name[1] is zero but nothing seems to
>clear it. I'm hoping it's being cleared in a piece of code I haven't
>found yet...
>
>James
>
>
>
>
>
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-02-11 17:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-10 22:45 why store the search type in the ieee name field? Steven Dake
2003-02-10 23:12 ` James Bottomley
2003-02-11 16:20 ` Patrick Mansfield
2003-02-11 16:43 ` James Bottomley
2003-02-11 16:46 ` Patrick Mansfield
2003-02-11 17:38 ` Steven Dake
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox