📄 mtx.h
字号:
/* MTX -- SCSI Tape Attached Medium Control Program Copyright 1997-1998 Leonard N. Zubkoff <lnz@dandelion.com> Changes 1999 Eric Lee Green to add support for multi-drive tape changers. $Date: 2001/06/19 21:51:32 $ $Revision: 1.3 $ See mtx.c for licensing information. */#ifndef MTX_H /* protect against multiple includes... */#define MTX_H 1/* surround all the Unix-stuff w/ifndef VMS */#ifdef VMS#include "[.vms]defs.h"#else /* all the Unix stuff: */#include "config.h" /* all the autoconf stuff. *//* all the general Unix includes: */#include <stdio.h>#include <errno.h>#if HAVE_STDLIB_H# include <stdlib.h>#endif#if HAVE_FCNTL_H# include <fcntl.h>#endif#if HAVE_SYS_TYPES_H# include <sys/types.h>#endif#if HAVE_STRING_H# include <string.h>#else# include <strings.h>#endif#if HAVE_UNISTD_H# include <unistd.h>#endif#if HAVE_STDARG_H# include <stdarg.h>#endif#if HAVE_SYS_STAT_H# include <sys/stat.h>#endif#if HAVE_SYS_IOCTL_H# include <sys/ioctl.h>#endif/* Now greately modified to use GNU Autoconf stuff: *//* If we use the 'sg' interface, like Linux, do this: */#if HAVE_SCSI_SG_H# include <scsi/scsi.h># include <scsi/scsi_ioctl.h># include <scsi/sg.h>typedef int DEVICE_TYPE; /* the sg interface uses this. */# define HAVE_GET_ID_LUN 1 /* signal that we have it... */#endif/* The 'cam' interface, like FreeBSD: */#if HAVE_CAMLIB_H# include <camlib.h> /* easy (?) access to the CAM user library. */# include <cam/cam_ccb.h># include <cam/scsi/scsi_message.h> /* sigh sigh sigh! */typedef struct cam_device *DEVICE_TYPE;#endif/* the 'uscsi' interface, as used on Solaris: */#if HAVE_SYS_SCSI_IMPL_USCSI_H#include <sys/scsi/impl/uscsi.h>typedef int DEVICE_TYPE;#endif/* the scsi_ctl interface, as used on HP/UX: */#if HAVE_SYS_SCSI_CTL_H# include <sys/wsio.h># include <sys/spinlock.h># include <sys/scsi.h># include <sys/scsi_ctl.h> typedef int DEVICE_TYPE;# ifndef VERSION# define VERSION "1.2.12 hbb"# endif#endif/* The 'tm_buf' interface, as used on AIX. */#ifdef HAVE_SYS_SCSI_H#include <sys/scsi.h>#include <sys/scsi_buf.h>#include <sys/devinfo.h> /* devinfo. */typedef struct tm_device_type { int filenum; int id; int lun; char *DeviceName;} *DEVICE_TYPE; #endif /* the 'dslib' interface, as used on SGI. */#if HAVE_DSLIB_H#include <dslib.h>typedef dsreq_t *DEVICE_TYPE; /* 64-bit pointers/32bit int on later sgi? */#endif#if ((defined(__alpha) && defined(__osf__)) || \ defined(ultrix) || defined(__ultrix))#include "du/defs.h"#endif#endif /* VMS protect. *//* Do a test for LITTLE_ENDIAN_BITFIELDS. Use WORDS_BIGENDIAN as set * by configure: */#if WORDS_BIGENDIAN# define BIG_ENDIAN_BITFIELDS#else# define LITTLE_ENDIAN_BITFIELDS#endif/* Get rid of some Hocky Pux defines: */#ifdef S_NO_SENSE#undef S_NO_SENSE#endif#ifdef S_RECOVERED_ERROR#undef S_RECOVERED_ERROR#endif#ifdef S_NOT_READY#undef S_NOT_READY#endif#ifdef S_MEDIUM_ERROR#undef S_MEDIUM_ERROR#endif#ifdef S_HARDWARE_ERROR#undef S_HARDWARE_ERROR#endif#ifdef S_UNIT_ATTENTION#undef S_UNIT_ATTENTION#endif#ifdef S_BLANK_CHECK#undef S_BLANK_CHECK#endif#ifdef S_VOLUME_OVERFLOW#undef S_VOLUME_OVERFLOW#endif/* Note: These are only used for defaults for when we don't have * the element assignment mode page to tell us real amount... */#define MAX_STORAGE_ELEMENTS 64 /* for the BIG jukeboxes! */#define MAX_TRANSFER_ELEMENTS 2 /* we just do dual-drive for now :-} */#define MAX_TRANSPORT_ELEMENTS 1 /* we just do one arm for now... *//* These are flags used for the READ_ELEMENT_STATUS and MOVE_MEDIUM * commands: */typedef struct SCSI_Flags_Struct { unsigned char eepos; unsigned char invert; unsigned char no_attached; /* ignore _attached bit */ unsigned char no_barcodes; /* don't try to get barcodes. */ int numbytes; int elementtype; int numelements; int attached; int has_barcodes;} SCSI_Flags_T;typedef enum { false, true } boolean;typedef enum { Input, Output } Direction_T;typedef unsigned char CDB_T[12];typedef struct Inquiry{#ifdef LITTLE_ENDIAN_BITFIELDS unsigned char PeripheralDeviceType:5; /* Byte 0 Bits 0-4 */ unsigned char PeripheralQualifier:3; /* Byte 0 Bits 5-7 */ unsigned char DeviceTypeModifier:7; /* Byte 1 Bits 0-6 */ boolean RMB:1; /* Byte 1 Bit 7 */ unsigned char ANSI_ApprovedVersion:3; /* Byte 2 Bits 0-2 */ unsigned char ECMA_Version:3; /* Byte 2 Bits 3-5 */ unsigned char ISO_Version:2; /* Byte 2 Bits 6-7 */ unsigned char ResponseDataFormat:4; /* Byte 3 Bits 0-3 */ unsigned char :2; /* Byte 3 Bits 4-5 */ boolean TrmIOP:1; /* Byte 3 Bit 6 */ boolean AENC:1; /* Byte 3 Bit 7 */#else unsigned char PeripheralQualifier:3; /* Byte 0 Bits 5-7 */ unsigned char PeripheralDeviceType:5; /* Byte 0 Bits 0-4 */ boolean RMB:1; /* Byte 1 Bit 7 */ unsigned char DeviceTypeModifier:7; /* Byte 1 Bits 0-6 */ unsigned char ISO_Version:2; /* Byte 2 Bits 6-7 */ unsigned char ECMA_Version:3; /* Byte 2 Bits 3-5 */ unsigned char ANSI_ApprovedVersion:3; /* Byte 2 Bits 0-2 */ boolean AENC:1; /* Byte 3 Bit 7 */ boolean TrmIOP:1; /* Byte 3 Bit 6 */ unsigned char :2; /* Byte 3 Bits 4-5 */ unsigned char ResponseDataFormat:4; /* Byte 3 Bits 0-3 */#endif unsigned char AdditionalLength; /* Byte 4 */ unsigned char :8; /* Byte 5 */#ifdef LITTLE_ENDIAN_BITFIELDS boolean ADDR16:1; /* Byte 6 bit 0 */ boolean Obs6_1:1; /* Byte 6 bit 1 */ boolean Obs6_2:1; /* obsolete */ /* Byte 6 bit 2 */ boolean MChngr:1; /* Media Changer */ /* Byte 6 bit 3 */ boolean MultiP:1; /* Byte 6 bit 4 */ boolean VS:1; /* Byte 6 bit 5 */ boolean EncServ:1; /* Byte 6 bit 6 */ boolean BQue:1; /* Byte 6 bit 7 */#else boolean BQue:1; /* Byte 6 bit 7 */ boolean EncServ:1; /* Byte 6 bit 6 */ boolean VS:1; /* Byte 6 bit 5 */ boolean MultiP:1; /* Byte 6 bit 4 */ boolean MChngr:1; /* Media Changer */ /* Byte 6 bit 3 */ boolean Obs6_2:1; /* obsolete */ /* Byte 6 bit 2 */ boolean Obs6_1:1; /* Byte 6 bit 1 */ boolean ADDR16:1; /* Byte 6 bit 0 */#endif#ifdef LITTLE_ENDIAN_BITFIELDS boolean SftRe:1; /* Byte 7 Bit 0 */ boolean CmdQue:1; /* Byte 7 Bit 1 */ boolean :1; /* Byte 7 Bit 2 */ boolean Linked:1; /* Byte 7 Bit 3 */ boolean Sync:1; /* Byte 7 Bit 4 */ boolean WBus16:1; /* Byte 7 Bit 5 */ boolean WBus32:1; /* Byte 7 Bit 6 */ boolean RelAdr:1; /* Byte 7 Bit 7 */#else boolean RelAdr:1; /* Byte 7 Bit 7 */ boolean WBus32:1; /* Byte 7 Bit 6 */ boolean WBus16:1; /* Byte 7 Bit 5 */ boolean Sync:1; /* Byte 7 Bit 4 */ boolean Linked:1; /* Byte 7 Bit 3 */ boolean :1; /* Byte 7 Bit 2 */ boolean CmdQue:1; /* Byte 7 Bit 1 */ boolean SftRe:1; /* Byte 7 Bit 0 */#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -