Bug 236393

Summary: sysutils/sg3_utils After update to 1.44 relative path of device is no longer accepted
Product: Ports & Packages Reporter: Andrew <andrew.hotlab>
Component: Individual Port(s)Assignee: Dmitry Marakasov <amdmi3>
Status: Closed Works As Intended    
Severity: Affects Many People CC: dgilbert, w.schwarzenfeld
Priority: --- Flags: bugzilla: maintainer-feedback?
Version: Latest   
Hardware: Any   
OS: Any   

Description Andrew 2019-03-08 14:05:26 UTC
I do not know if it is the intended behavior from now on, but after the latest upgrade (from 1.42 to 1.44), sg3_utils commands do not take for granted the "/dev" prefix any longer in the device name parameter. This broke some scripts of ours which leverage the sg_persist(8) command.

Here is an example transcript:

# sg_persist -V
version: 0.52 20160201
# sg_persist -i -s da0
  FREEBSD   CTLDISK           0001
  Peripheral device type: disk
  PR generation=0x9
    Key=0x223220250
      All target ports bit clear
      Relative port address: 0x6
      << Reservation holder >>
      scope: LU_SCOPE,  type: Write Exclusive
      Transport Id of initiator:
        iSCSI world wide unique port id: iqn.1994-09.org.freebsd:xxx.xxx.xxx,i,0x80118193bc0b

# sg_persist -V
version: 0.66 20180615
# sg_persist -i -s da0
scsi_pt_open_flags: unable to stat(da0): No such file or directory
sg_persist: error opening file (ro): da0: No such file or directory


I examined the changelog (https://github.com/hreinecke/sg3_utils/blob/master/ChangeLog), but I didn't find anything about this.
Comment 1 Walter Schwarzenfeld freebsd_triage 2019-08-14 11:13:00 UTC
Maintainer feedback, please !
Comment 2 Andrew 2019-10-12 16:48:02 UTC
Since we noticed that sg_persist(8) coming from version 1.44 of sg3_utils also presented another issue (it does not seem to be able to register a disk device ignoring any previous registration key), we just gave up to use it and changed our code to use camcontrol(8), which is integrated in FreeBSD base.

Since we do not make use of this port anymore, we are not directly interested in its behavior. Still waiting a little more for maintainer's feedback before closing this PR.
Comment 3 Dmitry Marakasov freebsd_committer freebsd_triage 2021-02-16 17:03:17 UTC
Judging by the code, this behavior is at least explainable, as there's stat(2) call on device name passed as-is:

https://github.com/hreinecke/sg3_utils/blob/d82f040c69689305ca1d318d3dc0e1e42ab6ffa3/lib/sg_pt_freebsd.c#L185

This behavior was likely introduced in this commit:
 
https://github.com/hreinecke/sg3_utils/commit/d44a4b8fa5fe56394c4299b5af714409ff64f13b#diff-c606bb382809d352875315e606f67881c0ef7a277a51c9a67b7523f897ad3a9aR150

It worked before because there was no stat(2) call and device name was passed right to cam_get_device(3) which performs additional parsing. This may be an upstream bug, reported as https://github.com/hreinecke/sg3_utils/issues/65.

Since it's not really related to the port, submitter is no longer interested in a fix and there's no maintainer, closing this PR.
Comment 4 Douglas Gilbert 2021-02-22 20:01:48 UTC
I have changed sg_pt_freebsd.c to accept the abridged device name form that was broken by the addition of the stat(2) system call that appeared in version 1.43 . The fix is in svn rev 877 and can be found at https://github.com/doug-gilbert/sg3_utils/tree/master/trunk . Version 1.46 will be released soon and will include this fix.
Comment 5 Andrew 2021-02-22 20:56:20 UTC
(In reply to Douglas Gilbert from comment #4)
Thank you! Although we are no longer using this port, I think it is useful to maintain it active and up to date.