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