This file is indexed.

/usr/include/iscsi/scsi-lowlevel.h is in libiscsi-dev 1.4.0-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
/*
   Copyright (C) 2010 by Ronnie Sahlberg <ronniesahlberg@gmail.com>

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published by
   the Free Software Foundation; either version 2.1 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public License
   along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __scsi_lowlevel_h__
#define __scsi_lowlevel_h__

#define SCSI_CDB_MAX_SIZE			16

enum scsi_opcode {
	SCSI_OPCODE_TESTUNITREADY      = 0x00,
	SCSI_OPCODE_READ6              = 0x08,
	SCSI_OPCODE_INQUIRY            = 0x12,
	SCSI_OPCODE_MODESENSE6         = 0x1a,
	SCSI_OPCODE_READCAPACITY10     = 0x25,
	SCSI_OPCODE_READ10             = 0x28,
	SCSI_OPCODE_WRITE10            = 0x2A,
	SCSI_OPCODE_VERIFY10           = 0x2F,
	SCSI_OPCODE_PREFETCH10         = 0x34,
	SCSI_OPCODE_SYNCHRONIZECACHE10 = 0x35,
	SCSI_OPCODE_WRITE_SAME10       = 0x41,
	SCSI_OPCODE_UNMAP              = 0x42,
	SCSI_OPCODE_READ16             = 0x88,
	SCSI_OPCODE_WRITE16            = 0x8A,
	SCSI_OPCODE_PREFETCH16         = 0x90,
	SCSI_OPCODE_WRITE_SAME16       = 0x93,
	SCSI_OPCODE_SERVICE_ACTION_IN  = 0x9E,
	SCSI_OPCODE_REPORTLUNS         = 0xA0,
	SCSI_OPCODE_READ12             = 0xA8,
	SCSI_OPCODE_WRITE12            = 0xAA
};

enum scsi_service_action_in {
	SCSI_READCAPACITY16            = 0x10
};

/* sense keys */
enum scsi_sense_key {
	SCSI_SENSE_NO_SENSE            = 0x00,
	SCSI_SENSE_RECOVERED_ERROR     = 0x01,
	SCSI_SENSE_NOT_READY           = 0x02,
	SCSI_SENSE_MEDIUM_ERROR        = 0x03,
	SCSI_SENSE_HARDWARE_ERROR      = 0x04,
	SCSI_SENSE_ILLEGAL_REQUEST     = 0x05,
	SCSI_SENSE_UNIT_ATTENTION      = 0x06,
	SCSI_SENSE_DATA_PROTECTION     = 0x07,
	SCSI_SENSE_BLANK_CHECK         = 0x08,
	SCSI_SENSE_VENDOR_SPECIFIC     = 0x09,
	SCSI_SENSE_COPY_ABORTED        = 0x0a,
	SCSI_SENSE_COMMAND_ABORTED     = 0x0b,
	SCSI_SENSE_OBSOLETE_ERROR_CODE = 0x0c,
	SCSI_SENSE_OVERFLOW_COMMAND    = 0x0d,
	SCSI_SENSE_MISCOMPARE          = 0x0e
};

EXTERN const char *scsi_sense_key_str(int key);

/* ascq */
#define SCSI_SENSE_ASCQ_INVALID_OPERATION_CODE		0x2000
#define SCSI_SENSE_ASCQ_LBA_OUT_OF_RANGE		0x2100
#define SCSI_SENSE_ASCQ_INVALID_FIELD_IN_CDB		0x2400
#define SCSI_SENSE_ASCQ_LOGICAL_UNIT_NOT_SUPPORTED	0x2500
#define SCSI_SENSE_ASCQ_BUS_RESET			0x2900
#define SCSI_SENSE_ASCQ_INTERNAL_TARGET_FAILURE	        0x4400

EXTERN const char *scsi_sense_ascq_str(int ascq);


enum scsi_xfer_dir {
	SCSI_XFER_NONE  = 0,
	SCSI_XFER_READ  = 1,
	SCSI_XFER_WRITE = 2
};

