hreinecke / sg3_utils

Deprecated git-svn mirror for sg3_utils

Home Page:http://sg.danny.cz/sg/sg3_utils.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possible regression in sg_pt_freebsd.c:scsi_pt_open_flags()

AMDmi3 opened this issue · comments

This was reported long time ago in FreeBSD bug tracker, user complains that sg_persist -i -s da0 (e.g. called on device name as opposed to full path /dev/da0) stopped working after update from 1.42 to 1.44. This may be a regression introduced by d82f040, there's now a stat(2) call on a specified path:

if (stat(device_name, &a_stat) < 0) {

which requires a valid path, however the device name is later passed to cam_get_device(3) which performs additional parsing

     cam_get_device() takes a path argument containing a string with a device
     name followed by a unit number.  It then breaks the string down into a
     device name and unit number, and passes them back in dev_name and unit,
     respectively.  cam_get_device() can handle strings of the following
     forms, at least:

     /dev/foo1
     foo0
     nsa2

     cam_get_device() is provided as a convenience function for applications
     that need to provide functionality similar to cam_open_device().

My guess here is that the current logic which expects raw path no longer allows to specify a unit number, and maybe cam_get_device should be called early to split dev name first which can be then passed to stat and other checks.

Note that I don't use sg3_utils, just conveying a potential problem.

Thanks for the report. I will try to undo the regression. The fix should be in svn revision 877 and it the soon to be released sg3_utils-1.46 .