Commit Graph

186 Commits

Author SHA1 Message Date
Bart Van Assche
2a5a0b3291 Enable -Wno-unused-parameter
Instead of adding __attribute__((unused)) to unused arguments, add the
-Wno-unused-parameter compiler flag.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2021-05-23 13:23:41 -07:00
Bart Van Assche
e1978f991a lib: Fix scsi_maintenancein_datain_getfullsize()
Coverity reported dead code.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2020-02-23 20:11:14 -08:00
Ronnie Sahlberg
148e5f69e8 remove FIXME
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2020-02-11 17:06:41 +10:00
Tim Crawford
9347cfebf2 Replace file variables with .dir-locals.el
Signed-off-by: Tim Crawford <tcrawford@datto.com>
2019-02-21 11:54:02 -05:00
Paolo Bonzini
679d0abe7c avoid fallthrough 2018-10-04 14:06:39 +02:00
David Disseldorp
c88e9715ab lib/scsi: fix SCSI_PERSISTENT_RESERVE_READ_KEYS handling
When unmarshalling a SCSI_PERSISTENT_RESERVE_READ_KEYS response,
scsi_persistentreservein_datain_unmarshall() assumes that the ADDITIONAL
LENGTH field represents the number of keys packed in the key array.
This is incorrect as key array data buffer may be truncated while
ADDITIONAL LENGTH is left in tact, as per SPC5r17 4.2.5.6:

  If the information being transferred to the Data-In Buffer includes
  fields containing counts ..., then the contents of these fields shall
  not be altered to reflect the truncation, if any, that results from an
  insufficient ALLOCATION LENGTH value, unless the standard that
  describes the Data-In Buffer format states otherwise.

Determine the number of keys returned based on the minimum of the
data-in length and the ADDITIONAL LENGTH value.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2018-05-31 23:10:28 +02:00
Tim Crawford
aba0f7da1a Replace WIN32 with _WIN32
Using WIN32 depends on the build environment defining the variable.
_WIN32 is a predefined MSVC macro and is always available.

Signed-off-by: Tim Crawford <crawfxrd@gmail.com>
2017-11-29 10:07:44 -05:00
Ronnie Sahlberg
f750101980 Add initial visual studio project files and fix the win32 build
Win32 has been rotting for a while. This patch adds vs17 build files
as well as fixing up all build errors that have accumulated.
There are still build warnings but those can be addressed in a followup
patch.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-05-11 21:19:14 -07:00
Ronnie Sahlberg
178b3ec5b9 XCOPY: Only set the write flag if we actually have DATA-OUT
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2017-01-07 08:57:45 -08:00
Ronnie Sahlberg
39001203b7 TESTS: simple support for READDEFECTDATA10/12
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-09-22 22:43:16 -07:00
Peter Lieven
20e1182b3e scsi-lowlevel: add more pagecodes to scsi_inquiry_pagecode_to_str
add reverse mappings for all members of: enum scsi_inquiry_pagecode

Signed-off-by: Peter Lieven <pl@kamp.de>
2016-07-07 11:30:34 +02:00
Ronnie Sahlberg
a6fc65b4ef Tests: remove the warning if a SSD supports SANITIZE/OVERWRITE
There is technically no reason why a SSD with (assumingly with thin
provisioning) can not support SANITIZE/OVERWRITE instead or or in addition
to the more expected SANITIZE/BLOCK-ERASE so remove the warning for this.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-05-01 12:35:29 -07:00
Ronnie Sahlberg
b240bf1a2c Don't free() things allicated through scsi_malloc()
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-02-20 14:27:52 -08:00
Ronnie Sahlberg
99a5f99527 Add some emacs defaults. Tabs are 8 spaces.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2016-02-18 21:34:43 -08:00
Ronnie Sahlberg
7b8363827b libiscsi: Fix RECEIVE COPY RESULTS response unmarshalling
Allocate the correct amount of memory for the scsi_copy_results_copy_status
and scsi_copy_results_op_params structures.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-12-24 10:36:04 -08:00
Bart Van Assche
608dbcba12 scsi-lowlevel.c: Use sizeof() instead of a hardcoded constant
This patch does not change any functionality.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
2015-10-07 07:42:30 -07:00
David Disseldorp
ef8e59a24d lib/scsi: fix PRin REPORT CAPS allow_cmds unmarshalling
The Persistent Reserve In REPORT CAPABILITIES response carries the
ALLOW COMMANDS field in bits 4-6 at byte offset 3.
Bit 7 (TMV) should be masked out during ALLOW COMMANDS unmarshalling.