struct scsi_reportluns_params {
	int report_type;
};
struct scsi_read6_params {
	uint32_t lba;
	uint32_t num_blocks;
};
struct scsi_read10_params {
	uint32_t lba;
	uint32_t num_blocks;
};
struct scsi_read12_params {
	uint32_t lba;
	uint32_t num_blocks;
};
struct scsi_read16_params {
	uint64_t lba;
	uint32_t num_blocks;
};
struct scsi_write10_params {
	uint32_t lba;
	uint32_t num_blocks;
};
struct scsi_write12_params {
	uint32_t lba;
	uint32_t num_blocks;
};
struct scsi_write16_params {
	uint64_t lba;
	uint32_t num_blocks;
};
struct scsi_verify10_params {
	uint32_t lba;
	uint32_t num_blocks;
	int vprotect;
	int dpo;
	int bytchk;
};
struct scsi_readcapacity10_params {
	int lba;
	int pmi;
};
struct scsi_inquiry_params {
	int evpd;
	int page_code;
};
struct scsi_modesense6_params {
	int dbd;
	int pc;
	int page_code;
	int sub_page_code;
};
struct scsi_serviceactionin_params {
	enum scsi_service_action_in sa;
};

struct scsi_sense {
	unsigned char       error_type;
	enum scsi_sense_key key;
	int                 ascq;
};

struct scsi_data {
	int            size;
	unsigned char *data;
};

struct scsi_allocated_memory {
	struct scsi_allocated_memory *next;
	void                         *ptr;
};

enum scsi_residual {
	SCSI_RESIDUAL_NO_RESIDUAL = 0,
	SCSI_RESIDUAL_UNDERFLOW,
	SCSI_RESIDUAL_OVERFLOW
};

struct scsi_task {
	int status;

	int cdb_size;
	int xfer_dir;
	int expxferlen;
	unsigned char cdb[SCSI_CDB_MAX_SIZE];
	union {
		struct scsi_read6_params           read6;
		struct scsi_read10_params          read10;
		struct scsi_read12_params          read12;
		struct scsi_read16_params          read16;
		struct scsi_write10_params         write10;
		struct scsi_write12_params         write12;
		struct scsi_write16_params         write16;
		struct scsi_verify10_params        verify10;
		struct scsi_readcapacity10_params  readcapacity10;
		struct scsi_reportluns_params      reportluns;
		struct scsi_inquiry_params         inquiry;
		struct scsi_modesense6_params      modesense6;
		struct scsi_serviceactionin_params serviceactionin;
	} params;

	enum scsi_residual residual_status;
	int residual;
	struct scsi_sense sense;
	struct scsi_data datain;
	struct scsi_allocated_memory *mem;

	void *ptr;

	uint32_t itt;
	uint32_t cmdsn;
	uint32_t lun;

	struct scsi_data_buffer *in_buffers;
};

EXTERN void scsi_free_scsi_task(struct scsi_task *task);
EXTERN void scsi_set_task_private_ptr(struct scsi_task *task, void *ptr);
EXTERN void *scsi_get_task_private_ptr(struct scsi_task *task);

/*
 * TESTUNITREADY
 */
EXTERN struct scsi_task *scsi_cdb_testunitready(void);


/*
 * REPORTLUNS
 */
#define SCSI_REPORTLUNS_REPORT_ALL_LUNS				0x00
#define SCSI_REPORTLUNS_REPORT_WELL_KNOWN_ONLY			0x01
#define SCSI_REPORTLUNS_REPORT_AVAILABLE_LUNS_ONLY		0x02

struct scsi_reportluns_list {
	uint32_t num;
	uint16_t luns[0];
};

EXTERN struct scsi_task *scsi_reportluns_cdb(int report_type, int alloc_len);

/*
 * READCAPACITY10
 */
struct scsi_readcapacity10 {
	uint32_t lba;
	uint32_t block_size;
};
EXTERN struct scsi_task *scsi_cdb_readcapacity10(int lba, int pmi);


