diff options
author | Douglas Gilbert <dgilbert@interlog.com> | 2018-01-03 05:40:58 +0000 |
---|---|---|
committer | Douglas Gilbert <dgilbert@interlog.com> | 2018-01-03 05:40:58 +0000 |
commit | a0df198b498b114e901cb022acddcc14330275da (patch) | |
tree | 724e2461cf7b93d923f5b3a41062e0c042245bb8 /src | |
parent | cd3508dc77d96ee24007928391b66273c36b34f7 (diff) | |
download | sg3_utils-a0df198b498b114e901cb022acddcc14330275da.tar.gz |
sg_inq: add --only option, further sanity checks on --inhex so CDROM std inq not confused with VPD page 0x80; sgp_dd: use pthread_kill(); various configure.ac and Makefile.am cleanups
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@742 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 142 | ||||
-rw-r--r-- | src/Makefile.in | 147 | ||||
-rw-r--r-- | src/sg_inq.c | 131 | ||||
-rw-r--r-- | src/sg_logs.c | 4 | ||||
-rw-r--r-- | src/sgp_dd.c | 13 |
5 files changed, 238 insertions, 199 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 4c3bb1ca..7d76caf1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -39,145 +39,141 @@ endif ## CC = clang ## CC = clang++ -# -std=<s> can be c99, c11, gnu11, etc. Default is gnu89 (gnu90 is the same) +# -std=<s> can be c99, c11, gnu11, etc. Default is gnu11 # -Wall is no longer all warnings. Add -W (since renamed to -Wextra) for more AM_CPPFLAGS = -iquote ${top_srcdir}/include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -AM_CFLAGS = -Wall -W @os_cflags@ -# AM_CFLAGS = -Wall -W @os_cflags@ -pedantic -std=c11 -# AM_CFLAGS = -Wall -W @os_cflags@ -pedantic -std=c11 --analyze -# AM_CFLAGS = -Wall -W @os_cflags@ -pedantic -std=c++14 +AM_CFLAGS = -Wall -W +# AM_CFLAGS = -Wall -W -pedantic -std=c11 +# AM_CFLAGS = -Wall -W -pedantic -std=c11 --analyze +# AM_CFLAGS = -Wall -W -pedantic -std=c++14 -sg_bg_ctl_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_bg_ctl_LDADD = ../lib/libsgutils2.la -sg_compare_and_write_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_compare_and_write_LDADD = ../lib/libsgutils2.la -sg_copy_results_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_copy_results_LDADD = ../lib/libsgutils2.la -sg_dd_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_dd_LDADD = ../lib/libsgutils2.la -sg_decode_sense_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_decode_sense_LDADD = ../lib/libsgutils2.la -sg_emc_trespass_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_emc_trespass_LDADD = ../lib/libsgutils2.la -sg_format_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_format_LDADD = ../lib/libsgutils2.la -sg_get_config_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_get_config_LDADD = ../lib/libsgutils2.la -sg_get_lba_status_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_get_lba_status_LDADD = ../lib/libsgutils2.la -sg_ident_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_ident_LDADD = ../lib/libsgutils2.la -sginfo_LDADD = ../lib/libsgutils2.la @os_libs@ +sginfo_LDADD = ../lib/libsgutils2.la sg_inq_SOURCES = sg_inq.c sg_inq_data.c -sg_inq_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_inq_LDADD = ../lib/libsgutils2.la -sg_logs_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_logs_LDADD = ../lib/libsgutils2.la -sg_luns_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_luns_LDADD = ../lib/libsgutils2.la -sg_map26_LDADD = @os_libs@ +sg_map_LDADD = ../lib/libsgutils2.la -sg_map_LDADD = ../lib/libsgutils2.la @os_libs@ +sgm_dd_LDADD = ../lib/libsgutils2.la -sgm_dd_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_modes_LDADD = ../lib/libsgutils2.la -sg_modes_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_opcodes_LDADD = ../lib/libsgutils2.la -sg_opcodes_LDADD = ../lib/libsgutils2.la @os_libs@ +sgp_dd_LDADD = ../lib/libsgutils2.la @PTHREAD_LIB@ -sgp_dd_LDADD = ../lib/libsgutils2.la @os_libs@ -lpthread +sg_persist_LDADD = ../lib/libsgutils2.la -sg_persist_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_prevent_LDADD = ../lib/libsgutils2.la -sg_prevent_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_raw_LDADD = ../lib/libsgutils2.la -sg_raw_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_rbuf_LDADD = ../lib/libsgutils2.la -sg_rbuf_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_rdac_LDADD = ../lib/libsgutils2.la -sg_rdac_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_read_LDADD = ../lib/libsgutils2.la -sg_read_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_read_attr_LDADD = ../lib/libsgutils2.la -sg_read_attr_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_readcap_LDADD = ../lib/libsgutils2.la -sg_readcap_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_read_block_limits_LDADD = ../lib/libsgutils2.la -sg_read_block_limits_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_read_buffer_LDADD = ../lib/libsgutils2.la -sg_read_buffer_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_read_long_LDADD = ../lib/libsgutils2.la -sg_read_long_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_reassign_LDADD = ../lib/libsgutils2.la -sg_reassign_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_requests_LDADD = ../lib/libsgutils2.la -sg_requests_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_referrals_LDADD = ../lib/libsgutils2.la -sg_referrals_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_rep_zones_LDADD = ../lib/libsgutils2.la -sg_rep_zones_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_reset_wp_LDADD = ../lib/libsgutils2.la -sg_reset_LDADD = @os_libs@ +sg_rmsn_LDADD = ../lib/libsgutils2.la -sg_reset_wp_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_rtpg_LDADD = ../lib/libsgutils2.la -sg_rmsn_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_safte_LDADD = ../lib/libsgutils2.la -sg_rtpg_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_sanitize_LDADD = ../lib/libsgutils2.la -sg_safte_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_sat_identify_LDADD = ../lib/libsgutils2.la -sg_sanitize_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_sat_phy_event_LDADD = ../lib/libsgutils2.la -sg_sat_identify_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_sat_read_gplog_LDADD = ../lib/libsgutils2.la -sg_sat_phy_event_LDADD = ../lib/libsgutils2.la @os_libs@ - -sg_sat_read_gplog_LDADD = ../lib/libsgutils2.la @os_libs@ - -sg_sat_set_features_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_sat_set_features_LDADD = ../lib/libsgutils2.la # sg_scan_SOURCES list is already set above in the platform-specific sections -sg_scan_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_scan_LDADD = ../lib/libsgutils2.la -sg_senddiag_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_senddiag_LDADD = ../lib/libsgutils2.la -sg_ses_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_ses_LDADD = ../lib/libsgutils2.la -sg_ses_microcode_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_ses_microcode_LDADD = ../lib/libsgutils2.la -sg_start_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_start_LDADD = ../lib/libsgutils2.la -sg_stpg_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_stpg_LDADD = ../lib/libsgutils2.la -sg_sync_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_sync_LDADD = ../lib/libsgutils2.la -sg_test_rwbuf_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_test_rwbuf_LDADD = ../lib/libsgutils2.la -sg_timestamp_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_timestamp_LDADD = ../lib/libsgutils2.la -sg_turs_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_turs_LDADD = ../lib/libsgutils2.la -sg_unmap_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_unmap_LDADD = ../lib/libsgutils2.la -sg_verify_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_verify_LDADD = ../lib/libsgutils2.la sg_vpd_SOURCES = sg_vpd.c sg_vpd_vendor.c -sg_vpd_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_vpd_LDADD = ../lib/libsgutils2.la -sg_wr_mode_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_wr_mode_LDADD = ../lib/libsgutils2.la -sg_write_buffer_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_write_buffer_LDADD = ../lib/libsgutils2.la -sg_write_long_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_write_long_LDADD = ../lib/libsgutils2.la -sg_write_same_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_write_same_LDADD = ../lib/libsgutils2.la -sg_write_verify_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_write_verify_LDADD = ../lib/libsgutils2.la -sg_write_x_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_write_x_LDADD = ../lib/libsgutils2.la -sg_xcopy_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_xcopy_LDADD = ../lib/libsgutils2.la -sg_zone_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_zone_LDADD = ../lib/libsgutils2.la diff --git a/src/Makefile.in b/src/Makefile.in index 7b446b09..58b81399 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -188,7 +188,7 @@ sg_map_OBJECTS = sg_map.$(OBJEXT) sg_map_DEPENDENCIES = ../lib/libsgutils2.la sg_map26_SOURCES = sg_map26.c sg_map26_OBJECTS = sg_map26.$(OBJEXT) -sg_map26_DEPENDENCIES = +sg_map26_LDADD = $(LDADD) sg_modes_SOURCES = sg_modes.c sg_modes_OBJECTS = sg_modes.$(OBJEXT) sg_modes_DEPENDENCIES = ../lib/libsgutils2.la @@ -242,7 +242,7 @@ sg_requests_OBJECTS = sg_requests.$(OBJEXT) sg_requests_DEPENDENCIES = ../lib/libsgutils2.la sg_reset_SOURCES = sg_reset.c sg_reset_OBJECTS = sg_reset.$(OBJEXT) -sg_reset_DEPENDENCIES = +sg_reset_LDADD = $(LDADD) sg_reset_wp_SOURCES = sg_reset_wp.c sg_reset_wp_OBJECTS = sg_reset_wp.$(OBJEXT) sg_reset_wp_DEPENDENCIES = ../lib/libsgutils2.la @@ -499,6 +499,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ +PTHREAD_LIB = @PTHREAD_LIB@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ @@ -545,8 +546,6 @@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ -os_cflags = @os_cflags@ -os_libs = @os_libs@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ @@ -564,83 +563,81 @@ sg_scan_SOURCES = $(am__append_2) $(am__append_4) $(am__append_6) # For C++/clang testing -# -std=<s> can be c99, c11, gnu11, etc. Default is gnu89 (gnu90 is the same) +# -std=<s> can be c99, c11, gnu11, etc. Default is gnu11 # -Wall is no longer all warnings. Add -W (since renamed to -Wextra) for more AM_CPPFLAGS = -iquote ${top_srcdir}/include -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -AM_CFLAGS = -Wall -W @os_cflags@ -# AM_CFLAGS = -Wall -W @os_cflags@ -pedantic -std=c11 -# AM_CFLAGS = -Wall -W @os_cflags@ -pedantic -std=c11 --analyze -# AM_CFLAGS = -Wall -W @os_cflags@ -pedantic -std=c++14 -sg_bg_ctl_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_compare_and_write_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_copy_results_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_dd_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_decode_sense_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_emc_trespass_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_format_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_get_config_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_get_lba_status_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_ident_LDADD = ../lib/libsgutils2.la @os_libs@ -sginfo_LDADD = ../lib/libsgutils2.la @os_libs@ +AM_CFLAGS = -Wall -W +# AM_CFLAGS = -Wall -W -pedantic -std=c11 +# AM_CFLAGS = -Wall -W -pedantic -std=c11 --analyze +# AM_CFLAGS = -Wall -W -pedantic -std=c++14 +sg_bg_ctl_LDADD = ../lib/libsgutils2.la +sg_compare_and_write_LDADD = ../lib/libsgutils2.la +sg_copy_results_LDADD = ../lib/libsgutils2.la +sg_dd_LDADD = ../lib/libsgutils2.la +sg_decode_sense_LDADD = ../lib/libsgutils2.la +sg_emc_trespass_LDADD = ../lib/libsgutils2.la +sg_format_LDADD = ../lib/libsgutils2.la +sg_get_config_LDADD = ../lib/libsgutils2.la +sg_get_lba_status_LDADD = ../lib/libsgutils2.la +sg_ident_LDADD = ../lib/libsgutils2.la +sginfo_LDADD = ../lib/libsgutils2.la sg_inq_SOURCES = sg_inq.c sg_inq_data.c -sg_inq_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_logs_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_luns_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_map26_LDADD = @os_libs@ -sg_map_LDADD = ../lib/libsgutils2.la @os_libs@ -sgm_dd_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_modes_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_opcodes_LDADD = ../lib/libsgutils2.la @os_libs@ -sgp_dd_LDADD = ../lib/libsgutils2.la @os_libs@ -lpthread -sg_persist_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_prevent_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_raw_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_rbuf_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_rdac_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_read_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_read_attr_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_readcap_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_read_block_limits_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_read_buffer_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_read_long_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_reassign_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_requests_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_referrals_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_rep_zones_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_reset_LDADD = @os_libs@ -sg_reset_wp_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_rmsn_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_rtpg_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_safte_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_sanitize_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_sat_identify_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_sat_phy_event_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_sat_read_gplog_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_sat_set_features_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_inq_LDADD = ../lib/libsgutils2.la +sg_logs_LDADD = ../lib/libsgutils2.la +sg_luns_LDADD = ../lib/libsgutils2.la +sg_map_LDADD = ../lib/libsgutils2.la +sgm_dd_LDADD = ../lib/libsgutils2.la +sg_modes_LDADD = ../lib/libsgutils2.la +sg_opcodes_LDADD = ../lib/libsgutils2.la +sgp_dd_LDADD = ../lib/libsgutils2.la @PTHREAD_LIB@ +sg_persist_LDADD = ../lib/libsgutils2.la +sg_prevent_LDADD = ../lib/libsgutils2.la +sg_raw_LDADD = ../lib/libsgutils2.la +sg_rbuf_LDADD = ../lib/libsgutils2.la +sg_rdac_LDADD = ../lib/libsgutils2.la +sg_read_LDADD = ../lib/libsgutils2.la +sg_read_attr_LDADD = ../lib/libsgutils2.la +sg_readcap_LDADD = ../lib/libsgutils2.la +sg_read_block_limits_LDADD = ../lib/libsgutils2.la +sg_read_buffer_LDADD = ../lib/libsgutils2.la +sg_read_long_LDADD = ../lib/libsgutils2.la +sg_reassign_LDADD = ../lib/libsgutils2.la +sg_requests_LDADD = ../lib/libsgutils2.la +sg_referrals_LDADD = ../lib/libsgutils2.la +sg_rep_zones_LDADD = ../lib/libsgutils2.la +sg_reset_wp_LDADD = ../lib/libsgutils2.la +sg_rmsn_LDADD = ../lib/libsgutils2.la +sg_rtpg_LDADD = ../lib/libsgutils2.la +sg_safte_LDADD = ../lib/libsgutils2.la +sg_sanitize_LDADD = ../lib/libsgutils2.la +sg_sat_identify_LDADD = ../lib/libsgutils2.la +sg_sat_phy_event_LDADD = ../lib/libsgutils2.la +sg_sat_read_gplog_LDADD = ../lib/libsgutils2.la +sg_sat_set_features_LDADD = ../lib/libsgutils2.la # sg_scan_SOURCES list is already set above in the platform-specific sections -sg_scan_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_senddiag_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_ses_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_ses_microcode_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_start_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_stpg_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_sync_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_test_rwbuf_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_timestamp_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_turs_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_unmap_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_verify_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_scan_LDADD = ../lib/libsgutils2.la +sg_senddiag_LDADD = ../lib/libsgutils2.la +sg_ses_LDADD = ../lib/libsgutils2.la +sg_ses_microcode_LDADD = ../lib/libsgutils2.la +sg_start_LDADD = ../lib/libsgutils2.la +sg_stpg_LDADD = ../lib/libsgutils2.la +sg_sync_LDADD = ../lib/libsgutils2.la +sg_test_rwbuf_LDADD = ../lib/libsgutils2.la +sg_timestamp_LDADD = ../lib/libsgutils2.la +sg_turs_LDADD = ../lib/libsgutils2.la +sg_unmap_LDADD = ../lib/libsgutils2.la +sg_verify_LDADD = ../lib/libsgutils2.la sg_vpd_SOURCES = sg_vpd.c sg_vpd_vendor.c -sg_vpd_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_wr_mode_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_write_buffer_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_write_long_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_write_same_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_write_verify_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_write_x_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_xcopy_LDADD = ../lib/libsgutils2.la @os_libs@ -sg_zone_LDADD = ../lib/libsgutils2.la @os_libs@ +sg_vpd_LDADD = ../lib/libsgutils2.la +sg_wr_mode_LDADD = ../lib/libsgutils2.la +sg_write_buffer_LDADD = ../lib/libsgutils2.la +sg_write_long_LDADD = ../lib/libsgutils2.la +sg_write_same_LDADD = ../lib/libsgutils2.la +sg_write_verify_LDADD = ../lib/libsgutils2.la +sg_write_x_LDADD = ../lib/libsgutils2.la +sg_xcopy_LDADD = ../lib/libsgutils2.la +sg_zone_LDADD = ../lib/libsgutils2.la all: all-am .SUFFIXES: diff --git a/src/sg_inq.c b/src/sg_inq.c index 423c0fbf..3a4fae3d 100644 --- a/src/sg_inq.c +++ b/src/sg_inq.c @@ -1,5 +1,5 @@ /* A utility program originally written for the Linux OS SCSI subsystem. -* Copyright (C) 2000-2017 D. Gilbert +* Copyright (C) 2000-2018 D. Gilbert * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) @@ -46,7 +46,7 @@ #include "sg_pt_nvme.h" #endif -static const char * version_str = "1.80 20171229"; /* SPC-5 rev 17 */ +static const char * version_str = "1.81 20180102"; /* SPC-5 rev 17 */ /* INQUIRY notes: * It is recommended that the initial allocation length given to a @@ -223,6 +223,7 @@ static struct option long_options[] = { {"new", no_argument, 0, 'N'}, {"old", no_argument, 0, 'O'}, #endif + {"only", no_argument, 0, 'o'}, {"page", required_argument, 0, 'p'}, {"raw", no_argument, 0, 'r'}, {"vendor", no_argument, 0, 's'}, @@ -241,6 +242,7 @@ struct opts_t { bool do_decode; bool do_vpd; bool p_given; + bool skip_vpd; /* --only after standard inq don't fetch VPD page 0x80 */ int do_block; int do_cmddt; int do_help; @@ -253,7 +255,6 @@ struct opts_t { int page_num; int page_pdt; int num_pages; - int num_opcodes; const char * page_arg; const char * device_name; const char * inhex_fn; @@ -271,9 +272,10 @@ usage() "[--export]\n" " [--extended] [--help] [--hex] [--id] [--inhex=FN] " "[--len=LEN]\n" - " [--long] [--maxlen=LEN] [--page=PG] [--raw] " - "[--vendor]\n" - " [--verbose] [--version] [--vpd] DEVICE\n" + " [--long] [--maxlen=LEN] [--only] [--page=PG] " + "[--raw]\n" + " [--vendor] [--verbose] [--version] [--vpd] " + "DEVICE\n" " where:\n" " --ata|-a treat DEVICE as (directly attached) ATA " "device\n"); @@ -282,9 +284,9 @@ usage() "[--export]\n" " [--extended] [--help] [--hex] [--id] [--inhex=FN] " "[--len=LEN]\n" - " [--maxlen=LEN] [--page=PG] [--raw] [--verbose] " - "[--version]\n" - " [--vpd] DEVICE\n" + " [--long] [--maxlen=LEN] [--only] [--page=PG] " + "[--raw]\n" + " [--verbose] [--version] [--vpd] DEVICE\n" " where:\n"); #endif pr2serr(" --block=0|1 0-> open(non-blocking); 1-> " @@ -318,6 +320,9 @@ usage() "indicated)\n" " --long|-L supply extra information on NVMe devices\n" " --maxlen=LEN|-m LEN same as '--len='\n" + " --old|-O use old interface (use as first option)\n" + " --only|-o for std inquiry do not fetch serial number " + "vpd page\n" " --page=PG|-p PG Vital Product Data (VPD) page number " "or\n" " abbreviation (opcode number if " @@ -327,7 +332,6 @@ usage() "inquiry\n" " --verbose|-v increase verbosity\n" " --version|-V print version string then exit\n" - " --old|-O use old interface (use as first option)\n" " --vpd|-e vital product data (set page with " "'--page=PG')\n\n" "Performs a SCSI INQUIRY command on DEVICE or decodes INQUIRY " @@ -345,7 +349,7 @@ usage_old() pr2serr("Usage: sg_inq [-a] [-A] [-b] [-B=0|1] [-c] [-cl] [-d] [-e] " "[-h]\n" " [-H] [-i] [I=FN] [-l=LEN] [-L] [-m] [-M] " - "[-o=OPCODE_PG]\n" + "[-o]\n" " [-p=VPD_PG] [-P] [-r] [-s] [-u] [-U] [-v] [-V] " "[-x]\n" " [-36] [-?] DEVICE\n" @@ -355,7 +359,7 @@ usage_old() #else pr2serr("Usage: sg_inq [-a] [-b] [-B 0|1] [-c] [-cl] [-d] [-e] [-h] " "[-H]\n" - " [-i] [-l=LEN] [-L] [-m] [-M] [-o=OPCODE_PG] " + " [-i] [-l=LEN] [-L] [-m] [-M] [-o] " "[-p=VPD_PG]\n" " [-P] [-r] [-s] [-u] [-v] [-V] [-x] [-36] " "[-?]\n" @@ -382,7 +386,9 @@ usage_old() " -m decode management network addresses VPD page " "(0x85)\n" " -M decode mode page policy VPD page (0x87)\n" - " -o=OPCODE_PG opcode or page code in hex (def: 0)\n" + " -N|--new use new interface\n" + " -o for std inquiry only do that, not serial number vpd " + "page\n" " -p=VPD_PG vpd page code in hex (def: 0)\n" " -P decode Unit Path Report VPD page (0xc0) (EMC)\n" " -r output response in binary ('-rr': output for hdparm)\n" @@ -392,7 +398,6 @@ usage_old() " -V output version string\n" " -x decode extended INQUIRY data VPD page (0x86)\n" " -36 perform standard INQUIRY with a 36 byte response\n" - " -N|--new use new interface\n" " -? output this usage message\n\n" "If no options given then does a standard SCSI INQUIRY\n"); } @@ -429,19 +434,19 @@ new_parse_cmd_line(struct opts_t * op, int argc, char * argv[]) #ifdef SG_LIB_LINUX #ifdef SG_SCSI_STRINGS - c = getopt_long(argc, argv, "aB:cdeEfhHiI:l:Lm:NOp:rsuvVx", + c = getopt_long(argc, argv, "aB:cdeEfhHiI:l:Lm:NoOp:rsuvVx", long_options, &option_index); #else - c = getopt_long(argc, argv, "B:cdeEfhHiI:l:Lm:p:rsuvVx", long_options, - &option_index); + c = getopt_long(argc, argv, "B:cdeEfhHiI:l:Lm:op:rsuvVx", + long_options, &option_index); #endif /* SG_SCSI_STRINGS */ #else /* SG_LIB_LINUX */ #ifdef SG_SCSI_STRINGS - c = getopt_long(argc, argv, "B:cdeEfhHiI:l:Lm:NOp:rsuvVx", + c = getopt_long(argc, argv, "B:cdeEfhHiI:l:Lm:NoOp:rsuvVx", long_options, &option_index); #else - c = getopt_long(argc, argv, "B:cdeEfhHiI:l:Lm:p:rsuvVx", long_options, - &option_index); + c = getopt_long(argc, argv, "B:cdeEfhHiI:l:Lm:op:rsuvVx", + long_options, &option_index); #endif /* SG_SCSI_STRINGS */ #endif /* SG_LIB_LINUX */ if (c == -1) @@ -487,6 +492,9 @@ new_parse_cmd_line(struct opts_t * op, int argc, char * argv[]) case 'h': ++op->do_help; break; + case 'o': + op->skip_vpd = true; + break; case '?': if (! op->do_help) ++op->do_help; @@ -648,6 +656,9 @@ old_parse_cmd_line(struct opts_t * op, int argc, char * argv[]) case 'N': op->opt_new = true; return 0; + case 'o': + op->skip_vpd = true; + break; case 'O': break; case 'P': @@ -711,9 +722,6 @@ old_parse_cmd_line(struct opts_t * op, int argc, char * argv[]) return SG_LIB_SYNTAX_ERROR; } op->resp_len = n; - } else if (0 == strncmp("o=", cp, 2)) { - op->page_arg = cp + 2; - ++op->num_opcodes; } else if (0 == strncmp("p=", cp, 2)) { op->page_arg = cp + 2; op->p_given = true; @@ -1208,29 +1216,31 @@ decode_supported_vpd(unsigned char * buff, int len, int do_hex) } static bool -vpd_page_is_supported(unsigned char * buff, int len, int pg) +vpd_page_is_supported(unsigned char * vpd_pg0, int v0_len, int pg_num) { - int vpd, k, rlen; - bool supported = false; + int k, rlen; - if (len < 4) + if (v0_len < 4) return false; - rlen = buff[3] + 4; - if (rlen > len) + rlen = vpd_pg0[3] + 4; + if (rlen > v0_len) pr2serr("Supported VPD pages VPD page truncated, indicates %d, got " - "%d\n", rlen, len); + "%d\n", rlen, v0_len); else - len = rlen; + v0_len = rlen; - for (k = 0; k < len - 4; ++k) { - vpd = buff[4 + k]; - if(vpd == pg) { - supported = true; - break; - } + for (k = 4; k < v0_len; ++k) { + if(vpd_pg0[k] == pg_num) + return true; } - return supported; + return false; +} + +static bool +vpd_page_not_supported(unsigned char * vpd_pg0, int v0_len, int pg_num) +{ + return ! vpd_page_is_supported(vpd_pg0, v0_len, pg_num); } /* ASCII Information VPD pages (page numbers: 0x1 to 0x7f) */ @@ -3151,6 +3161,16 @@ fetch_unit_serial_num(int sg_fd, char * obuff, int obuff_len, int verbose) int len, k, res, c; unsigned char b[DEF_ALLOC_LEN]; + res = vpd_fetch_page_from_dev(sg_fd, b, VPD_SUPPORTED_VPDS, + -1,verbose, &len); + if (res) { + if (verbose > 2) + pr2serr("fetch_unit_serial_num: no supported VPDs page\n"); + return SG_LIB_CAT_MALFORMED; + } + if (vpd_page_not_supported(b, len, VPD_UNIT_SERIAL_NUM)) + return SG_LIB_CAT_ILLEGAL_REQ; + memset(b, 0xff, 4); /* guard against empty response */ res = vpd_fetch_page_from_dev(sg_fd, b, VPD_UNIT_SERIAL_NUM, -1, verbose, &len); @@ -3226,7 +3246,7 @@ std_inq_process(int sg_fd, const struct opts_t * op, int inhex_len) act_len = rlen - resid; if (act_len < SAFE_STD_INQ_RESP_LEN) rsp_buff[act_len] = '\0'; - if ((! op->do_export) && (0 == op->resp_len)) { + if ((! op->skip_vpd) && (! op->do_export) && (0 == op->resp_len)) { if (fetch_unit_serial_num(sg_fd, usn_buff, sizeof(usn_buff), op->do_verbose)) usn_buff[0] = '\0'; @@ -3459,7 +3479,7 @@ vpd_decode(int sg_fd, const struct opts_t * op, int inhex_len) vb, &len); if (res) goto out; - if (!vpd_page_is_supported(rp, len, pn)) { + if (vpd_page_not_supported(rp, len, pn)) { res = SG_LIB_CAT_ILLEGAL_REQ; goto out; } @@ -4213,13 +4233,30 @@ main(int argc, char * argv[]) pr2serr("Guessing from --inhex= this is a standard " "INQUIRY\n"); } else if (rsp_buff[2] <= 2) { - if (op->do_verbose) - pr2serr("Guessing from --inhex this is VPD page 0x%x\n", - rsp_buff[1]); - op->page_num = rsp_buff[1]; - op->do_vpd = true; - if ((1 != op->do_hex) && (0 == op->do_raw)) - op->do_decode = true; + /* + * Removable devices have the RMB bit set, which would + * present itself as vpd page 0x80 output if we're not + * careful + * + * Serial number must be right-aligned ASCII data in + * bytes 5-7; standard INQUIRY will have flags here. + */ + if (rsp_buff[1] == 0x80 && + (rsp_buff[5] < 0x20 || rsp_buff[5] > 0x80 || + rsp_buff[6] < 0x20 || rsp_buff[6] > 0x80 || + rsp_buff[7] < 0x20 || rsp_buff[7] > 0x80)) { + if (op->do_verbose) + pr2serr("Guessing from --inhex= this is a " + "standard INQUIRY\n"); + } else { + if (op->do_verbose) + pr2serr("Guessing from --inhex= this is VPD " + "page 0x%x\n", rsp_buff[1]); + op->page_num = rsp_buff[1]; + op->do_vpd = true; + if ((1 != op->do_hex) && (0 == op->do_raw)) + op->do_decode = true; + } } else { if (op->do_verbose) pr2serr("page number unclear from --inhex, hope it's a " diff --git a/src/sg_logs.c b/src/sg_logs.c index 81ef6cf6..bf1a5ce2 100644 --- a/src/sg_logs.c +++ b/src/sg_logs.c @@ -1,5 +1,5 @@ /* A utility program originally written for the Linux OS SCSI subsystem. - * Copyright (C) 2000-2017 D. Gilbert + * Copyright (C) 2000-2018 D. Gilbert * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) @@ -32,7 +32,7 @@ #include "sg_unaligned.h" #include "sg_pr2serr.h" -static const char * version_str = "1.58 20171229"; /* spc5r17 + sbc4r11 */ +static const char * version_str = "1.59 20180102"; /* spc5r17 + sbc4r11 */ #define MX_ALLOC_LEN (0xfffc) #define SHORT_RESP_LEN 128 diff --git a/src/sgp_dd.c b/src/sgp_dd.c index bb515c82..ecc853e5 100644 --- a/src/sgp_dd.c +++ b/src/sgp_dd.c @@ -1,7 +1,7 @@ /* A utility program for copying files. Specialised for "files" that * represent devices that understand the SCSI command set. * - * Copyright (C) 1999 - 2017 D. Gilbert and P. Allworth + * Copyright (C) 1999 - 2018 D. Gilbert and P. Allworth * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) @@ -60,7 +60,7 @@ #include "sg_pr2serr.h" -static const char * version_str = "5.59 20171222"; +static const char * version_str = "5.60 20180102"; #define DEF_BLOCK_SIZE 512 #define DEF_BLOCKS_PER_TRANSFER 128 @@ -181,6 +181,7 @@ static int sg_finish_io(bool wr, Rq_elem * rep, pthread_mutex_t * a_mutp); static pthread_mutex_t strerr_mut = PTHREAD_MUTEX_INITIALIZER; +static bool shutting_down = false; static bool do_sync = false; static bool do_time = false; static Rq_coll rcoll; @@ -478,6 +479,8 @@ sig_listen_thread(void * v_clp) while (1) { sigwait(&signal_set, &sig_number); + if (shutting_down) + break; if (SIGINT == sig_number) { pr2serr(ME "interrupted by SIGINT\n"); guarded_stop_both(clp); @@ -1645,6 +1648,7 @@ main(int argc, char * argv[]) } } +#if 0 #if SG_LIB_ANDROID /* Android doesn't have pthread_cancel() so use pthread_kill() instead. * Also there is no need to link with -lpthread in Android */ @@ -1653,6 +1657,11 @@ main(int argc, char * argv[]) status = pthread_cancel(sig_listen_thread_id); #endif if (0 != status) err_exit(status, "pthread_cancel"); +#endif /* 0 */ + + shutting_down = true; + status = pthread_kill(sig_listen_thread_id, SIGINT); + if (0 != status) err_exit(status, "pthread_kill"); if (STDIN_FILENO != rcoll.infd) close(rcoll.infd); if ((STDOUT_FILENO != rcoll.outfd) && (FT_DEV_NULL != rcoll.out_type)) |