• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef SG_CMDS_EXTRA_H
2 #define SG_CMDS_EXTRA_H
3 
4 /*
5  * Copyright (c) 2004-2018 Douglas Gilbert.
6  * All rights reserved.
7  * Use of this source code is governed by a BSD-style
8  * license that can be found in the BSD_LICENSE file.
9  */
10 
11 #include <stdint.h>
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 /* Note: all functions that have an 'int timeout_secs' argument will use
18  * that value if it is > 0. Otherwise they will set an internal default
19  * which is currently 60 seconds. This timeout is typically applied in the
20  * SCSI stack above the initiator. If it goes off then the SCSI command is
21  * aborted and there can be other unwelcome side effects. Note that some
22  * commands (e.g. FORMAT UNIT and the Third Party copy commands) can take
23  * a lot longer than the default timeout. */
24 
25 
26 /* Invokes a ATA PASS-THROUGH (12, 16 or 32) SCSI command (SAT). This is
27  * selected by the cdb_len argument that can take values of 12, 16 or 32
28  * only (else -1 is returned). The byte at offset 0 (and bytes 0 to 9
29  * inclusive for ATA PT(32)) pointed to be cdbp are ignored and apart from
30  * the control byte, the rest is copied into an internal cdb which is then
31  * sent to the device. The control byte is byte 11 for ATA PT(12), byte 15
32  * for ATA PT(16) and byte 1 for ATA PT(32). If timeout_secs <= 0 then the
33  * timeout is set to 60 seconds. For data in or out transfers set dinp or
34  * doutp, and dlen to the number of bytes to transfer. If dlen is zero then
35  * no data transfer is assumed. If sense buffer obtained then it is written
36  * to sensep, else sensep[0] is set to 0x0. If ATA return descriptor is
37  * obtained then written to ata_return_dp, else ata_return_dp[0] is set to
38  * 0x0. Either sensep or ata_return_dp (or both) may be NULL pointers.
39  * Returns SCSI status value (>= 0) or -1 if other error. Users are
40  * expected to check the sense buffer themselves. If available the data in
41  * resid is written to residp. Note in SAT-2 and later, fixed format sense
42  * data may be placed in *sensep in which case sensep[0]==0x70, prior to
43  * SAT-2 descriptor sense format was required (i.e. sensep[0]==0x72).
44  */
45 int sg_ll_ata_pt(int sg_fd, const unsigned char * cdbp, int cdb_len,
46                  int timeout_secs,  void * dinp, void * doutp, int dlen,
47                  unsigned char * sensep, int max_sense_len,
48                  unsigned char * ata_return_dp, int max_ata_return_len,
49                  int * residp, int verbose);
50 
51 /* Invokes a FORMAT UNIT (SBC-3) command. Return of 0 -> success,
52  * SG_LIB_CAT_INVALID_OP -> Format unit not supported,
53  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
54  * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
55  * -1 -> other failure. Note that sg_ll_format_unit2() and
56  * sg_ll_format_unit_v2() are the same, both add the ffmt argument. */
57 int sg_ll_format_unit(int sg_fd, int fmtpinfo, bool longlist, bool fmtdata,
58                       bool cmplist, int dlist_format, int timeout_secs,
59                       void * paramp, int param_len, bool noisy, int verbose);
60 int sg_ll_format_unit2(int sg_fd, int fmtpinfo, bool longlist, bool fmtdata,
61                        bool cmplist, int dlist_format, int ffmt,
62                        int timeout_secs, void * paramp, int param_len,
63                        bool noisy, int verbose);
64 int sg_ll_format_unit_v2(int sg_fd, int fmtpinfo, bool longlist, bool fmtdata,
65                          bool cmplist, int dlist_format, int ffmt,
66                          int timeout_secs, void * paramp, int param_len,
67                          bool noisy, int verbose);
68 
69 /* Invokes a SCSI GET LBA STATUS(16) or GET LBA STATUS(32) command (SBC).
70  * Returns 0 -> success,
71  * SG_LIB_CAT_INVALID_OP -> GET LBA STATUS(16 or 32) not supported,
72  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND,
73  * SG_LIB_CAT_NOT_READY -> device not ready, -1 -> other failure.
74  * sg_ll_get_lba_status() calls the 16 byte variant with rt=0 . */
75 int sg_ll_get_lba_status(int sg_fd, uint64_t start_llba, void * resp,
76                          int alloc_len, bool noisy, int verbose);
77 int sg_ll_get_lba_status16(int sg_fd, uint64_t start_llba, uint8_t rt,
78                            void * resp, int alloc_len, bool noisy,
79                            int verbose);
80 int sg_ll_get_lba_status32(int sg_fd, uint64_t start_llba, uint32_t scan_len,
81                            uint32_t element_id, uint8_t rt,
82                            void * resp, int alloc_len, bool noisy,
83                            int verbose);
84 
85 /* Invokes a SCSI PERSISTENT RESERVE IN command (SPC). Returns 0
86  * when successful, SG_LIB_CAT_INVALID_OP if command not supported,
87  * SG_LIB_CAT_ILLEGAL_REQ if field in cdb not supported,
88  * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, else -1 */
89 int sg_ll_persistent_reserve_in(int sg_fd, int rq_servact, void * resp,
90                                 int mx_resp_len, bool noisy, int verbose);
91 
92 /* Invokes a SCSI PERSISTENT RESERVE OUT command (SPC). Returns 0
93  * when successful, SG_LIB_CAT_INVALID_OP if command not supported,
94  * SG_LIB_CAT_ILLEGAL_REQ if field in cdb not supported,
95  * SG_LIB_CAT_UNIT_ATTENTION, SG_LIB_CAT_ABORTED_COMMAND, else -1 */
96 int sg_ll_persistent_reserve_out(int sg_fd, int rq_servact, int rq_scope,
97                                  unsigned int rq_type, void * paramp,
98                                  int param_len, bool noisy, int verbose);
99 
100 /* Invokes a SCSI READ BLOCK LIMITS command. Return of 0 -> success,
101  * SG_LIB_CAT_INVALID_OP -> READ BLOCK LIMITS not supported,
102  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND,
103  * SG_LIB_NOT_READY (shouldn't happen), -1 -> other failure */
104 int sg_ll_read_block_limits(int sg_fd, void * resp, int mx_resp_len,
105                             bool noisy, int verbose);
106 
107 /* Invokes a SCSI READ BUFFER command (SPC). Return of 0 ->
108  * success, SG_LIB_CAT_INVALID_OP -> invalid opcode,
109  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
110  * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
111  * -1 -> other failure */
112 int sg_ll_read_buffer(int sg_fd, int mode, int buffer_id, int buffer_offset,
113                       void * resp, int mx_resp_len, bool noisy, int verbose);
114 
115 /* Invokes a SCSI READ DEFECT DATA (10) command (SBC). Return of 0 ->
116  * success, SG_LIB_CAT_INVALID_OP -> invalid opcode,
117  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
118  * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
119  * -1 -> other failure */
120 int sg_ll_read_defect10(int sg_fd, bool req_plist, bool req_glist,
121                         int dl_format, void * resp, int mx_resp_len,
122                         bool noisy, int verbose);
123 
124 /* Invokes a SCSI READ LONG (10) command (SBC). Note that 'xfer_len'
125  * is in bytes. Returns 0 -> success,
126  * SG_LIB_CAT_INVALID_OP -> READ LONG(10) not supported,
127  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb,
128  * SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO -> bad field in cdb, with info
129  * field written to 'offsetp', SG_LIB_CAT_UNIT_ATTENTION,
130  * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
131  * -1 -> other failure */
132 int sg_ll_read_long10(int sg_fd, bool pblock, bool correct, unsigned int lba,
133                       void * resp, int xfer_len, int * offsetp, bool noisy,
134                       int verbose);
135 
136 /* Invokes a SCSI READ LONG (16) command (SBC). Note that 'xfer_len'
137  * is in bytes. Returns 0 -> success,
138  * SG_LIB_CAT_INVALID_OP -> READ LONG(16) not supported,
139  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb,
140  * SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO -> bad field in cdb, with info
141  * field written to 'offsetp', SG_LIB_CAT_UNIT_ATTENTION,
142  * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
143  *  -1 -> other failure */
144 int sg_ll_read_long16(int sg_fd, bool pblock, bool correct, uint64_t llba,
145                       void * resp, int xfer_len, int * offsetp, bool noisy,
146                       int verbose);
147 
148 /* Invokes a SCSI READ MEDIA SERIAL NUMBER command. Return of 0 -> success,
149  * SG_LIB_CAT_INVALID_OP -> Read media serial number not supported,
150  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
151  * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
152  * -1 -> other failure */
153 int sg_ll_read_media_serial_num(int sg_fd, void * resp, int mx_resp_len,
154                                 bool noisy, int verbose);
155 
156 /* Invokes a SCSI REASSIGN BLOCKS command.  Return of 0 -> success,
157  * SG_LIB_CAT_INVALID_OP -> invalid opcode, SG_LIB_CAT_UNIT_ATTENTION,
158  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND,
159  * SG_LIB_CAT_NOT_READY -> device not ready, -1 -> other failure */
160 int sg_ll_reassign_blocks(int sg_fd, bool longlba, bool longlist,
161                           void * paramp, int param_len, bool noisy,
162                           int verbose);
163 
164 /* Invokes a SCSI RECEIVE DIAGNOSTIC RESULTS command. Return of 0 -> success,
165  * SG_LIB_CAT_INVALID_OP -> Receive diagnostic results not supported,
166  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
167  * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
168  * -1 -> other failure */
169 int sg_ll_receive_diag(int sg_fd, bool pcv, int pg_code, void * resp,
170                        int mx_resp_len, bool noisy, int verbose);
171 
172 /* Same as sg_ll_receive_diag() but with added timeout_secs and residp
173  * arguments. Adds the ability to set the command abort timeout
174  * and the ability to report the residual count. If timeout_secs is zero
175  * or less the default command abort timeout (60 seconds) is used.
176  * If residp is non-NULL then the residual value is written where residp
177  * points. A residual value of 0 implies mx_resp_len bytes have be written
178  * where resp points. If the residual value equals mx_resp_len then no
179  * bytes have been written. */
180 int sg_ll_receive_diag_v2(int sg_fd, bool pcv, int pg_code, void * resp,
181                           int mx_resp_len, int timeout_secs, int * residp,
182                           bool noisy, int verbose);
183 
184 /* Invokes a SCSI REPORT IDENTIFYING INFORMATION command. This command was
185  * called REPORT DEVICE IDENTIFIER prior to spc4r07. Return of 0 -> success,
186  * SG_LIB_CAT_INVALID_OP -> Report identifying information not supported,
187  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
188  * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
189  * -1 -> other failure */
190 int sg_ll_report_id_info(int sg_fd, int itype, void * resp, int max_resp_len,
191                          bool noisy, int verbose);
192 
193 /* Invokes a SCSI REPORT TARGET PORT GROUPS command. Return of 0 -> success,
194  * SG_LIB_CAT_INVALID_OP -> Report Target Port Groups not supported,
195  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND,
196  * SG_LIB_CAT_UNIT_ATTENTION, -1 -> other failure */
197 int sg_ll_report_tgt_prt_grp(int sg_fd, void * resp, int mx_resp_len,
198                              bool noisy, int verbose);
199 int sg_ll_report_tgt_prt_grp2(int sg_fd, void * resp, int mx_resp_len,
200                               bool extended, bool noisy, int verbose);
201 
202 /* Invokes a SCSI SET TARGET PORT GROUPS command. Return of 0 -> success,
203  * SG_LIB_CAT_INVALID_OP -> Report Target Port Groups not supported,
204  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND,
205  * SG_LIB_CAT_UNIT_ATTENTION, -1 -> other failure */
206 int sg_ll_set_tgt_prt_grp(int sg_fd, void * paramp, int param_len, bool noisy,
207                           int verbose);
208 
209 /* Invokes a SCSI REPORT REFERRALS command. Return of 0 -> success,
210  * SG_LIB_CAT_INVALID_OP -> Report Referrals not supported,
211  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND,
212  * SG_LIB_CAT_UNIT_ATTENTION, -1 -> other failure */
213 int sg_ll_report_referrals(int sg_fd, uint64_t start_llba, bool one_seg,
214                            void * resp, int mx_resp_len, bool noisy,
215                            int verbose);
216 
217 /* Invokes a SCSI SEND DIAGNOSTIC command. Foreground, extended self tests can
218  * take a long time, if so set long_duration flag in which case the timeout
219  * is set to 7200 seconds; if the value of long_duration is > 7200 then that
220  * value is taken as the timeout value in seconds. Return of 0 -> success,
221  * SG_LIB_CAT_INVALID_OP -> Send diagnostic not supported,
222  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
223  * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
224  * -1 -> other failure */
225 int sg_ll_send_diag(int sg_fd, int st_code, bool pf_bit, bool st_bit,
226                     bool devofl_bit, bool unitofl_bit, int long_duration,
227                     void * paramp, int param_len, bool noisy, int verbose);
228 
229 /* Invokes a SCSI SET IDENTIFYING INFORMATION command. This command was
230  * called SET DEVICE IDENTIFIER prior to spc4r07. Return of 0 -> success,
231  * SG_LIB_CAT_INVALID_OP -> Set identifying information not supported,
232  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
233  * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
234  * -1 -> other failure */
235 int sg_ll_set_id_info(int sg_fd, int itype, void * paramp, int param_len,
236                       bool noisy, int verbose);
237 
238 /* Invokes a SCSI UNMAP (SBC-3) command. Return of 0 -> success,
239  * SG_LIB_CAT_INVALID_OP -> command not supported,
240  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_ABORTED_COMMAND,
241  * SG_LIB_CAT_UNIT_ATTENTION, -1 -> other failure */
242 int sg_ll_unmap(int sg_fd, int group_num, int timeout_secs, void * paramp,
243                 int param_len, bool noisy, int verbose);
244 /* Invokes a SCSI UNMAP (SBC-3) command. Version 2 adds anchor field
245  * (sbc3r22). Otherwise same as sg_ll_unmap() . */
246 int sg_ll_unmap_v2(int sg_fd, bool anchor, int group_num, int timeout_secs,
247                    void * paramp, int param_len, bool noisy, int verbose);
248 
249 /* Invokes a SCSI VERIFY (10) command (SBC and MMC).
250  * Note that 'veri_len' is in blocks while 'data_out_len' is in bytes.
251  * Returns of 0 -> success,
252  * SG_LIB_CAT_INVALID_OP -> Verify(10) not supported,
253  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
254  * SG_LIB_CAT_MEDIUM_HARD -> medium or hardware error, no valid info,
255  * SG_LIB_CAT_MEDIUM_HARD_WITH_INFO -> as previous, with valid info,
256  * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
257  * SG_LIB_CAT_MISCOMPARE, -1 -> other failure */
258 int sg_ll_verify10(int sg_fd, int vrprotect, bool dpo, int bytechk,
259                    unsigned int lba, int veri_len, void * data_out,
260                    int data_out_len, unsigned int * infop, bool noisy,
261                    int verbose);
262 
263 /* Invokes a SCSI VERIFY (16) command (SBC).
264  * Note that 'veri_len' is in blocks while 'data_out_len' is in bytes.
265  * Returns of 0 -> success,
266  * SG_LIB_CAT_INVALID_OP -> Verify(16) not supported,
267  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
268  * SG_LIB_CAT_MEDIUM_HARD -> medium or hardware error, no valid info,
269  * SG_LIB_CAT_MEDIUM_HARD_WITH_INFO -> as previous, with valid info,
270  * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
271  * SG_LIB_CAT_MISCOMPARE, -1 -> other failure */
272 int sg_ll_verify16(int sg_fd, int vrprotect, bool dpo, int bytechk,
273                    uint64_t llba, int veri_len, int group_num,
274                    void * data_out, int data_out_len, uint64_t * infop,
275                    bool noisy, int verbose);
276 
277 /* Invokes a SCSI WRITE BUFFER command (SPC). Return of 0 ->
278  * success, SG_LIB_CAT_INVALID_OP -> invalid opcode,
279  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
280  * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
281  * -1 -> other failure */
282 int sg_ll_write_buffer(int sg_fd, int mode, int buffer_id, int buffer_offset,
283                        void * paramp, int param_len, bool noisy, int verbose);
284 
285 /* Invokes a SCSI WRITE BUFFER command (SPC). Return of 0 ->
286  * success, SG_LIB_CAT_INVALID_OP -> invalid opcode,
287  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
288  * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
289  * -1 -> other failure. Adds mode specific field (spc4r32) and timeout
290  *  to command abort to override default of 60 seconds. If timeout_secs is
291  *  0 or less then the default timeout is used instead. */
292 int
293 sg_ll_write_buffer_v2(int sg_fd, int mode, int m_specific, int buffer_id,
294                       uint32_t buffer_offset, void * paramp,
295                       uint32_t param_len, int timeout_secs, bool noisy,
296                       int verbose);
297 
298 /* Invokes a SCSI WRITE LONG (10) command (SBC). Note that 'xfer_len'
299  * is in bytes. Returns 0 -> success,
300  * SG_LIB_CAT_INVALID_OP -> WRITE LONG(10) not supported,
301  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb,
302  * SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO -> bad field in cdb, with info
303  * field written to 'offsetp', SG_LIB_CAT_UNIT_ATTENTION,
304  * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
305  * -1 -> other failure */
306 int sg_ll_write_long10(int sg_fd, bool cor_dis, bool wr_uncor, bool pblock,
307                        unsigned int lba, void * data_out, int xfer_len,
308                        int * offsetp, bool noisy, int verbose);
309 
310 /* Invokes a SCSI WRITE LONG (16) command (SBC). Note that 'xfer_len'
311  * is in bytes. Returns 0 -> success,
312  * SG_LIB_CAT_INVALID_OP -> WRITE LONG(16) not supported,
313  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb,
314  * SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO -> bad field in cdb, with info
315  * field written to 'offsetp', SG_LIB_CAT_UNIT_ATTENTION,
316  * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
317  * -1 -> other failure */
318 int sg_ll_write_long16(int sg_fd, bool cor_dis, bool wr_uncor, bool pblock,
319                        uint64_t llba, void * data_out, int xfer_len,
320                        int * offsetp, bool noisy, int verbose);
321 
322 /* Invokes a SPC-3 SCSI RECEIVE COPY RESULTS command. In SPC-4 this function
323  * supports all service action variants of the THIRD-PARTY COPY IN opcode.
324  * SG_LIB_CAT_INVALID_OP -> Receive copy results not supported,
325  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
326  * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
327  * -1 -> other failure */
328 int sg_ll_receive_copy_results(int sg_fd, int sa, int list_id, void * resp,
329                                int mx_resp_len, bool noisy, int verbose);
330 
331 /* Invokes a SCSI EXTENDED COPY(LID1) command. For EXTENDED COPY(LID4)
332  * including POPULATE TOKEN and WRITE USING TOKEN use
333  * sg_ll_3party_copy_out().  Return of 0 -> success,
334  * SG_LIB_CAT_INVALID_OP -> Extended copy not supported,
335  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
336  * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
337  * -1 -> other failure */
338 int sg_ll_extended_copy(int sg_fd, void * paramp, int param_len, bool noisy,
339                         int verbose);
340 
341 /* Handles various service actions associated with opcode 0x83 which is
342  * called THIRD PARTY COPY OUT. These include the EXTENDED COPY(LID4),
343  * POPULATE TOKEN and WRITE USING TOKEN commands. Return of 0 -> success,
344  * SG_LIB_CAT_INVALID_OP -> opcode 0x83 not supported,
345  * SG_LIB_CAT_ILLEGAL_REQ -> bad field in cdb, SG_LIB_CAT_UNIT_ATTENTION,
346  * SG_LIB_CAT_NOT_READY -> device not ready, SG_LIB_CAT_ABORTED_COMMAND,
347  * -1 -> other failure */
348 int sg_ll_3party_copy_out(int sg_fd, int sa, unsigned int list_id,
349                           int group_num, int timeout_secs, void * paramp,
350                           int param_len, bool noisy, int verbose);
351 
352 /* Invokes a SCSI PRE-FETCH(10), PRE-FETCH(16) or SEEK(10) command (SBC).
353  * Returns 0 -> success, 25 (SG_LIB_CAT_CONDITION_MET), various SG_LIB_CAT_*
354  * positive values or -1 -> other errors. Note that CONDITION MET status
355  * is returned when immed=true and num_blocks can fit in device's cache,
356  * somewaht strangely, GOOD status (return 0) is returned if num_blocks
357  * cannot fit in device's cache. If do_seek10==true then does a SEEK(10)
358  * command with given lba, if that LBA is < 2**32 . Unclear what SEEK(10)
359  * does, assume it is like PRE-FETCH. If timeout_secs is 0 (or less) then
360  * use DEF_PT_TIMEOUT (60 seconds) as command timeout. */
361 int sg_ll_pre_fetch_x(int sg_fd, bool do_seek10, bool cdb16, bool immed,
362                       uint64_t lba, uint32_t num_blocks, int group_num,
363                       int timeout_secs, bool noisy, int verbose);
364 
365 #ifdef __cplusplus
366 }
367 #endif
368 
369 #endif
370