/*
 * INQUIRY
 */
enum scsi_inquiry_peripheral_qualifier {
	SCSI_INQUIRY_PERIPHERAL_QUALIFIER_CONNECTED     = 0x00,
	SCSI_INQUIRY_PERIPHERAL_QUALIFIER_DISCONNECTED  = 0x01,
	SCSI_INQUIRY_PERIPHERAL_QUALIFIER_NOT_SUPPORTED = 0x03
};

const char *scsi_devqualifier_to_str(
			enum scsi_inquiry_peripheral_qualifier qualifier);

enum scsi_inquiry_peripheral_device_type {
	SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_DIRECT_ACCESS            = 0x00,
	SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_SEQUENTIAL_ACCESS        = 0x01,
	SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_PRINTER                  = 0x02,
	SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_PROCESSOR                = 0x03,
	SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_WRITE_ONCE               = 0x04,
	SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_MMC                      = 0x05,
	SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_SCANNER                  = 0x06,
	SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_OPTICAL_MEMORY           = 0x07,
	SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_MEDIA_CHANGER            = 0x08,
	SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_COMMUNICATIONS           = 0x09,
	SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_STORAGE_ARRAY_CONTROLLER = 0x0c,
	SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_ENCLOSURE_SERVICES       = 0x0d,
	SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_SIMPLIFIED_DIRECT_ACCESS = 0x0e,
	SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_OPTICAL_CARD_READER      = 0x0f,
	SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_BRIDGE_CONTROLLER        = 0x10,
	SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_OSD                      = 0x11,
	SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_AUTOMATION               = 0x12,
	SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_SEQURITY_MANAGER         = 0x13,
	SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_WELL_KNOWN_LUN           = 0x1e,
	SCSI_INQUIRY_PERIPHERAL_DEVICE_TYPE_UNKNOWN                  = 0x1f
};

EXTERN const char *scsi_devtype_to_str(enum scsi_inquiry_peripheral_device_type type);

enum scsi_version {
	SCSI_VERSION_SPC  = 0x03,
	SCSI_VERSION_SPC2 = 0x04,
	SCSI_VERSION_SPC3 = 0x05
};

EXTERN const char *scsi_version_to_str(enum scsi_version version);

enum scsi_inquiry_tpgs {
	SCSI_INQUIRY_TPGS_NO_SUPPORT            = 0x00,
	SCSI_INQUIRY_TPGS_IMPLICIT              = 0x01,
	SCSI_INQUIRY_TPGS_EXPLICIT              = 0x02,
	SCSI_INQUIRY_TPGS_IMPLICIT_AND_EXPLICIT = 0x03
};

struct scsi_inquiry_standard {
	enum scsi_inquiry_peripheral_qualifier periperal_qualifier;
	enum scsi_inquiry_peripheral_device_type periperal_device_type;
	int rmb;
	int version;
	int normaca;
	int hisup;
	int response_data_format;

	int sccs;
	int acc;
	int tpgs;
	int threepc;
	int protect;

	int encserv;
	int multip;
	int addr16;
	int wbus16;
	int sync;
	int cmdque;

	int clocking;
	int qas;
	int ius;

	char vendor_identification[8+1];
	char product_identification[16+1];
	char product_revision_level[4+1];
};

enum scsi_inquiry_pagecode {
	SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES          = 0x00,
	SCSI_INQUIRY_PAGECODE_UNIT_SERIAL_NUMBER           = 0x80,
	SCSI_INQUIRY_PAGECODE_DEVICE_IDENTIFICATION        = 0x83,
	SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS                 = 0xB0,
	SCSI_INQUIRY_PAGECODE_BLOCK_DEVICE_CHARACTERISTICS = 0xB1,
	SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING   = 0xB2
};

EXTERN const char *scsi_inquiry_pagecode_to_str(int pagecode);

