Skip to content

Commit

Permalink
sync to upstream sdparm svn rev 363
Browse files Browse the repository at this point in the history
See ChangeLog file for pre-release sdparm-1.13 [20220825]
  • Loading branch information
doug-gilbert committed Aug 26, 2022
1 parent 6415925 commit aa1736a
Show file tree
Hide file tree
Showing 18 changed files with 1,944 additions and 374 deletions.
4 changes: 2 additions & 2 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ The version number is hardcoded into sdparm.c (in a C string);
the rpm spec file: sdparm.spec ; the debian/changelog file;
and the configure.ac file (in the AC_INIT item).

ChangeLog for pre-release sdparm-1.13 [20220602] [svn: r362]
ChangeLog for pre-release sdparm-1.13 [20220825] [svn: r363]
- control extension mpage: add pwromact, hrdrmact, ssumact
and fmtmact fields
- format presets vpd: expand for schema type 4
Expand All @@ -15,7 +15,7 @@ ChangeLog for pre-release sdparm-1.13 [20220602] [svn: r362]
- act on LAST bit in App tag mpage descriptors to stop
output of further descriptors, override this
truncation with --flexible option
- point svn:externals to sg3_utils revision 954
- point svn:externals to sg3_utils revision 969
- autoconf: upgrade version 2.70 to 2.71; automake upgrade
to version 1.16.5

