aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2007-06-27 02:58:56 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2007-06-27 02:58:56 +0000
commit0e9184cde6f3d1a0046c706051a4bd4b36a6aede (patch)
treef4ac79c282481f25f14efa9b7d85dce6001832c5 /examples
parent1f7410c00c57dcc2c6b0d64a33431e2298a7c87b (diff)
downloadsg3_utils-0e9184cde6f3d1a0046c706051a4bd4b36a6aede.tar.gz
Load sg3_utils-1.07 into trunk/.
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@39 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'examples')
-rw-r--r--examples/Makefile16
-rw-r--r--examples/sg_err.h29
-rw-r--r--examples/sg_excl.c2
-rw-r--r--examples/sg_include.h4
4 files changed, 43 insertions, 8 deletions
diff --git a/examples/Makefile b/examples/Makefile
index 50043770..0cc7ef1c 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -8,14 +8,17 @@ CC = gcc
LD = gcc
EXECS = sg_simple1 sg_simple2 sg_simple3 sg_simple4 sg_simple16 \
- scsi_inquiry
+ sg_iovec_tst scsi_inquiry sg_excl
+
+# EXECS = sg_simple1 sg_simple2 sg_simple3 sg_simple4 sg_simple16 \
+# sg_simple_aio sg_iovec_tst scsi_inquiry sg_excl
MAN_PGS =
MAN_PREF = man8
LARGE_FILE_FLAGS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
-CFLAGS = -g -O2 -Wall -D_REENTRANT $(LARGE_FILE_FLAGS)
+CFLAGS = -g -O2 -W -Wall -D_REENTRANT $(LARGE_FILE_FLAGS)
# CFLAGS = -g -O2 -Wall -D_REENTRANT -DSG_KERNEL_INCLUDES $(LARGE_FILE_FLAGS)
# CFLAGS = -g -O2 -Wall -pedantic -D_REENTRANT $(LARGE_FILE_FLAGS)
@@ -45,9 +48,18 @@ sg_simple4: sg_simple4.o ../sg_err.o
sg_simple16: sg_simple16.o ../sg_err.o
$(LD) -o $@ $(LDFLAGS) $^
+sg_simple_aio: sg_simple_aio.o ../sg_err.o
+ $(LD) -o $@ $(LDFLAGS) $^ -l aio
+
+sg_iovec_tst: sg_iovec_tst.o ../sg_err.o
+ $(LD) -o $@ $(LDFLAGS) $^
+
scsi_inquiry: scsi_inquiry.o
$(LD) -o $@ $(LDFLAGS) $^
+sg_excl: sg_excl.o ../sg_err.o
+ $(LD) -o $@ $(LDFLAGS) $^
+
install: $(EXECS)
install -d $(INSTDIR)
for name in $^; \
diff --git a/examples/sg_err.h b/examples/sg_err.h
index 317767b6..886bac29 100644
--- a/examples/sg_err.h
+++ b/examples/sg_err.h
@@ -3,7 +3,7 @@
/* Feel free to copy and modify this GPL-ed code into your applications. */
-/* Version 0.89 (20030313)
+/* Version 0.93 (20040708)
*/
@@ -131,6 +131,16 @@ extern int sg_chk_n_print(const char * leadin, int masked_status,
struct sg_io_hdr;
extern int sg_chk_n_print3(const char * leadin, struct sg_io_hdr * hp);
+/* If no sense data returns 0 and places 0 in *response_code (if non-NULL)
+ and *sense_key (if non-NULL). If sense data found returns 1 and outputs
+ to *response_code, *sense_key, *asc and *ascq (those that are non-NULL).
+ Understands both descriptor and fixed sense data format. */
+extern int sg_decode_sense(const struct sg_io_hdr * hp,
+ unsigned char * response_code,
+ unsigned char * sense_key,
+ unsigned char * asc,
+ unsigned char * ascq);
+
/* The following "category" function returns one of the following */
#define SG_ERR_CAT_CLEAN 0 /* No errors or other information */
@@ -153,10 +163,21 @@ extern int sg_err_category_new(int scsi_status, int host_status,
Only version 3 sg_err.c defines it. */
extern int sg_err_category3(struct sg_io_hdr * hp);
-/* Returns length of SCSI command given the opcode (first byte) */
+/* Returns length of SCSI command given the opcode (first byte).
+ Yields the wrong answer for variable length commands (opcode=0x7f)
+ and potentially some vendor specific commands. */
extern int sg_get_command_size(unsigned char opcode);
-extern void sg_get_command_name(unsigned char opcode, int buff_len,
- char * buff);
+/* Command name given pointer to command bytes. Certain command names
+ depend on the service action within the command as well. */
+extern void sg_get_command_name(const unsigned char * cmdp, int peri_type,
+ int buff_len, char * buff);
+
+/* Opcode name given only the first byte (byte 0) of a command */
+extern void sg_get_opcode_name(unsigned char cmd_byte0, int peri_type,
+ int buff_len, char * buff);
+/* Command name given opcode (byte 0) and service action of a command */
+extern void sg_get_opcode_sa_name(unsigned char cmd_byte0, int service_action,
+ int peri_type, int buff_len, char * buff);
#endif
diff --git a/examples/sg_excl.c b/examples/sg_excl.c
index c1271a1d..14bf1731 100644
--- a/examples/sg_excl.c
+++ b/examples/sg_excl.c
@@ -42,7 +42,7 @@
int main(int argc, char * argv[])
{
- int sg_fd, k, ok, sg_fd2;
+ int sg_fd, k, ok /*, sg_fd2 */;
unsigned char inqCmdBlk [INQ_CMD_LEN] =
{0x12, 0, 0, 0, INQ_REPLY_LEN, 0};
unsigned char turCmdBlk [TUR_CMD_LEN] =
diff --git a/examples/sg_include.h b/examples/sg_include.h
index 5baca3cc..6b6dd6f3 100644
--- a/examples/sg_include.h
+++ b/examples/sg_include.h
@@ -1,4 +1,6 @@
#ifdef SG_KERNEL_INCLUDES
+ #define __user
+ typedef unsigned char u8;
#include "/usr/src/linux/include/scsi/sg.h"
#include "/usr/src/linux/include/scsi/scsi.h"
#else
@@ -38,5 +40,5 @@
Sorry about the inconvenience. Typically neither SG_KERNEL_INCLUDES
nor SG_TRICK_GNU_INCLUDES is defined.
- dpg 20010415
+ dpg 20010415, 20030522
*/