struct scsi_inquiry_supported_pages {
	enum scsi_inquiry_peripheral_qualifier periperal_qualifier;
	enum scsi_inquiry_peripheral_device_type periperal_device_type;
	enum scsi_inquiry_pagecode pagecode;

	int num_pages;
	unsigned char *pages;
};

struct scsi_inquiry_block_limits {
	enum scsi_inquiry_peripheral_qualifier periperal_qualifier;
	enum scsi_inquiry_peripheral_device_type periperal_device_type;
	enum scsi_inquiry_pagecode pagecode;

	int wsnz;		   		/* write same no zero */
	uint8_t max_cmp;			/* maximum_compare_and_write_length */
	uint16_t opt_gran;			/* optimal_transfer_length_granularity */
	uint32_t max_xfer_len;			/* maximum_transfer_length */
	uint32_t opt_xfer_len;			/* optimal_transfer_length */
	uint32_t max_prefetch;			/* maximum_prefetched_xdread_xdwrite_transfer_length */
	uint32_t max_unmap;			/* maximum_unmap_lba_count */
	uint32_t max_unmap_bdc;			/* maximum_unmap_block_descriptor_count */
	uint32_t opt_unmap_gran;		/* optimal_unmap_granularity */
	int ugavalid;
	uint32_t unmap_gran_align;		/* unmap_granularity_alignment */
	uint64_t max_ws_len;			/* maximum_write_same_length */
};

struct scsi_inquiry_block_device_characteristics {
	enum scsi_inquiry_peripheral_qualifier periperal_qualifier;
	enum scsi_inquiry_peripheral_device_type periperal_device_type;
	enum scsi_inquiry_pagecode pagecode;

	int medium_rotation_rate;
};

enum scsi_inquiry_provisioning_type {
	PROVISIONING_TYPE_NONE     = 0,
	PROVISIONING_TYPE_RESOURCE = 1,
	PROVISIONING_TYPE_THIN     = 2
};

struct scsi_inquiry_logical_block_provisioning {
	enum scsi_inquiry_peripheral_qualifier periperal_qualifier;
	enum scsi_inquiry_peripheral_device_type periperal_device_type;
	enum scsi_inquiry_pagecode pagecode;

       int threshold_exponent;
       int lbpu;
       int lbpws;
       int lbpws10;
       int lbprz;
       int anc_sup;
       int dp;
       enum scsi_inquiry_provisioning_type provisioning_type;
};

EXTERN struct scsi_task *scsi_cdb_inquiry(int evpd, int page_code, int alloc_len);

struct scsi_inquiry_unit_serial_number {
	enum scsi_inquiry_peripheral_qualifier periperal_qualifier;
	enum scsi_inquiry_peripheral_device_type periperal_device_type;
	enum scsi_inquiry_pagecode pagecode;

	char *usn;
};

enum scsi_protocol_identifier {
	SCSI_PROTOCOL_IDENTIFIER_FIBRE_CHANNEL = 0x00,
	SCSI_PROTOCOL_IDENTIFIER_PARALLEL_SCSI = 0x01,
	SCSI_PROTOCOL_IDENTIFIER_SSA           = 0x02,
	SCSI_PROTOCOL_IDENTIFIER_IEEE_1394     = 0x03,
	SCSI_PROTOCOL_IDENTIFIER_RDMA          = 0x04,
	SCSI_PROTOCOL_IDENTIFIER_ISCSI         = 0x05,
	SCSI_PROTOCOL_IDENTIFIER_SAS           = 0x06,
	SCSI_PROTOCOL_IDENTIFIER_ADT           = 0x07,
	SCSI_PROTOCOL_IDENTIFIER_ATA           = 0x08
};

EXTERN const char *scsi_protocol_identifier_to_str(int identifier);

enum scsi_codeset {
	SCSI_CODESET_BINARY = 0x01,
	SCSI_CODESET_ASCII  = 0x02,
	SCSI_CODESET_UTF8   = 0x03
};

EXTERN const char *scsi_codeset_to_str(int codeset);

