aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--debian/changelog2
-rw-r--r--doc/sg3_utils.87
-rw-r--r--lib/sg_pt_freebsd.c37
-rw-r--r--sg3_utils.spec2
5 files changed, 36 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 1405135e..d7aec470 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,7 @@ Each utility has its own version number, date of last change and
some description at the top of its ".c" file. All utilities in the main
directory have their own "man" pages. There is also a sg3_utils man page.
-Changelog for pre-release sg3_utils-1.46 [20210219] [svn: r876]
+Changelog for pre-release sg3_utils-1.46 [20210222] [svn: r877]
- sg_rep_pip: report new provisioning initialization pattern cmd
- sg_turs: estimated time-to-ready [20-061r2]
- add --delay=MS option
@@ -31,6 +31,8 @@ Changelog for pre-release sg3_utils-1.46 [20210219] [svn: r876]
- add --nvm option to send commands from the NVM command set
- add --cmdset option to bypass cdb heuristic
- add --scan= first_opcode,last_opcode
+ - sg_pt_freebsd: allow device names without leading /dev/
+ fix for regression introduced in rev 731 (ver: 1.43)
- sg_pt_solaris+sg_pt_osf1: fix problem with clear_scsi_pt_obj()
which needs to remember is_nvme and dev_fd values
- sg_lib: restore elements and rebuild command added
diff --git a/debian/changelog b/debian/changelog
index e5d0e7cb..c4e8106d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,7 @@ sg3-utils (1.46-0.1) unstable; urgency=low
* New upstream version
- -- Douglas Gilbert <dgilbert@interlog.com> Mon, 15 Feb 2021 10:00:00 -0500
+ -- Douglas Gilbert <dgilbert@interlog.com> Mon, 22 Feb 2021 15:00:00 -0500
sg3-utils (1.45-0.1) unstable; urgency=low
diff --git a/doc/sg3_utils.8 b/doc/sg3_utils.8
index 738391bc..38a2481e 100644
--- a/doc/sg3_utils.8
+++ b/doc/sg3_utils.8
@@ -192,6 +192,13 @@ corresponding pass\-through device name of the form /dev/pass<num>
where <num> is an integer starting at zero. The "camcontrol devlist"
command may be useful for finding out which SCSI device names are
available and the correspondence between class and pass\-through names.
+.PP
+FreeBSD allows device names to be given without the leading "/dev/" (e.g.
+da0 instead of /dev/da0). That worked in this package up until version
+1.43 when the unadorned device name (e.g. "da0") gave an error. The
+original action (i.e. allowing unadorned device names) has been restored
+in version 1.46 . Also note that symlinks (to device names) are followed
+before prepending "/dev/" if the resultant name doesn't start with a "/".
.SH SOLARIS DEVICE NAMING
SCSI device names below the /dev directory have a form like: c5t4d3s2
where the number following "c" is the controller (HBA) number, the number
diff --git a/lib/sg_pt_freebsd.c b/lib/sg_pt_freebsd.c
index 7c258f9e..180b582d 100644
--- a/lib/sg_pt_freebsd.c
+++ b/lib/sg_pt_freebsd.c
@@ -7,7 +7,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-/* sg_pt_freebsd version 1.37 20210102 */
+/* sg_pt_freebsd version 1.38 20210221 */
#include <stdio.h>
#include <stdlib.h>
@@ -159,7 +159,7 @@ int
scsi_pt_open_flags(const char * device_name, int oflags, int vb)
{
bool is_char, is_block, possible_nvme;
- char tmp;
+ char tmp, first_ch;
int k, err, dev_fd, ret;
uint32_t nsid, nv_ctrlid;
ssize_t s;
@@ -167,7 +167,7 @@ scsi_pt_open_flags(const char * device_name, int oflags, int vb)
struct cam_device* cam_dev;
struct stat a_stat;
char b[PATH_MAX];
- char full_path[64];
+ char dev_nm[PATH_MAX];
// Search table for a free entry
for (k = 0; k < FREEBSD_MAXDEV; k++)
@@ -182,9 +182,25 @@ scsi_pt_open_flags(const char * device_name, int oflags, int vb)
ret = -EMFILE;
goto err_out;
}
- if (stat(device_name, &a_stat) < 0) {
+ first_ch = device_name[0];
+ if (('/' != first_ch) && ('.' != first_ch)) {
+ /* Step 1: if device_name is symlink, follow it */
+ s = readlink(device_name, b, sizeof(b));
+ if (s <= 0) {
+ strncpy(b, device_name, PATH_MAX - 1);
+ b[PATH_MAX - 1] = '\0';
+ }
+ /* Step 2: if no leading '/' nor '.' given, prepend '/dev/' */
+ first_ch = b[0];
+ if (('/' != first_ch) && ('.' != first_ch))
+ snprintf(dev_nm, PATH_MAX, "%s%s", "/dev/", b);
+ else
+ strcpy(dev_nm, b);
+ } else
+ strcpy(dev_nm, device_name);
+ if (stat(dev_nm, &a_stat) < 0) {
err = errno;
- pr2ws("%s: unable to stat(%s): %s\n", __func__, device_name,
+ pr2ws("%s: unable to stat(%s): %s\n", __func__, dev_nm,
strerror(err));
ret = -err;
goto err_out;
@@ -194,15 +210,10 @@ scsi_pt_open_flags(const char * device_name, int oflags, int vb)
if (! (is_block || is_char)) {
if (vb)
pr2ws("%s: %s is not char nor block device\n", __func__,
- device_name);
+ dev_nm);
ret = -ENODEV;
goto err_out;
}
- s = readlink(device_name, b, sizeof(b));
- if (s <= 0) {
- strncpy(b, device_name, PATH_MAX - 1);
- b[PATH_MAX - 1] = '\0';
- }
/* Some code borrowed from smartmontools, Christian Franke */
nsid = broadcast_nsid;
@@ -247,7 +258,7 @@ scsi_pt_open_flags(const char * device_name, int oflags, int vb)
err = errno;
if (vb)
pr2ws("%s: open(%s) failed: %s (errno=%d), try SCSI/ATA\n",
- __func__, full_path, strerror(err), err);
+ __func__, fdc_p->devname, strerror(err), err);
goto scsi_ata_try;
}
fdc_p->is_nvme = true;
@@ -262,7 +273,7 @@ scsi_pt_open_flags(const char * device_name, int oflags, int vb)
scsi_ata_try:
fdc_p->is_char = is_char;
- if (cam_get_device(device_name, fdc_p->devname, DEV_IDLEN,
+ if (cam_get_device(dev_nm, fdc_p->devname, DEV_IDLEN,
&(fdc_p->unitnum)) == -1) {
if (vb)
pr2ws("bad device name structure\n");
diff --git a/sg3_utils.spec b/sg3_utils.spec
index 0691fc7a..44982897 100644
--- a/sg3_utils.spec
+++ b/sg3_utils.spec
@@ -84,7 +84,7 @@ fi
%{_libdir}/*.la
%changelog
-* Mon Feb 15 2021 - dgilbert at interlog dot com
+* Mon Feb 22 2021 - dgilbert at interlog dot com
- track t10 changes
* sg3_utils-1.46