diff options
author | Douglas Gilbert <dgilbert@interlog.com> | 2009-03-11 17:53:31 +0000 |
---|---|---|
committer | Douglas Gilbert <dgilbert@interlog.com> | 2009-03-11 17:53:31 +0000 |
commit | f5674ee34bb8c8ab2533396571731da53142d63b (patch) | |
tree | 6c9fed6eb87fc9c8541df0fff4a0e24c2a4d1b69 | |
parent | e1a71a7d78f54c3f7c058f6760c0cac0107b66e4 (diff) | |
download | sg3_utils-f5674ee34bb8c8ab2533396571731da53142d63b.tar.gz |
add no option guard to sg_write_same
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@232 6180dd3e-e324-4e3e-922d-17de1ae2f315
-rw-r--r-- | COVERAGE | 9 | ||||
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | README | 6 | ||||
-rw-r--r-- | README.freebsd | 3 | ||||
-rw-r--r-- | README.solaris | 3 | ||||
-rw-r--r-- | README.tru64 | 3 | ||||
-rw-r--r-- | README.win32 | 3 | ||||
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | doc/sg_write_same.8 | 6 | ||||
-rw-r--r-- | sg3_utils.spec | 4 | ||||
-rw-r--r-- | src/sg_write_same.c | 14 |
11 files changed, 42 insertions, 18 deletions
@@ -62,8 +62,11 @@ WRITE(10) sg_dd, sgm_dd, sgp_dd WRITE(12) sg_dd, sgm_dd, sgp_dd WRITE(16) sg_dd, sgm_dd, sgp_dd WRITE BUFFER sg_test_rwbuf, sg_write_buffer, ++ -WRITE LONG (10) sg_write_long, ++ -WRITE LONG (16) sg_write_long, ++ +WRITE LONG(10) sg_write_long, ++ +WRITE LONG(16) sg_write_long, ++ +WRITE SAME(10) sg_write_same +WRITE SAME(16) sg_write_same +WRITE SAME(32) sg_write_same <most commands> sg_raw @@ -88,4 +91,4 @@ SMART READ DATA examples/sg_sat_smart_rd_data Doug Gilbert -18th February 2008 +11th March 2009 @@ -2,8 +2,8 @@ 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 sg3_utils-1.27 [20090310] [svn: r231] - - sg_write_same: new utility: 10, 16 and 32 byte variants +Changelog for sg3_utils-1.27 [20090311] [svn: r232] + - sg_write_same: new utility: 10, 16 and 32 byte cdb variants - sg_inq: sync version descriptors with spc4r18 - add power condition VPD page - expand block limits VPD page (sbc3r18) @@ -34,8 +34,7 @@ Changelog for sg3_utils-1.27 [20090310] [svn: r231] - add scsi_pt_version() and clear_scsi_pt_obj() calls - clear os_err at start of do_scsi_pt() - add linux bsg support via runtime detection - os_err at start of do_scsi_pt() - - sg_cmds: add sg_cmds_open_device_flags() call previous entry + - sg_cmds: add sg_cmds_open_device_flags() - sg_cmds_extra: sg_ll_format_unit: remove rto_req argument, the expanded fmtpinfo argument subsumes it. - clearer split between Linux and Windows only code and doc @@ -167,7 +167,7 @@ subdirectory of the sg3_utils package: sg_request, sg_reset, sg_rmsn, sg_rtpg, sg_safte, sg_sat_identify, sg_sat_phy_event, sg_sat_set_features, sg_scan, sg_senddiag, sg_ses, sg_start, sg_stpg, sg_sync, sg_test_rwbuff, sg_turs, sg_verify, sg_vpd, - sg_write_buffer, sg_write_long, sg_wr_mode + sg_write_buffer, sg_write_long, sg_write_same, sg_wr_mode Each of the above utilities depends on header files found in the 'include' subdirectory and library code found in the 'lib' subdirectory. Associated @@ -300,7 +300,7 @@ The more recent utilities that use "getopt_long" only are: sg_prevent sg_raw sg_read_buffer sg_read_long sg_reassign sg_requests sg_rmsn sg_rtpg sg_safte sg_sat_identify sg_sat_phy_event sg_sat_set_features sg_scan(w) sg_ses sg_stpg sg_sync sg_test_rwbuf - sg_verify sg_vpd sg_write_buffer sg_write_long sg_wr_mode + sg_verify sg_vpd sg_write_buffer sg_write_long sg_write_same sg_wr_mode Dangerous code ============== @@ -321,4 +321,4 @@ See http://sg.danny.cz/sg/tools.html Doug Gilbert -8th March 2009 +11th March 2009 diff --git a/README.freebsd b/README.freebsd index 18045284..77629976 100644 --- a/README.freebsd +++ b/README.freebsd @@ -47,6 +47,7 @@ Here is a list of utilities that have been ported: sg_wr_mode sg_write_buffer sg_write_long + sg_write_same Most utility names are indicative of the main SCSI command that they execute. Some utilities are slightly higher level, for @@ -94,4 +95,4 @@ See the FreeBSD section in the INSTALL file for install directions. Doug Gilbert -5th February 2009 +11th March 2009 diff --git a/README.solaris b/README.solaris index 3cfff2bb..68e8e0f5 100644 --- a/README.solaris +++ b/README.solaris @@ -42,6 +42,7 @@ Here is a list of utilities that have been ported: sg_wr_mode sg_write_buffer sg_write_long + sg_write_same Most utility names are indicative of the main SCSI command that they execute. Some utilities are slightly higher level, for @@ -79,4 +80,4 @@ See the Solaris section in the INSTALL file for install directions. Doug Gilbert -26th October 2008 +11th March 2009 diff --git a/README.tru64 b/README.tru64 index a9968db6..d8a3ef8d 100644 --- a/README.tru64 +++ b/README.tru64 @@ -42,6 +42,7 @@ Here is a list of utilities that have been ported: sg_wr_mode sg_write_buffer sg_write_long + sg_write_same Most utility names are indicative of the main SCSI command that they execute. Some utilities are slightly higher level, for @@ -84,4 +85,4 @@ subdirectory. Currently only the Tru64 port uses it. Doug Gilbert -26th October 2008 +11th March 2009 diff --git a/README.win32 b/README.win32 index d97acc9d..7a9e801f 100644 --- a/README.win32 +++ b/README.win32 @@ -58,6 +58,7 @@ Here is a list of utilities that have been ported: sg_wr_mode sg_write_buffer sg_write_long + sg_write_same Most utility names are indicative of the main SCSI command that they execute. Some utilities are slightly higher level, for example sg_ses fetches SCSI @@ -148,4 +149,4 @@ mode" with the setmode() Windows command. Doug Gilbert -20th December 2008 +11th March 2009 diff --git a/debian/changelog b/debian/changelog index 80e01d07..ca224057 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,7 +2,7 @@ sg3-utils (1.27-0.1) unstable; urgency=low * New upstream version - -- Doug Gilbert <dgilbert@interlog.com> Sun, 08 Mar 2009 19:00:00 -0400 + -- Doug Gilbert <dgilbert@interlog.com> Wed, 11 Mar 2009 10:00:00 -0400 sg3-utils (1.26-0.1) unstable; urgency=low diff --git a/doc/sg_write_same.8 b/doc/sg_write_same.8 index 93e8f3e9..b4399349 100644 --- a/doc/sg_write_same.8 +++ b/doc/sg_write_same.8 @@ -35,6 +35,12 @@ time, potentially as long as a FORMAT UNIT command. In such situations the command timeout value \fITO\fR will most likely need to be increased from its default value of 60 seconds. .PP +As a precaution against an accidental 'sg_write_same /dev/sda' (for example) +overwriting LBA 0 on /dev/sda with zeroes, at least one of the +\fI\-\-in=IF\fR, \fI\-\-lba=LBA\fR or \fI\-\-num=NUM\fR options must be +given. Obviously this utility can destroy a lot of user data so check the +options carefully. +.PP This utility is based SBC\-3 draft revision 18 found at http://www.t10.org . .SH OPTIONS Arguments to long options are mandatory for short options as well. diff --git a/sg3_utils.spec b/sg3_utils.spec index 09d36753..d02545e9 100644 --- a/sg3_utils.spec +++ b/sg3_utils.spec @@ -79,8 +79,8 @@ fi %{_libdir}/*.la %changelog -* Sun Mar 08 2009 - dgilbert at interlog dot com -- sg_dd: add flock, of2= and posix_fadvise support with nocache flag +* Wed Mar 11 2009 - dgilbert at interlog dot com +- add sg_write_same; sg_dd work and split; spc4r18 sync * sg3_utils-1.27 * Wed Jun 25 2008 - dgilbert at interlog dot com diff --git a/src/sg_write_same.c b/src/sg_write_same.c index d3934b02..97b19ec7 100644 --- a/src/sg_write_same.c +++ b/src/sg_write_same.c @@ -48,7 +48,7 @@ #include "sg_cmds_basic.h" #include "sg_cmds_extra.h" -static char * version_str = "0.90 20090310"; +static char * version_str = "0.90 20090311"; #define ME "sg_write_same: " @@ -305,6 +305,9 @@ int main(int argc, char * argv[]) { int sg_fd, res, c, infd, prot_en, got_stdin, act_cdb_len, vb; + int num_given = 0; + int lba_given = 0; + int if_given = 0; int64_t ll; uint32_t block_size; const char * device_name = NULL; @@ -342,6 +345,7 @@ main(int argc, char * argv[]) return 0; case 'i': strncpy(opts.ifilename, optarg, sizeof(opts.ifilename)); + if_given = 1; break; case 'l': ll = sg_get_llnum(optarg); @@ -350,6 +354,7 @@ main(int argc, char * argv[]) return SG_LIB_SYNTAX_ERROR; } opts.lba = (uint64_t)ll; + lba_given = 1; break; case 'L': ++opts.lbdata; @@ -360,6 +365,7 @@ main(int argc, char * argv[]) fprintf(stderr, "bad argument to '--num'\n"); return SG_LIB_SYNTAX_ERROR; } + num_given = 1; break; case 'P': ++opts.pbdata; @@ -426,6 +432,12 @@ main(int argc, char * argv[]) } vb = opts.verbose; + if ((! if_given) && (! lba_given) && (! num_given)) { + fprintf(stderr, "As a precaution require one of '--in=', '--lba=' " + "or '--num=' to be given\n"); + return SG_LIB_SYNTAX_ERROR; + } + memset(&a_stat, 0, sizeof(a_stat)); if (opts.ifilename[0]) { if (stat(opts.ifilename, &a_stat) < 0) { |