enum scsi_association {
	SCSI_ASSOCIATION_LOGICAL_UNIT  = 0x00,
	SCSI_ASSOCIATION_TARGET_PORT   = 0x01,
	SCSI_ASSOCIATION_TARGET_DEVICE = 0x02
};

EXTERN const char *scsi_association_to_str(int association);

enum scsi_designator_type {
	SCSI_DESIGNATOR_TYPE_VENDOR_SPECIFIC             = 0x00,
	SCSI_DESIGNATOR_TYPE_T10_VENDORT_ID              = 0x01,
	SCSI_DESIGNATOR_TYPE_EUI_64                      = 0x02,
	SCSI_DESIGNATOR_TYPE_NAA                         = 0x03,
	SCSI_DESIGNATOR_TYPE_RELATIVE_TARGET_PORT        = 0x04,
	SCSI_DESIGNATOR_TYPE_TARGET_PORT_GROUP           = 0x05,
	SCSI_DESIGNATOR_TYPE_LOGICAL_UNIT_GROUP          = 0x06,
	SCSI_DESIGNATOR_TYPE_MD5_LOGICAL_UNIT_IDENTIFIER = 0x07,
	SCSI_DESIGNATOR_TYPE_SCSI_NAME_STRING            = 0x08
};

EXTERN const char *scsi_designator_type_to_str(int association);

struct scsi_inquiry_device_designator {
	struct scsi_inquiry_device_designator *next;

	enum scsi_protocol_identifier protocol_identifier;
	enum scsi_codeset code_set;
	int piv;
	enum scsi_association association;
	enum scsi_designator_type designator_type;
	int designator_length;
	char *designator;
};

struct scsi_inquiry_device_identification {
	enum scsi_inquiry_peripheral_qualifier periperal_qualifier;
	enum scsi_inquiry_peripheral_device_type periperal_device_type;
	enum scsi_inquiry_pagecode pagecode;

	struct scsi_inquiry_device_designator *designators;
};

/*
 * MODESENSE6
 */
enum scsi_modesense_page_control {
	SCSI_MODESENSE_PC_CURRENT    = 0x00,
	SCSI_MODESENSE_PC_CHANGEABLE = 0x01,
	SCSI_MODESENSE_PC_DEFAULT    = 0x02,
	SCSI_MODESENSE_PC_SAVED      = 0x03
};

struct scsi_mode_page_caching {
	int ic;
	int abpf;
	int cap;
	int disc;
	int size;
	int wce;
	int mf;
	int rcd;

	int demand_read_retention_priority;
	int write_retention_priority;

	int disable_prefetch_transfer_length;
	int minimum_prefetch;
	int maximum_prefetch;
	int maximum_prefetch_ceiling;
       
	int fsw;
	int lbcss;
	int dra;
	int nv_dis;

	int number_of_cache_segments;
	int cache_segment_size;
};

struct scsi_mode_page_disconnect_reconnect {
	int buffer_full_ratio;
	int buffer_empty_ratio;
	int bus_inactivity_limit;
	int disconnect_time_limit;
	int connect_time_limit;
	int maximum_burst_size;
	int emdp;
	int fair_arbitration;
	int dimm;
	int dtdc;
	int first_burst_size;
};

struct scsi_mode_page_informational_exceptions_control {
	int perf;
	int ebf;
	int ewasc;
	int dexcpt;
	int test;
	int ebackerr;
	int logerr;
	int mrie;
	int interval_timer;
	int report_count;
};

enum scsi_modesense_page_code {
	SCSI_MODESENSE_PAGECODE_READ_WRITE_ERROR_RECOVERY = 0x01,
	SCSI_MODESENSE_PAGECODE_DISCONNECT_RECONNECT      = 0x02,
	SCSI_MODESENSE_PAGECODE_VERIFY_ERROR_RECOVERY     = 0x07,
	SCSI_MODESENSE_PAGECODE_CACHING                   = 0x08,
	SCSI_MODESENSE_PAGECODE_XOR_CONTROL               = 0x10,
	SCSI_MODESENSE_PAGECODE_INFORMATIONAL_EXCEPTIONS_CONTROL        = 0x1c,
	SCSI_MODESENSE_PAGECODE_RETURN_ALL_PAGES          = 0x3f
};

