aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--README2
-rw-r--r--debian/changelog2
-rw-r--r--doc/sg_start.840
-rw-r--r--include/sg_cmds_basic.h12
-rw-r--r--lib/sg_cmds_basic.c18
-rw-r--r--lib/sg_lib_data.c2
-rw-r--r--sg3_utils.spec2
-rw-r--r--src/sg_start.c88
9 files changed, 124 insertions, 47 deletions
diff --git a/ChangeLog b/ChangeLog
index c3a884b3..efd87c3c 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 sg3_utils-1.26 [20080313]
+Changelog for sg3_utils-1.26 [20080316]
- sg_ses: sync with ses2r19b
- sg_get_config: sync with mmc6r01
- allow Microcode upgrade and DVD read feature descriptors
@@ -23,9 +23,10 @@ Changelog for sg3_utils-1.26 [20080313]
- sg_dd: improve MMC handling of 'illegal mode for this track'
read errors (with ILI and info field)
- sg_modes: add --maxlen= option to specify allocation length
+ - sg_start: add '--noflush' and '--mod=PC_MOD' options (08-139r1)
- change 'long long' to int64_t and 'unsigned long long' to
uint64_t to stress that 64 bit integer wanted, not larger
- - sg_lib: update asc/ascq code pending spc4r13
+ - sg_lib: update asc/ascq code to spc4r13
- split sg_lib into sg_lib_data.[hc] and sg_lib.[hc]
- split sg_cmds_extra into sg_cmds_extra and sg_cmds_mmc
- add osd2r03 service actions (all different from osd-r10)
diff --git a/README b/README
index c66fa49b..27ebe105 100644
--- a/README
+++ b/README
@@ -330,4 +330,4 @@ See http://www.torque.net/sg/tools.html
Doug Gilbert
-13th March 2008
+16th March 2008
diff --git a/debian/changelog b/debian/changelog
index 4c08a652..bf5bd734 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,7 @@ sg3-utils (1.26-0.1) unstable; urgency=low
* New upstream version
- -- Doug Gilbert <dgilbert@interlog.com> Thu, 13 Mar 2008 14:00:00 -0400
+ -- Doug Gilbert <dgilbert@interlog.com> Sun, 16 Mar 2008 16:00:00 -0400
sg3-utils (1.25-0.1) unstable; urgency=low
diff --git a/doc/sg_start.8 b/doc/sg_start.8
index 86e2d032..872bab5f 100644
--- a/doc/sg_start.8
+++ b/doc/sg_start.8
@@ -1,18 +1,19 @@
-.TH SG_START "8" "October 2007" "sg3_utils\-1.25" SG3_UTILS
+.TH SG_START "8" "March 2008" "sg3_utils\-1.26" SG3_UTILS
.SH NAME
sg_start \- send SCSI START STOP UNIT command to start, stop, load or
eject medium
.SH SYNOPSIS
.B sg_start
[\fI0\fR] [\fI1\fR] [\fI\-\-eject\fR] [\fI\-\-help\fR] [\fI\-\-fl=FL\fR]
-[\fI\-\-immed\fR] [\fI\-\-load\fR] [\fI\-\-loej\fR] [\fI\-\-pc=PC\fR]
-[\fI\-\-start\fR] [\fI\-\-stop\fR] [\fI\-\-verbose\fR] [\fI\-\-version\fR]
-\fIDEVICE\fR
+[\fI\-\-immed\fR] [\fI\-\-load\fR] [\fI\-\-loej\fR] [\fI\-\-mod=PC_MOD\fR]
+[\fI\-\-noflush\fR] [\fI\-\-pc=PC\fR] [\fI\-\-start\fR] [\fI\-\-stop\fR]
+[\fI\-\-verbose\fR] [\fI\-\-version\fR] \fIDEVICE\fR
.PP
.B sg_start
[\fI\-\-eject\fR] [\fI\-\-fl=FL\fR] [\fI\-i\fR] [\fI\-\-imm=0|1\fR]
-[\fI\-\-load\fR] [\fI\-\-loej\fR] [\fI\-\-pc=PC\fR] [\fI\-\-start\fR]
-[\fI\-\-stop\fR] [\fI\-v\fR] [\fI\-V\fR] [\fI0|1\fR] \fIDEVICE\fR
+[\fI\-\-load\fR] [\fI\-\-loej\fR] [\fI\-\-mod=PC_MOD\fR] [\fI\-\-noflush\fR]
+[\fI\-\-pc=PC\fR] [\fI\-\-start\fR] [\fI\-\-stop\fR] [\fI\-v\fR] [\fI\-V\fR]
+[\fI0|1\fR] \fIDEVICE\fR
.SH DESCRIPTION
.\" Add any additional description here
.PP
@@ -20,7 +21,7 @@ sg_start sends a SCSI START STOP UNIT command to the \fIDEVICE\fR with
the selected options. The most used options are \fI\-\-stop\fR to spin
down a disk and \fI\-\-start\fR to spin up a disk. Using \fI\-\-start\fR
on a disk that is already spinning is harmless. There is also finer grain
-control with "power conditions": active, idle and standby. This is set
+control with "power condition": active, idle or standby. This is set
with the \fI\-\-pc=PC\fR option. In some contexts the "stop" state can
be considered an additional power condition.
.PP
@@ -79,6 +80,17 @@ Default is off (i.e. don't attempt to load or eject media). If a start/start
indication is not given (i.e. neither \fI\-\-start\fR nor \fI\-\-stop\fR)
and this option is given then a load and start action is assumed.
.TP
+\fB\-m\fR, \fB\-\-mod\fR=\fIPC_MOD\fR
+where \fIPC_MOD\fR is the 'power condition modifier' value. 0 to 15 (inclusive)
+are valid and 0 is the default. This 'power condition modifier' field in the
+cdb was added after sbc3r13.
+.TP
+\fB\-n\fR, \fB\-\-noflush\fR
+do not perform a flush to media (e.g. like SYNCHRONIZE CACHE does) before
+a variant of this utility that limits access to the media. Using the
+\fB\-\-stop\fR option is an example of something that limits access to the
+media. This 'noflush' field in the cdb was added after sbc3r13.
+.TP
\fB\-O\fR, \fB\-\-old\fR
switch to older style options.
.TP
@@ -195,8 +207,18 @@ defaults to load and start.]
\fB\-N\fR
switch to the newer style options.
.TP
+\fB\-\-mod\fR=\fIPC_MOD\fR
+where \fIPC_MOD\fR is the 'power condition modifier' value. 0 to 15 (inclusive)
+are valid and 0 is the default. This field was added after sbc3r13.
+.TP
+\fB\-\-noflush\fR
+do not perform a flush to media (e.g. like SYNCHRONIZE CACHE does) before
+a variant of this utility that limits access to the media. Using the
+\fB\-\-stop\fR option is an example of something that limits access to the
+media. This field was added after sbc3r13.
+.TP
\fB\-\-pc\fR=\fIPC\fR
-where \fIPC\fR is the 'power conditions' value (in hex). 0 to f (inclusive)
+where \fIPC\fR is the 'power condition' value (in hex). 0 to f (inclusive)
are valid. Default value is 0.
.TP
\fB\-\-start\fR
@@ -216,7 +238,7 @@ Written by K. Garloff and D. Gilbert
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
-Copyright \(co 2002\-2007 Kurt Garloff, Douglas Gilbert
+Copyright \(co 2002\-2008 Kurt Garloff, Douglas Gilbert
.br
This software is distributed under the GPL version 2. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/include/sg_cmds_basic.h b/include/sg_cmds_basic.h
index 40ecaa7b..12e60281 100644
--- a/include/sg_cmds_basic.h
+++ b/include/sg_cmds_basic.h
@@ -137,14 +137,18 @@ extern int sg_ll_report_luns(int sg_fd, int select_report, void * resp,
extern int sg_ll_request_sense(int sg_fd, int desc, void * resp,
int mx_resp_len, int noisy, int verbose);
-/* Invokes a SCSI START STOP UNIT command (MMC + SBC).
+/* Invokes a SCSI START STOP UNIT command (SBC + MMC).
* Return of 0 -> success,
* SG_LIB_CAT_INVALID_OP -> Start stop unit not supported,
* SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
* SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
- * -1 -> other failure */
-extern int sg_ll_start_stop_unit(int sg_fd, int immed, int fl_num,
- int power_cond, int fl, int loej,
+ * -1 -> other failure
+ * SBC-3 and MMC partially overlap on the power_condition_modifier(sbc) and
+ * format_layer_number(mmc) fields. They also overlap on the noflush(sbc)
+ * and fl(mmc) one bit field. This is the cause of the awkardly named
+ * pc_mod__fl_num and noflush__fl arguments to this function. */
+extern int sg_ll_start_stop_unit(int sg_fd, int immed, int pc_mod__fl_num,
+ int power_cond, int noflush__fl, int loej,
int start, int noisy, int verbose);
/* Invokes a SCSI SYNCHRONIZE CACHE (10) command. Return of 0 -> success,
diff --git a/lib/sg_cmds_basic.c b/lib/sg_cmds_basic.c
index b460ed3d..4baf2f00 100644
--- a/lib/sg_cmds_basic.c
+++ b/lib/sg_cmds_basic.c
@@ -1412,15 +1412,21 @@ sg_ll_log_select(int sg_fd, int pcr, int sp, int pc, int pg_code,
return ret;
}
-/* Invokes a SCSI START STOP UNIT command (MMC + SBC).
+/* Invokes a SCSI START STOP UNIT command (SBC + MMC).
* Return of 0 -> success,
* SG_LIB_CAT_INVALID_OP -> Start stop unit not supported,
* SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
* SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
- * -1 -> other failure */
+ * -1 -> other failure
+ * SBC-3 and MMC partially overlap on the power_condition_modifier(sbc) and
+ * format_layer_number(mmc) fields. They also overlap on the noflush(sbc)
+ * and fl(mmc) one bit field. This is the cause of the awkardly named
+ * pc_mod__fl_num and noflush__fl arguments to this function.
+ * */
int
-sg_ll_start_stop_unit(int sg_fd, int immed, int fl_num, int power_cond,
- int fl, int loej, int start, int noisy, int verbose)
+sg_ll_start_stop_unit(int sg_fd, int immed, int pc_mod__fl_num,
+ int power_cond, int noflush__fl, int loej, int start,
+ int noisy, int verbose)
{
unsigned char ssuBlk[START_STOP_CMDLEN] = {START_STOP_CMD, 0, 0, 0, 0, 0};
unsigned char sense_b[SENSE_BUFF_LEN];
@@ -1428,8 +1434,8 @@ sg_ll_start_stop_unit(int sg_fd, int immed, int fl_num, int power_cond,
struct sg_pt_base * ptvp;
ssuBlk[1] = immed & 1;
- ssuBlk[3] = fl_num & 3;
- ssuBlk[4] = ((power_cond & 0xf) << 4) | (fl ? 0x4 : 0) |
+ ssuBlk[3] = pc_mod__fl_num & 0xf; /* bits 2 and 3 are reserved in MMC */
+ ssuBlk[4] = ((power_cond & 0xf) << 4) | (noflush__fl ? 0x4 : 0) |
(loej ? 0x2 : 0) | (start ? 0x1 : 0);
if (NULL == sg_warnings_strm)
sg_warnings_strm = stderr;
diff --git a/lib/sg_lib_data.c b/lib/sg_lib_data.c
index 525546a9..82285ece 100644
--- a/lib/sg_lib_data.c
+++ b/lib/sg_lib_data.c
@@ -33,7 +33,7 @@
#include "sg_lib_data.h"
-const char * sg_lib_version_str = "1.42 20080313"; /* spc-4 rev 13 */
+const char * sg_lib_version_str = "1.43 20080316"; /* spc-4 rev 13 */
struct sg_lib_value_name_t sg_lib_normal_opcodes[] = {
{0, 0, "Test Unit Ready"},
diff --git a/sg3_utils.spec b/sg3_utils.spec
index 097b595f..468c0911 100644
--- a/sg3_utils.spec
+++ b/sg3_utils.spec
@@ -79,7 +79,7 @@ fi
%{_libdir}/*.la
%changelog
-* Thu Mar 13 2008 - dgilbert at interlog dot com
+* Sun Mar 16 2008 - dgilbert at interlog dot com
- sg_get_config sync with mmc6r01, add sg_sat_phy_event
* sg3_utils-1.26
diff --git a/src/sg_start.c b/src/sg_start.c
index 17b104d6..305452cd 100644
--- a/src/sg_start.c
+++ b/src/sg_start.c
@@ -12,7 +12,7 @@
#include "sg_cmds_basic.h"
/*
- * Copyright (C) 1999-2007 D. Gilbert
+ * Copyright (C) 1999-2008 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)
@@ -30,7 +30,7 @@
*/
-static char * version_str = "0.55 20070714";
+static char * version_str = "0.56 20080316"; /* sbc3r13+08-139r1; mmc6r01a */
static struct option long_options[] = {
{"eject", 0, 0, 'e'},
@@ -39,6 +39,8 @@ static struct option long_options[] = {
{"immed", 0, 0, 'i'},
{"load", 0, 0, 'l'},
{"loej", 0, 0, 'L'},
+ {"mod", 1, 0, 'm'},
+ {"noflush", 0, 0, 'n'},
{"new", 0, 0, 'N'},
{"old", 0, 0, 'O'},
{"pc", 1, 0, 'p'},
@@ -56,6 +58,8 @@ struct opts_t {
int do_immed;
int do_load;
int do_loej;
+ int do_mod;
+ int do_noflush;
int do_pc;
int do_start;
int do_stop;
@@ -65,13 +69,14 @@ struct opts_t {
int opt_new;
};
-void usage()
+static void
+usage()
{
fprintf(stderr, "Usage: sg_start [--eject] [--fl=FL] [--help] "
"[--immed] [--load] [--loej]\n"
- " [--pc=PC] [--start] [--stop] "
- "[--verbose] [--version]\n"
- " DEVICE\n"
+ " [--mod=PC_MOD] [--noflush] [--pc=PC] "
+ "[--start] [--stop]\n"
+ " [--verbose] [--version] DEVICE\n"
" where:\n"
" --eject|-e stop unit then eject the medium\n"
" --fl=FL|-f FL format layer number (mmc5)\n"
@@ -85,10 +90,15 @@ void usage()
"in cdb;\n"
" load when START bit also set, else "
"eject\n"
- " --pc=PC|-p PC power conditions: 0 (default) -> no "
+ " --mod=PC_MOD|-m PC_MOD power condition modifier "
+ "(def: 0) (sbc)\n"
+ " --noflush|-n no flush prior to operation that limits "
+ "access (sbc)\n"
+ " --load|-l load medium then start the unit\n"
+ " --pc=PC|-p PC power condition: 0 (default) -> no "
"power condition,\n"
" 1 -> active, 2 -> idle, 3 -> standby, "
- "5 -> sleep (MMC)\n"
+ "5 -> sleep (mmc)\n"
" --start|-s start unit, corresponds to START bit "
"in cdb,\n"
" default (START=1) if no other options "
@@ -103,12 +113,14 @@ void usage()
);
}
-void usage_old()
+static void
+usage_old()
{
fprintf(stderr, "Usage: sg_start [0] [1] [--eject] [--fl=FL] "
"[-i] [--imm=0|1]\n"
- " [--load] [--loej] [--pc=PC] [--start] "
- "[--stop] [-v] [-V]\n"
+ " [--load] [--loej] [--mod=PC_MOD] "
+ "[--noflush] [--pc=PC]\n"
+ " [--start] [--stop] [-v] [-V]\n"
" DEVICE\n"
" where:\n"
" 0 stop unit (e.g. spin down a disk or a "
@@ -124,10 +136,14 @@ void usage_old()
" --loej load the medium if '-start' option is "
"also given\n"
" or stop unit and eject\n"
- " --pc=PC power conditions (in hex, default 0 -> no "
+ " --mod=PC_MOD power condition modifier "
+ "(def: 0) (sbc)\n"
+ " --noflush no flush prior to operation that limits "
+ "access (sbc)\n"
+ " --pc=PC power condition (in hex, default 0 -> no "
"power condition)\n"
" 1 -> active, 2 -> idle, 3 -> standby, "
- "5 -> sleep (MMC)\n"
+ "5 -> sleep (mmc)\n"
" --start start unit (same as '1'), default "
"action\n"
" --stop stop unit (same as '0')\n"
@@ -140,14 +156,15 @@ void usage_old()
);
}
-static int process_cl_new(struct opts_t * optsp, int argc, char * argv[])
+static int
+process_cl_new(struct opts_t * optsp, int argc, char * argv[])
{
int c, n, err;
while (1) {
int option_index = 0;
- c = getopt_long(argc, argv, "ef:hilLNOp:sSvV", long_options,
+ c = getopt_long(argc, argv, "ef:hilLm:nNOp:sSvV", long_options,
&option_index);
if (c == -1)
break;
@@ -182,6 +199,18 @@ static int process_cl_new(struct opts_t * optsp, int argc, char * argv[])
case 'L':
++optsp->do_loej;
break;
+ case 'm':
+ n = sg_get_num(optarg);
+ if ((n < 0) || (n > 15)) {
+ fprintf(stderr, "bad argument to '--mod='\n");
+ usage();
+ return SG_LIB_SYNTAX_ERROR;
+ }
+ optsp->do_mod = n;
+ break;
+ case 'n':
+ ++optsp->do_noflush;
+ break;
case 'N':
break; /* ignore */
case 'O':
@@ -241,7 +270,8 @@ static int process_cl_new(struct opts_t * optsp, int argc, char * argv[])
return 0;
}
-static int process_cl_old(struct opts_t * optsp, int argc, char * argv[])
+static int
+process_cl_old(struct opts_t * optsp, int argc, char * argv[])
{
int k, jmp_out, plen, num;
int ambigu = 0;
@@ -334,6 +364,16 @@ static int process_cl_old(struct opts_t * optsp, int argc, char * argv[])
return SG_LIB_SYNTAX_ERROR;
}
optsp->do_pc = u;
+ } else if (0 == strncmp("mod=", cp, 4)) {
+ num = sscanf(cp + 3, "%x", &u);
+ if (1 != num) {
+ fprintf(stderr, "Bad value after 'mod=' option\n");
+ usage_old();
+ return SG_LIB_SYNTAX_ERROR;
+ }
+ optsp->do_mod = u;
+ } else if (0 == strncmp(cp, "noflush", 7)) {
+ optsp->do_noflush = 1;
} else if (0 == strncmp(cp, "start", 5)) {
if (startstop == 0)
ambigu = 1;
@@ -382,7 +422,8 @@ static int process_cl_old(struct opts_t * optsp, int argc, char * argv[])
return 0;
}
-static int process_cl(struct opts_t * optsp, int argc, char * argv[])
+static int
+process_cl(struct opts_t * optsp, int argc, char * argv[])
{
int res;
char * cp;
@@ -403,7 +444,8 @@ static int process_cl(struct opts_t * optsp, int argc, char * argv[])
}
-int main(int argc, char * argv[])
+int
+main(int argc, char * argv[])
{
int fd, res;
int ret = 0;
@@ -480,11 +522,13 @@ int main(int argc, char * argv[])
1 /*start */, 1 /* noisy */,
opts.do_verbose);
else if (opts.do_pc > 0)
- res = sg_ll_start_stop_unit(fd, opts.do_immed, 0, opts.do_pc, 0, 0,
- 0, 1, opts.do_verbose);
+ res = sg_ll_start_stop_unit(fd, opts.do_immed, opts.do_mod,
+ opts.do_pc, opts.do_noflush, 0, 0, 1,
+ opts.do_verbose);
else
- res = sg_ll_start_stop_unit(fd, opts.do_immed, 0, 0, 0, opts.do_loej,
- opts.do_start, 1, opts.do_verbose);
+ res = sg_ll_start_stop_unit(fd, opts.do_immed, 0, 0, opts.do_noflush,
+ opts.do_loej, opts.do_start, 1,
+ opts.do_verbose);
ret = res;
if (res) {
if (opts.do_verbose < 2) {