1 #ifndef SG_LIB_H 2 #define SG_LIB_H 3 4 /* 5 * Copyright (c) 2004-2016 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 /* 12 * 13 * On 5th October 2004 a FreeBSD license was added to this file. 14 * The intention is to keep this file and the related sg_lib.c file 15 * as open source and encourage their unencumbered use. 16 * 17 * Current version number is in the sg_lib.c file and can be accessed 18 * with the sg_lib_version() function. 19 */ 20 21 22 /* 23 * This header file contains defines and function declarations that may 24 * be useful to applications that communicate with devices that use a 25 * SCSI command set. These command sets have names like SPC-4, SBC-3, 26 * SSC-3, SES-2 and draft standards defining them can be found at 27 * http://www.t10.org . Virtually all devices in the Linux SCSI subsystem 28 * utilize SCSI command sets. Many devices in other Linux device subsystems 29 * utilize SCSI command sets either natively or via emulation (e.g. a 30 * parallel ATA disk in a USB enclosure). 31 */ 32 33 #include <stdio.h> 34 #include <stdint.h> 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 /* SCSI Peripheral Device Types (PDT) [5 bit field] */ 41 #define PDT_DISK 0x0 /* direct access block device (disk) */ 42 #define PDT_TAPE 0x1 /* sequential access device (magnetic tape) */ 43 #define PDT_PRINTER 0x2 /* printer device (see SSC-1) */ 44 #define PDT_PROCESSOR 0x3 /* processor device (e.g. SAFTE device) */ 45 #define PDT_WO 0x4 /* write once device (some optical disks) */ 46 #define PDT_MMC 0x5 /* CD/DVD/BD (multi-media) */ 47 #define PDT_SCANNER 0x6 /* obsolete */ 48 #define PDT_OPTICAL 0x7 /* optical memory device (some optical disks) */ 49 #define PDT_MCHANGER 0x8 /* media changer device (e.g. tape robot) */ 50 #define PDT_COMMS 0x9 /* communications device (obsolete) */ 51 #define PDT_SAC 0xc /* storage array controller device */ 52 #define PDT_SES 0xd /* SCSI Enclosure Services (SES) device */ 53 #define PDT_RBC 0xe /* Reduced Block Commands (simplified PDT_DISK) */ 54 #define PDT_OCRW 0xf /* optical card read/write device */ 55 #define PDT_BCC 0x10 /* bridge controller commands */ 56 #define PDT_OSD 0x11 /* Object Storage Device (OSD) */ 57 #define PDT_ADC 0x12 /* Automation/drive commands (ADC) */ 58 #define PDT_SMD 0x13 /* Security Manager Device (SMD) */ 59 #define PDT_ZBC 0x14 /* Zoned Block Commands (ZBC) */ 60 #define PDT_WLUN 0x1e /* Well known logical unit (WLUN) */ 61 #define PDT_UNKNOWN 0x1f /* Unknown or no device type */ 62 63 #ifndef SAM_STAT_GOOD 64 /* The SCSI status codes as found in SAM-4 at www.t10.org */ 65 #define SAM_STAT_GOOD 0x0 66 #define SAM_STAT_CHECK_CONDITION 0x2 67 #define SAM_STAT_CONDITION_MET 0x4 68 #define SAM_STAT_BUSY 0x8 69 #define SAM_STAT_INTERMEDIATE 0x10 /* obsolete in SAM-4 */ 70 #define SAM_STAT_INTERMEDIATE_CONDITION_MET 0x14 /* obsolete in SAM-4 */ 71 #define SAM_STAT_RESERVATION_CONFLICT 0x18 72 #define SAM_STAT_COMMAND_TERMINATED 0x22 /* obsolete in SAM-3 */ 73 #define SAM_STAT_TASK_SET_FULL 0x28 74 #define SAM_STAT_ACA_ACTIVE 0x30 75 #define SAM_STAT_TASK_ABORTED 0x40 76 #endif 77 78 /* The SCSI sense key codes as found in SPC-4 at www.t10.org */ 79 #define SPC_SK_NO_SENSE 0x0 80 #define SPC_SK_RECOVERED_ERROR 0x1 81 #define SPC_SK_NOT_READY 0x2 82 #define SPC_SK_MEDIUM_ERROR 0x3 83 #define SPC_SK_HARDWARE_ERROR 0x4 84 #define SPC_SK_ILLEGAL_REQUEST 0x5 85 #define SPC_SK_UNIT_ATTENTION 0x6 86 #define SPC_SK_DATA_PROTECT 0x7 87 #define SPC_SK_BLANK_CHECK 0x8 88 #define SPC_SK_VENDOR_SPECIFIC 0x9 89 #define SPC_SK_COPY_ABORTED 0xa 90 #define SPC_SK_ABORTED_COMMAND 0xb 91 #define SPC_SK_RESERVED 0xc 92 #define SPC_SK_VOLUME_OVERFLOW 0xd 93 #define SPC_SK_MISCOMPARE 0xe 94 #define SPC_SK_COMPLETED 0xf 95 96 /* Transport protocol identifiers or just Protocol identifiers */ 97 #define TPROTO_FCP 0 98 #define TPROTO_SPI 1 99 #define TPROTO_SSA 2 100 #define TPROTO_1394 3 101 #define TPROTO_SRP 4 102 #define TPROTO_ISCSI 5 103 #define TPROTO_SAS 6 104 #define TPROTO_ADT 7 105 #define TPROTO_ATA 8 106 #define TPROTO_UAS 9 /* USB attached SCSI */ 107 #define TPROTO_SOP 0xa /* SCSI over PCIe */ 108 #define TPROTO_PCIE 0xb /* includes NVMe */ 109 #define TPROTO_NONE 0xf 110 111 112 /* The format of the version string is like this: "1.87 20130731" */ 113 const char * sg_lib_version(); 114 115 /* Returns length of SCSI command given the opcode (first byte). 116 * Yields the wrong answer for variable length commands (opcode=0x7f) 117 * and potentially some vendor specific commands. */ 118 int sg_get_command_size(unsigned char cdb_byte0); 119 120 /* Command name given pointer to the cdb. Certain command names 121 * depend on peripheral type (give 0 if unknown). Places command 122 * name into buff and will write no more than buff_len bytes. */ 123 void sg_get_command_name(const unsigned char * cdbp, int peri_type, 124 int buff_len, char * buff); 125 126 /* Command name given only the first byte (byte 0) of a cdb and 127 * peripheral type. */ 128 void sg_get_opcode_name(unsigned char cdb_byte0, int peri_type, int buff_len, 129 char * buff); 130 131 /* Command name given opcode (byte 0), service action and peripheral type. 132 * If no service action give 0, if unknown peripheral type give 0. */ 133 void sg_get_opcode_sa_name(unsigned char cdb_byte0, int service_action, 134 int peri_type, int buff_len, char * buff); 135 136 /* Fetch scsi status string. */ 137 void sg_get_scsi_status_str(int scsi_status, int buff_len, char * buff); 138 139 /* This is a slightly stretched SCSI sense "descriptor" format header. 140 * The addition is to allow the 0x70 and 0x71 response codes. The idea 141 * is to place the salient data of both "fixed" and "descriptor" sense 142 * format into one structure to ease application processing. 143 * The original sense buffer should be kept around for those cases 144 * in which more information is required (e.g. the LBA of a MEDIUM ERROR). */ 145 struct sg_scsi_sense_hdr { 146 unsigned char response_code; /* permit: 0x0, 0x70, 0x71, 0x72, 0x73 */ 147 unsigned char sense_key; 148 unsigned char asc; 149 unsigned char ascq; 150 unsigned char byte4; 151 unsigned char byte5; 152 unsigned char byte6; 153 unsigned char additional_length; 154 }; 155 156 /* Maps the salient data from a sense buffer which is in either fixed or 157 * descriptor format into a structure mimicking a descriptor format 158 * header (i.e. the first 8 bytes of sense descriptor format). 159 * If zero response code returns 0. Otherwise returns 1 and if 'sshp' is 160 * non-NULL then zero all fields and then set the appropriate fields in 161 * that structure. sshp::additional_length is always 0 for response 162 * codes 0x70 and 0x71 (fixed format). */ 163 int sg_scsi_normalize_sense(const unsigned char * sensep, int sense_len, 164 struct sg_scsi_sense_hdr * sshp); 165 166 /* Attempt to find the first SCSI sense data descriptor that matches the 167 * given 'desc_type'. If found return pointer to start of sense data 168 * descriptor; otherwise (including fixed format sense data) returns NULL. */ 169 const unsigned char * sg_scsi_sense_desc_find(const unsigned char * sensep, 170 int sense_len, int desc_type); 171 172 /* Get sense key from sense buffer. If successful returns a sense key value 173 * between 0 and 15. If sense buffer cannot be decode, returns -1 . */ 174 int sg_get_sense_key(const unsigned char * sensep, int sense_len); 175 176 /* Yield string associated with sense_key value. Returns 'buff'. */ 177 char * sg_get_sense_key_str(int sense_key, int buff_len, char * buff); 178 179 /* Yield string associated with ASC/ASCQ values. Returns 'buff'. */ 180 char * sg_get_asc_ascq_str(int asc, int ascq, int buff_len, char * buff); 181 182 /* Returns 1 if valid bit set, 0 if valid bit clear. Irrespective the 183 * information field is written out via 'info_outp' (except when it is 184 * NULL). Handles both fixed and descriptor sense formats. */ 185 int sg_get_sense_info_fld(const unsigned char * sensep, int sb_len, 186 uint64_t * info_outp); 187 188 /* Returns 1 if any of the 3 bits (i.e. FILEMARK, EOM or ILI) are set. 189 * In descriptor format if the stream commands descriptor not found 190 * then returns 0. Writes 1 or 0 corresponding to these bits to the 191 * last three arguments if they are non-NULL. */ 192 int sg_get_sense_filemark_eom_ili(const unsigned char * sensep, int sb_len, 193 int * filemark_p, int * eom_p, int * ili_p); 194 195 /* Returns 1 if SKSV is set and sense key is NO_SENSE or NOT_READY. Also 196 * returns 1 if progress indication sense data descriptor found. Places 197 * progress field from sense data where progress_outp points. If progress 198 * field is not available returns 0. Handles both fixed and descriptor 199 * sense formats. N.B. App should multiply by 100 and divide by 65536 200 * to get percentage completion from given value. */ 201 int sg_get_sense_progress_fld(const unsigned char * sensep, int sb_len, 202 int * progress_outp); 203 204 /* Closely related to sg_print_sense(). Puts decoded sense data in 'buff'. 205 * Usually multiline with multiple '\n' including one trailing. If 206 * 'raw_sinfo' set appends sense buffer in hex. 'leadin' is string prepended 207 * to each line written to 'buff', NULL treated as "". Returns the number of 208 * bytes written to 'buff' excluding the trailing '\0'. 209 * N.B. prior to sg3_utils v 1.42 'leadin' was only prepended to the first 210 * line output. Also this function returned type void. */ 211 int sg_get_sense_str(const char * leadin, const unsigned char * sense_buffer, 212 int sb_len, int raw_sinfo, int buff_len, char * buff); 213 214 /* Decode descriptor format sense descriptors (assumes sense buffer is 215 * in descriptor format). 'leadin' is string prepended to each line written 216 * to 'b', NULL treated as "". Returns the number of bytes written to 'b' 217 * excluding the trailing '\0'. */ 218 int sg_get_sense_descriptors_str(const char * leadin, 219 const unsigned char * sense_buffer, 220 int sb_len, int blen, char * b); 221 222 /* Decodes a designation descriptor (e.g. as found in the Device 223 * Identification VPD page (0x83)) into string 'b' whose maximum length is 224 * blen. 'leadin' is string prepended to each line written to 'b', NULL 225 * treated as "". Returns the number of bytes written to 'b' excluding the 226 * trailing '\0'. */ 227 int sg_get_designation_descriptor_str(const char * leadin, 228 const unsigned char * ddp, int dd_len, 229 int print_assoc, int do_long, int blen, 230 char * b); 231 232 /* Yield string associated with peripheral device type (pdt). Returns 233 * 'buff'. If 'pdt' out of range yields "bad pdt" string. */ 234 char * sg_get_pdt_str(int pdt, int buff_len, char * buff); 235 236 /* Some lesser used PDTs share a lot in common with a more used PDT. 237 * Examples are PDT_ADC decaying to PDT_TAPE and PDT_ZBC to PDT_DISK. 238 * If such a lesser used 'pdt' is given to this function, then it will 239 * return the more used PDT (i.e. "decays to"); otherwise 'pdt' is returned. 240 * Valid for 'pdt' 0 to 31, for other values returns 'pdt'. */ 241 int sg_lib_pdt_decay(int pdt); 242 243 /* Yield string associated with transport protocol identifier (tpi). Returns 244 * 'buff'. If 'tpi' out of range yields "bad tpi" string. */ 245 char * sg_get_trans_proto_str(int tpi, int buff_len, char * buff); 246 247 /* Returns a designator's type string given 'val' (0 to 15 inclusive), 248 * otherwise returns NULL. */ 249 const char * sg_get_desig_type_str(int val); 250 251 /* Returns a designator's code_set string given 'val' (0 to 15 inclusive), 252 * otherwise returns NULL. */ 253 const char * sg_get_desig_code_set_str(int val); 254 255 /* Returns a designator's association string given 'val' (0 to 3 inclusive), 256 * otherwise returns NULL. */ 257 const char * sg_get_desig_assoc_str(int val); 258 259 extern FILE * sg_warnings_strm; 260 261 void sg_set_warnings_strm(FILE * warnings_strm); 262 263 /* The following "print" functions send ACSII to 'sg_warnings_strm' file 264 * descriptor (default value is stderr). 'leadin' is string prepended to 265 * each line printed out, NULL treated as "". */ 266 void sg_print_command(const unsigned char * command); 267 void sg_print_scsi_status(int scsi_status); 268 269 /* 'leadin' is string prepended to each line printed out, NULL treated as 270 * "". N.B. prior to sg3_utils v 1.42 'leadin' was only prepended to the 271 * first line printed. */ 272 void sg_print_sense(const char * leadin, const unsigned char * sense_buffer, 273 int sb_len, int raw_info); 274 275 /* Utilities can use these exit status values for syntax errors and 276 * file (device node) problems (e.g. not found or permissions). */ 277 #define SG_LIB_SYNTAX_ERROR 1 /* command line syntax problem */ 278 #define SG_LIB_FILE_ERROR 15 /* device or other file problem */ 279 280 /* The sg_err_category_sense() function returns one of the following. 281 * These may be used as exit status values (from a process). Notice that 282 * some of the lower values correspond to SCSI sense key values. */ 283 #define SG_LIB_CAT_CLEAN 0 /* No errors or other information */ 284 /* Value 1 left unused for utilities to use SG_LIB_SYNTAX_ERROR */ 285 #define SG_LIB_CAT_NOT_READY 2 /* sense key, unit stopped? */ 286 /* [sk,asc,ascq: 0x2,*,*] */ 287 #define SG_LIB_CAT_MEDIUM_HARD 3 /* medium or hardware error, blank check */ 288 /* [sk,asc,ascq: 0x3/0x4/0x8,*,*] */ 289 #define SG_LIB_CAT_ILLEGAL_REQ 5 /* Illegal request (other than invalid */ 290 /* opcode): [sk,asc,ascq: 0x5,*,*] */ 291 #define SG_LIB_CAT_UNIT_ATTENTION 6 /* sense key, device state changed */ 292 /* [sk,asc,ascq: 0x6,*,*] */ 293 /* was SG_LIB_CAT_MEDIA_CHANGED earlier [sk,asc,ascq: 0x6,0x28,*] */ 294 #define SG_LIB_CAT_DATA_PROTECT 7 /* sense key, media write protected? */ 295 /* [sk,asc,ascq: 0x7,*,*] */ 296 #define SG_LIB_CAT_INVALID_OP 9 /* (Illegal request,) Invalid opcode: */ 297 /* [sk,asc,ascq: 0x5,0x20,0x0] */ 298 #define SG_LIB_CAT_COPY_ABORTED 10 /* sense key, some data transferred */ 299 /* [sk,asc,ascq: 0xa,*,*] */ 300 #define SG_LIB_CAT_ABORTED_COMMAND 11 /* interpreted from sense buffer */ 301 /* [sk,asc,ascq: 0xb,! 0x10,*] */ 302 #define SG_LIB_CAT_MISCOMPARE 14 /* sense key, probably verify */ 303 /* [sk,asc,ascq: 0xe,*,*] */ 304 #define SG_LIB_CAT_NO_SENSE 20 /* sense data with key of "no sense" */ 305 /* [sk,asc,ascq: 0x0,*,*] */ 306 #define SG_LIB_CAT_RECOVERED 21 /* Successful command after recovered err */ 307 /* [sk,asc,ascq: 0x1,*,*] */ 308 #define SG_LIB_CAT_RES_CONFLICT SAM_STAT_RESERVATION_CONFLICT 309 /* 24: this is a SCSI status, not sense. */ 310 /* It indicates reservation by another */ 311 /* machine blocks this command */ 312 #define SG_LIB_CAT_CONDITION_MET 25 /* SCSI status, not sense key. */ 313 /* Only from PRE-FETCH (SBC-4) */ 314 #define SG_LIB_CAT_BUSY 26 /* SCSI status, not sense. Invites retry */ 315 #define SG_LIB_CAT_TS_FULL 27 /* SCSI status, not sense. Wait then retry */ 316 #define SG_LIB_CAT_ACA_ACTIVE 28 /* SCSI status; ACA seldom used */ 317 #define SG_LIB_CAT_TASK_ABORTED 29 /* SCSI status, this command aborted by? */ 318 #define SG_LIB_CAT_PROTECTION 40 /* subset of aborted command (for PI, DIF) */ 319 /* [sk,asc,ascq: 0xb,0x10,*] */ 320 #define SG_LIB_CAT_MALFORMED 97 /* Response to SCSI command malformed */ 321 #define SG_LIB_CAT_SENSE 98 /* Something else is in the sense buffer */ 322 #define SG_LIB_CAT_OTHER 99 /* Some other error/warning has occurred */ 323 /* (e.g. a transport or driver error) */ 324 325 /* Returns a SG_LIB_CAT_* value. If cannot decode sense_buffer or a less 326 * common sense key then return SG_LIB_CAT_SENSE .*/ 327 int sg_err_category_sense(const unsigned char * sense_buffer, int sb_len); 328 329 /* Here are some additional sense data categories that are not returned 330 * by sg_err_category_sense() but are returned by some related functions. */ 331 #define SG_LIB_CAT_ILLEGAL_REQ_WITH_INFO 17 /* Illegal request (other than */ 332 /* invalid opcode) plus 'info' field: */ 333 /* [sk,asc,ascq: 0x5,*,*] */ 334 #define SG_LIB_CAT_MEDIUM_HARD_WITH_INFO 18 /* medium or hardware error */ 335 /* sense key plus 'info' field: */ 336 /* [sk,asc,ascq: 0x3/0x4,*,*] */ 337 #define SG_LIB_CAT_PROTECTION_WITH_INFO 41 /* aborted command sense key, */ 338 /* protection plus 'info' field: */ 339 /* [sk,asc,ascq: 0xb,0x10,*] */ 340 #define SG_LIB_CAT_TIMEOUT 33 341 342 /* Yield string associated with sense category. Returns 'buff' (or pointer 343 * to "Bad sense category" if 'buff' is NULL). If sense_cat unknown then 344 * yield "Sense category: <sense_cat>" string. */ 345 const char * sg_get_category_sense_str(int sense_cat, int buff_len, 346 char * buff, int verbose); 347 348 349 /* Iterates to next designation descriptor in the device identification 350 * VPD page. The 'initial_desig_desc' should point to start of first 351 * descriptor with 'page_len' being the number of valid bytes in that 352 * and following descriptors. To start, 'off' should point to a negative 353 * value, thereafter it should point to the value yielded by the previous 354 * call. If 0 returned then 'initial_desig_desc + *off' should be a valid 355 * descriptor; returns -1 if normal end condition and -2 for an abnormal 356 * termination. Matches association, designator_type and/or code_set when 357 * any of those values are greater than or equal to zero. */ 358 int sg_vpd_dev_id_iter(const unsigned char * initial_desig_desc, int page_len, 359 int * off, int m_assoc, int m_desig_type, 360 int m_code_set); 361 362 363 /* <<< General purpose (i.e. not SCSI specific) utility functions >>> */ 364 365 /* Always returns valid string even if errnum is wild (or library problem). 366 * If errnum is negative, flip its sign. */ 367 char * safe_strerror(int errnum); 368 369 370 /* Print (to stdout) 'str' of bytes in hex, 16 bytes per line optionally 371 * followed at the right hand side of the line with an ASCII interpretation. 372 * Each line is prefixed with an address, starting at 0 for str[0]..str[15]. 373 * All output numbers are in hex. 'no_ascii' allows for 3 output types: 374 * > 0 each line has address then up to 16 ASCII-hex bytes 375 * = 0 in addition, the bytes are listed in ASCII to the right 376 * < 0 only the ASCII-hex bytes are listed (i.e. without address) 377 */ 378 void dStrHex(const char* str, int len, int no_ascii); 379 380 /* Print (to sg_warnings_strm (stderr)) 'str' of bytes in hex, 16 bytes per 381 * line optionally followed at right by its ASCII interpretation. Same 382 * logic as dStrHex() with different output stream (i.e. stderr). */ 383 void dStrHexErr(const char* str, int len, int no_ascii); 384 385 /* Read 'len' bytes from 'str' and output as ASCII-Hex bytes (space 386 * separated) to 'b' not to exceed 'b_len' characters. Each line 387 * starts with 'leadin' (NULL for no leadin) and there are 16 bytes 388 * per line with an extra space between the 8th and 9th bytes. 'format' 389 * is unused, set to 0 . Returns number of bytes written to 'b' excluding 390 * the trailing '\0'.*/ 391 int dStrHexStr(const char* str, int len, const char * leadin, int format, 392 int b_len, char * b); 393 394 /* Returns 1 when executed on big endian machine; else returns 0. 395 * Useful for displaying ATA identify words (which need swapping on a 396 * big endian machine). 397 */ 398 int sg_is_big_endian(); 399 400 /* Extract character sequence from ATA words as in the model string 401 * in a IDENTIFY DEVICE response. Returns number of characters 402 * written to 'ochars' before 0 character is found or 'num' words 403 * are processed. */ 404 int sg_ata_get_chars(const unsigned short * word_arr, int start_word, 405 int num_words, int is_big_endian, char * ochars); 406 407 /* Print (to stdout) 16 bit 'words' in hex, 8 words per line optionally 408 * followed at the right hand side of the line with an ASCII interpretation 409 * (pairs of ASCII characters in big endian order (upper first)). 410 * Each line is prefixed with an address, starting at 0. 411 * All output numbers are in hex. 'no_ascii' allows for 3 output types: 412 * > 0 each line has address then up to 8 ASCII-hex words 413 * = 0 in addition, the words are listed in ASCII pairs to the right 414 * = -1 only the ASCII-hex words are listed (i.e. without address) 415 * = -2 only the ASCII-hex words, formatted for "hdparm --Istdin" 416 * < -2 same as -1 417 * If 'swapb' non-zero then bytes in each word swapped. Needs to be set 418 * for ATA IDENTIFY DEVICE response on big-endian machines. 419 */ 420 void dWordHex(const unsigned short* words, int num, int no_ascii, int swapb); 421 422 /* If the number in 'buf' can not be decoded or the multiplier is unknown 423 * then -1 is returned. Accepts a hex prefix (0x or 0X) or a 'h' (or 'H') 424 * suffix. Otherwise a decimal multiplier suffix may be given. Recognised 425 * multipliers: c C *1; w W *2; b B *512; k K KiB *1,024; 426 * KB *1,000; m M MiB *1,048,576; MB *1,000,000; g G GiB *1,073,741,824; 427 * GB *1,000,000,000 and <n>x<m> which multiplies <n> by <m> . Ignore leading 428 * spaces and tabs; accept comma, space, tab and hash as terminator. */ 429 int sg_get_num(const char * buf); 430 431 /* If the number in 'buf' can not be decoded then -1 is returned. Accepts a 432 * hex prefix (0x or 0X) or a 'h' (or 'H') suffix; otherwise decimal is 433 * assumed. Does not accept multipliers. Accept a comma (","), a whitespace 434 * or newline as terminator. */ 435 int sg_get_num_nomult(const char * buf); 436 437 /* If the number in 'buf' can not be decoded or the multiplier is unknown 438 * then -1LL is returned. Accepts a hex prefix (0x or 0X) or a 'h' (or 'H') 439 * suffix. Otherwise a decimal multiplier suffix may be given. In addition 440 * to supporting the multipliers of sg_get_num(), this function supports: 441 * t T TiB *(2**40); TB *(10**12); p P PiB *(2**50); PB *(10**15) . 442 * Ignore leading spaces and tabs; accept comma, space, tab and hash as 443 * terminator. */ 444 int64_t sg_get_llnum(const char * buf); 445 446 447 /* <<< Architectural support functions [is there a better place?] >>> */ 448 449 /* Non Unix OSes distinguish between text and binary files. 450 * Set text mode on fd. Does nothing in Unix. Returns negative number on 451 * failure. */ 452 int sg_set_text_mode(int fd); 453 454 /* Set binary mode on fd. Does nothing in Unix. Returns negative number on 455 * failure. */ 456 int sg_set_binary_mode(int fd); 457 458 #ifdef __cplusplus 459 } 460 #endif 461 462 #endif 463