Signed-off-by: David Disseldorp <ddiss@suse.de>
2015-09-30 11:00:13 +02:00
Ronnie Sahlberg
80b81772e2 Add unmarshalling of VPD BLock Limits settings for atomic writes
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-09 06:49:41 -07:00
Ronnie Sahlberg
02fd6217cb Add support for WRITE_ATOMIC_16
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-09-08 10:16:57 -07:00
Ronnie Sahlberg
a6f7c06119 Add support and tests for ExtendedCopy and ReceiveCopyResults
From sushma.gurram@sandisk.com
Add support to libiscsi and tests for these two opcodes.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-08-02 12:57:21 -07:00
Ronnie Sahlberg
2f94f16d02 iovectors: don't reset nalloc when resetting an iovector
Don't reset nalloc when resetting an iovector during reconnect.
Resetting offset/consumed should be sufficient.

Also, don't reset the iovectors when we detect an error condition in
iscsi_iovector_readv_writev. If there is a bug feeding an invalid
pos into this function, where pos suddently points before the amount
of data we have already read/written, then singlan this as an error
and return -EINVAL.

Previosly we did not reset the iovectors correctly when we re-queued
PDUs after a reconnect and thus relied on the iovectors being automatically
reset if/when we detected this type of error in readv_writev.
Now we do reset the iovectors properly so we do nt need to atuo reset them
here anymore and we can change this check to test for and abort the transfer
if an error is detected.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-03-22 08:20:29 -07:00
Ronnie Sahlberg
6822baee3f reconnect: we need to reset the in/out iovectors on reconnect
This is a bug that has been there a long time.
When we reconnect and requeue a PDU we must reset the iovectors
for the task. Otherwise, any partially sent/received data when the
command is reconnected would end up containing garbage.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2015-02-24 06:54:18 -08:00
Ronnie Sahlberg
7865a8a26e Merge branch 'sgio' 2014-12-21 15:07:40 -08:00
Ronnie Sahlberg
8c4a579cda SCSI: scsi_task_get_status add getter function for task status and sense
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-12-19 08:33:21 -08:00
Ronnie Sahlberg
0c6e3bffb3 SCSI: scsi_create_task must set task->cdb_size
We forgot to set task->cdb_size which means all tasks we create with this
function becomes test unit ready :-(

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-12-18 09:20:17 -08:00
Ronnie Sahlberg
14461757c4 TESTS: Allow Hardware/Software write protect as valid ASCQ
Add 0x2701/0x2702 to the list of valid ASCQ values we accept for devices
that are write protected.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-10-08 06:23:43 -07:00
Ronnie Sahlberg
f3205bb095 scsi-lowlevel.c: check that task/datain are valid before we unmarshalling
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-27 09:49:52 -07:00
Ronnie Sahlberg
9e514fbf44 scsi-lowlevel.c: check that task/datain are valid before we unmarshalling
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-09-27 09:48:16 -07:00
Bart Van Assche
ded75ae18a Fix WRITE SAME data buffer length handling
From the SPC-4 paragraph about WRITE SAME(10): "The WRITE SAME (10)
command requests that the device server transfer a single logical
block from the Data-Out Buffer [ ... ]". Hence always pass a data
buffer when sending a WRITE SAME(10) command.

Set the NDOB bit in the WRITE SAME(16) command if no data out buffer
is present.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2014-08-21 06:42:49 -07:00
Ronnie Sahlberg
717b95cb8a slist.h: rename SLIST_ to ISCSI_LIST_ to avoid clash on *BSD
Rename the macros for managing the linked lists from SLIST_* to ISCSI_LIST_*
to avoid a clash on *BSD which already have other macros SLIST_*

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2014-05-07 06:44:19 -07:00
Bart Van Assche
3fdc3f2327 lib: Fix a memory leak in scsi_cdb_persistent_reserve_out()
If scsi_cdb_persistent_reserve_out() succeeds a call to
scsi_free_scsi_task() won't free any memory allocated with scsi_malloc()
in this function because the memset() call in this function overwrites
the task->mem pointer. Move the memset() call up such that it doesn't
clear task->mem. This makes it possible for the caller of this function
to free the memory allocated by this function by calling
scsi_free_scsi_task(). Merge the error handling code such that the code
for freeing memory only occurs once.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2013-10-23 05:33:07 -07:00
Bart Van Assche
afa076b537 lib: Make scsi_free_scsi_task() accept a NULL task pointer
Several cleanup paths can be simplified if it is allowed to pass a
NULL pointer to scsi_free_scsi_task(). Hence modify this function
such that it returns immediately if passed a NULL task pointer.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
2013-10-23 05:32:21 -07:00
Edward Tomasz Napierala
dd1ca33094 Freebsd build fixes. 2013-10-13 15:35:00 +02:00
Ronnie Sahlberg
d7b7c7727a Fix win32 so it works again 2013-10-05 15:34:56 -07:00
Ronnie Sahlberg
8aa6d9de8f TESTS: Add a test for COMPARE_AND_WRITE when the data to verify does not match 2013-09-23 21:58:55 -07:00
Ronnie Sahlberg
a9b75b96a3 SCSI: Add definitions for some more 0x29xx ASCQs
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2013-09-22 17:09:11 -07:00
Ronnie Sahlberg
9f1a28f753 TESTS: Add an initial simple test for COMPARE_AND_WRITE
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
2013-09-22 17:02:30 -07:00
Ronnie Sahlberg
9b40f0a94d Merge pull request #75 from sitsofe/clang
Fix compilation issues under clang
2013-09-10 06:24:08 -07:00
Sitsofe Wheeler
7692027d6c Fix compilation issues under clang
clang defaults to c99 so remove inline statements
(http://clang.llvm.org/compatibility.html#inline ) on functions shared
across different translation units.
clang's linker doesn't like major numbers over 255 so change how SOREL
is generated in Makefile.am.
2013-09-09 18:04:06 +01:00
Sitsofe Wheeler
0b6b12ba53 TESTS: Fix COMPAREANDWRITE tests to send write data
Previously COMPAREANDWRITE was only sending verify instance data which
can cause targets to generate COMMAND ABORTED/NOT ENOUGH UNSOLICITED
DATA errors due to the buffer being obviously too small to contain
verify AND write instance data.

The buffer size check has been modified and compareandwrite tests
updated to pass a larger buffer with interesting write instance data.
2013-09-09 17:48:13 +01:00
Ronnie Sahlberg
6041dcd136 Add a new function to create a scsi_task using an existing CDB 2013-08-04 14:35:58 -07:00
Paolo Bonzini
31a3aeb0e0 fix another aliasing problem
scsi_set_uint64 should just use scsi_set_uint32, similar to
what scsi_get_uint64 does.  This avoids problems on architectures
where "uint32_t" requires more alignment than "char", e.g. ARM.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-08-02 14:07:42 +02:00
Ronnie Sahlberg
83a0cd90f9 Add SANITIZE_IN_PROGRESS ASCQ 2013-07-21 09:55:35 -07:00
Ronnie Sahlberg
52a83e91af Add POWER_CONDITION modepage marshalling/unmarshalling 2013-07-20 15:35:38 -07:00
Ronnie Sahlberg
fd38ff4bfc Add MODESENSE6/10 and MODESELECT6/10 support 2013-07-20 14:05:20 -07:00
Ronnie Sahlberg
e556a0399b SCSI MODESELECT: leave the 4/8 byte header completely blank.
The convention is to not fill this header in when sending modeselect to a target
2013-07-20 09:08:52 -07:00
Ronnie Sahlberg
9e9ca71247 Modesense6 decoding bugs, start preparing for modesense10 decoding 2013-07-08 01:31:03 -07:00
Ronnie Sahlberg
ebb1f06830 Add parameter list length error sense code 2013-07-06 23:35:03 -07:00
Ronnie Sahlberg
a51d706d32 Add invalid field in parameter list sense code 2013-07-06 22:35:36 -07:00
Ronnie Sahlberg
7895fb700c Add MODESELECT6 support
Add support for MODESELECT6 and add marshalling functions for the
mode pages we support so far.
2013-07-06 16:11:17 -07:00