struct scsi_mode_page {
       struct scsi_mode_page *next;
       int ps;
       int spf;
       enum scsi_modesense_page_code page_code;
       int subpage_code;
       int len;
       union {
              struct scsi_mode_page_caching caching;
              struct scsi_mode_page_disconnect_reconnect disconnect_reconnect;
	      struct scsi_mode_page_informational_exceptions_control iec;
       };
};

struct scsi_mode_sense {
       uint8_t mode_data_length;
       uint8_t medium_type;
       uint8_t device_specific_parameter;
       uint8_t block_descriptor_length;
       struct scsi_mode_page *pages;       
};

EXTERN struct scsi_task *scsi_cdb_modesense6(int dbd,
			enum scsi_modesense_page_control pc,
			enum scsi_modesense_page_code page_code,
			int sub_page_code,
			unsigned char alloc_len);




struct scsi_readcapacity16 {
       uint64_t returned_lba;
       uint32_t block_length;
       uint8_t  p_type;
       uint8_t  prot_en;
       uint8_t  p_i_exp;
       uint8_t  lbppbe;
       uint8_t  lbpme;
       uint8_t  lbprz;
       uint16_t lalba;
};

EXTERN int scsi_datain_getfullsize(struct scsi_task *task);
EXTERN void *scsi_datain_unmarshall(struct scsi_task *task);

EXTERN struct scsi_task *scsi_cdb_read6(uint32_t lba, uint32_t xferlen, int blocksize);
EXTERN struct scsi_task *scsi_cdb_read10(uint32_t lba, uint32_t xferlen, int blocksize);
EXTERN struct scsi_task *scsi_cdb_read12(uint32_t lba, uint32_t xferlen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group_number);
EXTERN struct scsi_task *scsi_cdb_read16(uint64_t lba, uint32_t xferlen, int blocksize, int rdprotect, int dpo, int fua, int fua_nv, int group_number);
EXTERN struct scsi_task *scsi_cdb_write10(uint32_t lba, uint32_t xferlen, int fua, int fuanv, int blocksize);
EXTERN struct scsi_task *scsi_cdb_write12(uint32_t lba, uint32_t xferlen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group_number);
EXTERN struct scsi_task *scsi_cdb_write16(uint64_t lba, uint32_t xferlen, int blocksize, int wrprotect, int dpo, int fua, int fua_nv, int group_number);
EXTERN struct scsi_task *scsi_cdb_verify10(uint32_t lba, uint32_t xferlen, int vprotect, int dpo, int bytchk, int blocksize);

EXTERN struct scsi_task *scsi_cdb_synchronizecache10(int lba, int num_blocks,
			int syncnv, int immed);
EXTERN struct scsi_task *scsi_cdb_serviceactionin16(enum scsi_service_action_in sa, uint32_t xferlen);
EXTERN struct scsi_task *scsi_cdb_readcapacity16(void);
EXTERN struct scsi_task *scsi_cdb_unmap(int anchor, int group, uint16_t xferlen);
EXTERN struct scsi_task *scsi_cdb_writesame10(int wrprotect, int anchor, int unmap, int pbdata, int lbdata, uint32_t lba, int group, uint16_t num_blocks);
EXTERN struct scsi_task *scsi_cdb_writesame16(int wrprotect, int anchor, int unmap, int pbdata, int lbdata, uint64_t lba, int group, uint32_t num_blocks);
EXTERN struct scsi_task *scsi_cdb_prefetch10(uint32_t lba, int num_blocks, int immed, int group);
EXTERN struct scsi_task *scsi_cdb_prefetch16(uint64_t lba, int num_blocks, int immed, int group);

void *scsi_malloc(struct scsi_task *task, size_t size);

#endif /* __scsi_lowlevel_h__ */