aboutsummaryrefslogtreecommitdiff
path: root/lib/sg_pt_linux.c
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2012-08-20 15:32:17 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2012-08-20 15:32:17 +0000
commit816b65c1c8044422340c13b883e00e1d4204be0f (patch)
treef727f63707ed8cd031f9930e3ca08d4ffbbbfac0 /lib/sg_pt_linux.c
parent01c80b4c0fdc8408353762124ab630a02f1770c4 (diff)
downloadsg3_utils-816b65c1c8044422340c13b883e00e1d4204be0f.tar.gz
sg_ses: more sanity for additional element status descriptor page
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@451 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'lib/sg_pt_linux.c')
-rw-r--r--lib/sg_pt_linux.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/sg_pt_linux.c b/lib/sg_pt_linux.c
index 1635cac1..2089e330 100644
--- a/lib/sg_pt_linux.c
+++ b/lib/sg_pt_linux.c
@@ -5,7 +5,7 @@
* license that can be found in the BSD_LICENSE file.
*/
-/* sg_pt_linux version 1.16 20120125 */
+/* sg_pt_linux version 1.17 20120806 */
#include <stdio.h>
@@ -481,15 +481,23 @@ get_scsi_pt_os_err_str(const struct sg_pt_base * vp, int max_b_len, char * b)
* do_scsi_pt_v3() transfers the input data into a v3 structure and
* then the output data is transferred back into a sg v4 structure.
* That implementation detail could change in the future.
+ *
+ * [20120806] Only use MAJOR() macro in kdev_t.h if that header file is
+ * available and major() macro [N.B. lower case] is not available.
*/
#include <linux/types.h>
#include <linux/bsg.h>
+#ifdef major
+#define SG_DEV_MAJOR major
+#else
#ifdef HAVE_LINUX_KDEV_T_H
#include <linux/kdev_t.h>
#endif
+#define SG_DEV_MAJOR MAJOR /* MAJOR() macro faulty if > 255 minors */
+#endif
struct sg_pt_linux_scsi {
@@ -973,15 +981,9 @@ do_scsi_pt(struct sg_pt_base * vp, int fd, int time_secs, int verbose)
strerror(ptp->os_err), ptp->os_err);
return -ptp->os_err;
}
-#ifdef HAVE_LINUX_KDEV_T_H
if (! S_ISCHR(a_stat.st_mode) ||
- (bsg_major != (int)MAJOR(a_stat.st_rdev)))
+ (bsg_major != (int)SG_DEV_MAJOR(a_stat.st_rdev)))
return do_scsi_pt_v3(ptp, fd, time_secs, verbose);
-#else
- if (! S_ISCHR(a_stat.st_mode) ||
- (bsg_major != (int)major(a_stat.st_rdev)))
- return do_scsi_pt_v3(ptp, fd, time_secs, verbose);
-#endif
}
if (! ptp->io_hdr.request) {