aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2009-04-03 03:02:02 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2009-04-03 03:02:02 +0000
commit6803aac2635eff73505e4b8d9c0240cd94855769 (patch)
tree3fe7b7099ac8984cc06b6ed2ffd8a85155244d0e
parentb15dc3d385fa5f94350c0b4f721c026560891d28 (diff)
downloadsg3_utils-6803aac2635eff73505e4b8d9c0240cd94855769.tar.gz
sg_persist: add '--alloc-length=' option
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@243 6180dd3e-e324-4e3e-922d-17de1ae2f315
-rw-r--r--CREDITS7
-rw-r--r--ChangeLog3
-rw-r--r--README2
-rw-r--r--TODO4
-rw-r--r--debian/changelog2
-rw-r--r--doc/sg_persist.87
-rw-r--r--sg3_utils.spec2
-rw-r--r--src/sg_persist.c21
8 files changed, 39 insertions, 9 deletions
diff --git a/CREDITS b/CREDITS
index b9b5c8ff..92b4bf40 100644
--- a/CREDITS
+++ b/CREDITS
@@ -24,7 +24,8 @@ Eric Schwartz <emschwar at debian dot org> who wrote these man pages:
Eric Youngdale <eric at andante dot org> author of scsi_info on which sginfo
is based.
-F. Jansen: additions to sg_scan
+Frank Jansen <fjansen at egenera dot com>: additions to sg_scan; contributed
+ code for '--alloc-length=' option in sg_persist [20090402]
Grant Grundler <grundler at parisc-linux dot org> co-author of blk512-linux
that has become sg_format [20050201]
@@ -46,7 +47,7 @@ James Bottomley <jejb at parisc-linux dot org> co-author of blk512-linux
that has become sg_format [20050201]
Joe Krahn <krahn at niehs dot nih dot gov> help with int64_t cleanup
- [20071219]
+ [20071219]
Kai Makisara <Kai dot Makisara at kolumbus dot fi> help with tape
minor numbers in lk 2.6 plus earlier advice [20081008]
@@ -92,4 +93,4 @@ Trent Piepho <xyzzy at speakeasy dot org> print out some "sense key specific"
Doug Gilbert
-9th October 2008
+2nd April 2009
diff --git a/ChangeLog b/ChangeLog
index 734d01a7..def753c3 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.27 [20090401] [svn: r242]
+Changelog for sg3_utils-1.27 [20090402] [svn: r243]
- sg_write_same: new utility: 10, 16 and 32 byte cdb variants
- sg_inq: sync version descriptors with spc4r18
- add power condition VPD page
@@ -31,6 +31,7 @@ Changelog for sg3_utils-1.27 [20090401] [svn: r242]
- sg_readcap: more protection + thin provisioning (sbc3r18)
- sg_persist: code clean up
- allow '--transport-id=' argument to use space as separator
+ - add '--alloc-length=' argument
- sginfo: fix crash when 1024 sg device nodes (or more)
- sg_ses: allow '--data=' argument to use space as separator
- sg_senddiag: allow '--raw=' argument to use space as separator
diff --git a/README b/README
index e80ad485..8f200ed8 100644
--- a/README
+++ b/README
@@ -321,4 +321,4 @@ See http://sg.danny.cz/sg/tools.html
Doug Gilbert
-31st March 2009
+2nd April 2009
diff --git a/TODO b/TODO
new file mode 100644
index 00000000..29808e4b
--- /dev/null
+++ b/TODO
@@ -0,0 +1,4 @@
+Some suggestions and shortcomings:
+
+ - Win32 version of sg_scan doesn't work well in Vista. Rework scanning
+ logic [20090402]
diff --git a/debian/changelog b/debian/changelog
index 02761cd3..0e35e9af 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> Tue, 31 Mar 2009 21:00:00 -0400
+ -- Doug Gilbert <dgilbert@interlog.com> Thu, 02 Apr 2009 15:00:00 -0400
sg3-utils (1.26-0.1) unstable; urgency=low
diff --git a/doc/sg_persist.8 b/doc/sg_persist.8
index c727567c..8d159a23 100644
--- a/doc/sg_persist.8
+++ b/doc/sg_persist.8
@@ -62,6 +62,13 @@ Arguments to long options are mandatory for short options as well.
The following options are sorted in alphabetical order, based on their
long option name.
.TP
+\fB\-l\fR, \fB\-\-alloc-length\fR=\fILEN\fR
+specify the allocation length of the PRIN command. \fILEN\fR is a hex value.
+By default this value is set to the size of the data\-in buffer (8192).
+This parameter is of use for verification that response to PRIN commands
+with various allocation lengths is per section 4.3.5.6 of SPC\-4 revision 18.
+Valid \fILEN\fR values are 0\-8192.
+.TP
\fB\-C\fR, \fB\-\-clear\fR
Clear is a sub\-command of the PROUT command. It releases the
persistent reservation (if any) and clears all registrations from the
diff --git a/sg3_utils.spec b/sg3_utils.spec
index 72fe024e..b86add74 100644
--- a/sg3_utils.spec
+++ b/sg3_utils.spec
@@ -79,7 +79,7 @@ fi
%{_libdir}/*.la
%changelog
-* Tue Mar 31 2009 - dgilbert at interlog dot com
+* Thu Apr 02 2009 - dgilbert at interlog dot com
- add sg_write_same; sg_dd split; spc4r18 sync
* sg3_utils-1.27
diff --git a/src/sg_persist.c b/src/sg_persist.c
index 96531cad..76dad174 100644
--- a/src/sg_persist.c
+++ b/src/sg_persist.c
@@ -60,11 +60,13 @@ struct opts_t {
unsigned char transportid_arr[MX_ALLOC_LEN];
int transportid_arr_len;
int num_transportids;
+ unsigned int alloc_len;
int verbose;
};
static struct option long_options[] = {
+ {"alloc-length", 1, 0, 'l'},
{"clear", 0, 0, 'C'},
{"device", 1, 0, 'd'},
{"help", 0, 0, 'h'},
@@ -146,6 +148,10 @@ usage()
fprintf(stderr,
"Usage: sg_persist [OPTIONS] [DEVICE]\n"
" where OPTIONS include:\n"
+ " --alloc-length=LEN|-l LEN allocation length hex value "
+ "(used with\n"
+ " PR In only) (default: 8192 "
+ "(2000 in hex))\n"
" --clear|-C PR Out: Clear\n"
" --device=DEVICE|-d DEVICE query or change DEVICE\n"
" --help|-h output this usage message\n"
@@ -308,7 +314,7 @@ prin_work(int sg_fd, const struct opts_t * optsp)
memset(pr_buff, 0, sizeof(pr_buff));
res = sg_ll_persistent_reserve_in(sg_fd, optsp->prin_sa, pr_buff,
- sizeof(pr_buff), 1, optsp->verbose);
+ optsp->alloc_len, 1, optsp->verbose);
if (res) {
if (SG_LIB_CAT_INVALID_OP == res)
fprintf(stderr, "PR in: command not supported\n");
@@ -744,10 +750,11 @@ main(int argc, char * argv[])
opts.prin_sa = -1;
opts.prout_sa = -1;
opts.inquiry = 1;
+ opts.alloc_len = MX_ALLOC_LEN;
while (1) {
int option_index = 0;
- c = getopt_long(argc, argv, "AcCd:GHhiIkK:LMnoPQrRsS:T:UvVX:YZ",
+ c = getopt_long(argc, argv, "AcCd:GHhiIkK:l:LMnoPQrRsS:T:UvVX:YZ",
long_options, &option_index);
if (c == -1)
break;
@@ -796,6 +803,16 @@ main(int argc, char * argv[])
}
++num_prout_param;
break;
+ case 'l':
+ if (1 != sscanf(optarg, "%x", &opts.alloc_len)) {
+ fprintf(stderr, "bad argument to '--alloc-length'\n");
+ return SG_LIB_SYNTAX_ERROR;
+ } else if (MX_ALLOC_LEN < opts.alloc_len) {
+ fprintf(stderr, "'--alloc-length' argument exceeds maximum"
+ " value(%d)\n", MX_ALLOC_LEN);
+ return SG_LIB_SYNTAX_ERROR;
+ }
+ break;
case 'L':
opts.prout_sa = PROUT_REL_SA;
++num_prout_sa;