Expand Down
1 change: 1 addition & 0 deletions include/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ EGREP = @EGREP@
ETAGS = @ETAGS@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
FILECMD = @FILECMD@
GETOPT_O_FILES = @GETOPT_O_FILES@
GREP = @GREP@
INSTALL = @INSTALL@
Expand Down
92 changes: 66 additions & 26 deletions include/sg_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ extern "C" {
/* Borrowed from Linux kernel; no check that 'arr' actually is one */
#define SG_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))

/* Doesn't seem to be a common C and C++ technique for clearing an
* aggregrate (e.g. a struct instance) on the stack. Hence this hack: */
#ifdef __cplusplus
#define SG_C_CPP_ZERO_INIT {}
#else
#define SG_C_CPP_ZERO_INIT ={0}
#endif


/* The format of the version string is like this: "2.26 20170906" */
const char * sg_lib_version();
Expand Down Expand Up @@ -230,9 +238,16 @@ int sg_get_sense_key(const uint8_t * sensep, int sense_len);
/* Yield string associated with sense_key value. Returns 'buff'. */
char * sg_get_sense_key_str(int sense_key, int buff_len, char * buff);

/* Yield string associated with ASC/ASCQ values. Returns 'buff'. */
/* Yield string associated with ASC/ASCQ values. Returns 'buff'. Prefixes
* any valid additional sense found with "Additional sense: ". */
char * sg_get_asc_ascq_str(int asc, int ascq, int buff_len, char * buff);

/* Same as sg_get_asc_ascq_str() when add_sense_leadin is true. When it is
* false this function does _not_ prefix any valid additional sense found
* with "Additional sense: ". */
char * sg_get_additional_sense_str(int asc, int ascq, bool add_sense_leadin,
int buff_len, char * buff);

/* Returns true if valid bit set, false if valid bit clear. Irrespective the
* information field is written out via 'info_outp' (except when it is
* NULL). Handles both fixed and descriptor sense formats. */
Expand Down Expand Up @@ -310,10 +325,10 @@ char * sg_get_pdt_str(int pdt, int buff_len, char * buff);

/* Some lesser used PDTs share a lot in common with a more used PDT.
* Examples are PDT_ADC decaying to PDT_TAPE and PDT_ZBC to PDT_DISK.
* If such a lesser used 'pdt' is given to this function, then it will
* return the more used PDT (i.e. "decays to"); otherwise 'pdt' is returned.
* Valid for 'pdt' 0 to 31, for other values returns 0. */
int sg_lib_pdt_decay(int pdt);
* If such a lesser used 'dev_pdt' is given to this function, then it will
* return the more used PDT (i.e. "decays to"); otherwise 'dev_pdt' is
* returned. Valid for 'pdt' 0 to 31, for other values returns 0. */
int sg_lib_pdt_decay(int dev_pdt);

/* Yield string associated with transport protocol identifier (tpi). Returns
* 'buff'. If 'tpi' out of range yields "bad tpi" string. */
Expand Down Expand Up @@ -584,6 +599,25 @@ int sg_vpd_dev_id_iter(const uint8_t * initial_desig_desc, int page_len,
* If errnum is negative, flip its sign. */
char * safe_strerror(int errnum);

/* Not all platforms support the Unix sleep(seconds) function. */
void sg_sleep_secs(int num_secs);

/* There are several SCSI commands that are very destructive for the user
* data stored on a device. The FORMAT UNIT command is the prime example
* but there are an increasing number of newer SCSI commands that remove or
* destroy some or all of the user's data. This function takes 15 seconds,
* divided into three parts, saying that 'cmd_name' will be executed on
* 'dev_name' and then waits for 5 seconds inviting the user to press
* control-C to abort the operation. After three such prompts the function
* returns and the utility start to execute the "dangerous" SCSI command,
* Utilities that use this function usually have a --quick option to bypass
* this call. That may be appropriate if the utility in question is called
* from a script or in background processing. If 'stress_all' is true then
* state "ALL data" will be lost, if false drop the "ALL". */
void
sg_warn_and_wait(const char * cmd_name, const char * dev_name,
bool stress_all);


/* Print (to stdout) 'str' of bytes in hex, 16 bytes per line optionally
* followed at the right hand side of the line with an ASCII interpretation.
Expand All @@ -602,29 +636,29 @@ void dStrHex(const char * str, int len, int no_ascii);
void dStrHexErr(const char * str, int len, int no_ascii);

/* Read binary starting at 'str' for 'len' bytes and output as ASCII
* hexadecinal into file pointer (fp). 16 bytes per line are output with an
* hexadecimal into file pointer (fp). 16 bytes per line are output with an
* additional space between 8th and 9th byte on each line (for readability).
* 'no_ascii' selects one of 3 output format types as shown in dStrHex() . */
void dStrHexFp(const char* str, int len, int no_ascii, FILE * fp);

/* Read 'len' bytes from 'str' and output as ASCII-Hex bytes (space
* separated) to 'b' not to exceed 'b_len' characters. Each line
* starts with 'leadin' (NULL for no leadin) and there are 16 bytes
* per line with an extra space between the 8th and 9th bytes. 'format'
* is 0 for repeat in printable ASCII ('.' for non printable chars) to
* right of each line; 1 don't (so just output ASCII hex). Note that
* an address is not printed on each line preceding the hex data. Returns
* number of bytes written to 'b' excluding the trailing '\0'.
* The only difference between dStrHexStr() and hex2str() is the type of
* the first argument. */
int dStrHexStr(const char * str, int len, const char * leadin, int format,
/* Read 'len' bytes from 'str' and output as ASCII-Hex bytes (space separated)
* to 'b' not to exceed 'b_len' characters. Each line starts with 'leadin'
* (NULL for no leadin) and there are 16 bytes per line with an extra space
* between the 8th and 9th bytes. 'oformat' is 0 for repeat in printable ASCII
* ('.' for non printable chars) to right of each line; 1 don't (so just
* output ASCII hex). If 'oformat' is 2 output same as 1 but any LFs are
* replaced by space (and trailing spaces are trimmed). Note that an address
* is _not_ printed on each line preceding the hex data. Returns number of
* bytes written to 'b' excluding the trailing '\0'. The only difference
* between dStrHexStr() and hex2str() is the type of the first argument. */
int dStrHexStr(const char * str, int len, const char * leadin, int oformat,
int cb_len, char * cbp);
int hex2str(const uint8_t * b_str, int len, const char * leadin, int format,
int hex2str(const uint8_t * b_str, int len, const char * leadin, int oformat,
int cb_len, char * cbp);

/* Similar to hex2str() but outputs to file pointed to be fp */
void hex2fp(const uint8_t * b_str, int len, const char * leadin, int format,
FILE * fp);
void hex2fp(const uint8_t * b_str, int len, const char * leadin, int oformat,
FILE * fp);

/* The following 2 functions are equivalent to dStrHex() and dStrHexErr()
* respectively. The difference is only the type of the first of argument:
Expand All @@ -635,13 +669,19 @@ void hex2stderr(const uint8_t * b_str, int len, int no_ascii);

/* Read ASCII hex bytes or binary from fname (a file named '-' taken as
* stdin). If reading ASCII hex then there should be either one entry per
* line or a comma, space or tab separated list of bytes. If no_space is
* set then a string of ACSII hex digits is expected, 2 per byte. Everything
* from and including a '#' on a line is ignored. Returns 0 if ok, or an
* error code. If the error code is SG_LIB_LBA_OUT_OF_RANGE then mp_arr
* would be exceeded and both mp_arr and mp_arr_len are written to. */
* line or a comma, space, hyphen or tab separated list of bytes. If no_space
* is set then a string of ACSII hex digits is expected, 2 per byte.
* Everything from and including a '#' on a line is ignored. Returns 0 if ok,
* or an error code. If the error code is SG_LIB_LBA_OUT_OF_RANGE then mp_arr
* would be exceeded and both mp_arr and mp_arr_len are written to.
* The max_arr_len_and argument may carry extra information: when it is
* negative its absolute value is used for the maximum number of bytes to
* write to mp_arr _and_ the first hexadecimal value on each line is skipped.
* Many hexadecimal output programs place a running address (index) as the
* first field on each line. When as_binary and/or no_space are true, the
* absolute value of max_arr_len_and is used. */
int sg_f2hex_arr(const char * fname, bool as_binary, bool no_space,
uint8_t * mp_arr, int * mp_arr_len, int max_arr_len);
uint8_t * mp_arr, int * mp_arr_len, int max_arr_len_and);

/* Returns true when executed on big endian machine; else returns false.
* Useful for displaying ATA identify words (which need swapping on a
Expand Down
5 changes: 3 additions & 2 deletions include/sg_lib_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ extern "C" {
#define SG_VARIABLE_LENGTH_CMD 0x7f
#define SG_WRITE_BUFFER 0x3b
#define SG_ZONING_OUT 0x94
#define SG_ZBC_OUT SG_ZONING_OUT /* as SPC calls them */
#define SG_ZBC_OUT SG_ZONING_OUT /* as SPC calls them */
#define SG_ZONING_IN 0x95
#define SG_ZBC_IN SG_ZONING_IN /* as SPC calls them */
#define SG_ZBC_IN SG_ZONING_IN /* as SPC calls them */



Expand Down Expand Up @@ -128,6 +128,7 @@ extern struct sg_lib_value_name_t sg_lib_scsi_feature_sets[];
extern const char * sg_lib_sense_key_desc[];
extern const char * sg_lib_pdt_strs[];
extern const char * sg_lib_transport_proto_strs[];
extern const char * sg_lib_tapealert_strs[];
extern int sg_lib_pdt_decay_arr[];

extern struct sg_lib_simple_value_name_t sg_lib_nvme_admin_cmd_arr[];
Expand Down
Loading

0 comments on commit aa1736a

Please sign in to comment.