Skip to content

Commit

Permalink
sync to upstream sdparm svn rev 384
Browse files Browse the repository at this point in the history
See ChangeLog file for pre-release sdparm-1.13 [20230808]
  • Loading branch information
doug-gilbert committed Aug 11, 2023
1 parent 541492d commit 640cc3d
Show file tree
Hide file tree
Showing 21 changed files with 290 additions and 190 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 [20230523] [svn: r382]
ChangeLog for pre-release sdparm-1.13 [20230808] [svn: r384]
- add --json[=JO] and --js-file=JFN options
- apart from with a real device, json output can be
requested with --enumerate or --inhex=FN
Expand All @@ -25,7 +25,7 @@ ChangeLog for pre-release sdparm-1.13 [20230523] [svn: r382]
output of further descriptors, override this
truncation with --flexible option
- experimental: add NetBSD support
- point svn:externals to sg3_utils revision 1038
- point svn:externals to sg3_utils revision 1046
- remove the imtermediate files generated by ./autogen.sh
- this reduces size of svn and git repositories but still
plan to have these intermediate files in release tarballs
Expand Down
24 changes: 23 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,36 @@ check_for_linux_nvme_headers() {
# include <linux/types.h>
#endif
]])
AC_CHECK_HEADERS([linux/major.h], [AC_DEFINE_UNQUOTED(HAVE_LINUX_MAJOR_H, 1,
[Found linux/major.h])], [], [])
AC_CHECK_HEADERS([linux/types.h], [AC_DEFINE_UNQUOTED(HAVE_LINUX_TYPES_H, 1,
[Found linux/types.h])], [], [])
}

check_for___u64() {
AC_MSG_CHECKING([for __u64])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#ifdef HAVE_LINUX_TYPES_H
#include <linux/types.h>
#endif
]],[[
__u64 var = 0;
return var;
]])],
[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE___U64, 1, [__u64 is defined in <linux/types.h>])
],
[AC_MSG_RESULT(no)])
}

case "${host}" in
*-*-android*)
AC_SUBST([os_deps], ['sg_pt_linux.o sg_pt_linux_nvme.o'])
AC_DEFINE_UNQUOTED(SG_LIB_ANDROID, 1, [sdparm on android])
AC_DEFINE_UNQUOTED(SG_LIB_LINUX, 1, [sdparm on linux])
check_for_linux_nvme_headers;;
check_for_linux_nvme_headers
check_for___u64;;
*-*-freebsd*|*-*-kfreebsd*-gnu*)
AC_SUBST([os_deps], ['sg_pt_freebsd.o'])
AC_DEFINE_UNQUOTED(SG_LIB_FREEBSD, 1, [sdparm on FreeBSD])
Expand Down
2 changes: 1 addition & 1 deletion debian/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sdparm (1.13-0.1) unstable; urgency=low

* see ChangeLog

-- Douglas Gilbert <[email protected]> Fri, 19 May 2023 23:00:00 -0400
-- Douglas Gilbert <[email protected]> Fri, 23 Jun 2023 22:00:00 -0400

sdparm (1.12-0.1) unstable; urgency=low

Expand Down
2 changes: 1 addition & 1 deletion doc/sdparm.8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH SDPARM "8" "May 2023" "sdparm\-1.13" SDPARM
.TH SDPARM "8" "June 2023" "sdparm\-1.13" SDPARM
.SH NAME
sdparm \- access SCSI modes pages; read VPD pages; send simple SCSI commands
.SH SYNOPSIS
Expand Down
78 changes: 39 additions & 39 deletions include/sg_lib_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,45 +107,45 @@ struct sg_aux_info_t {
};


extern const char * sg_lib_version_str;

extern struct sg_lib_value_name_t sg_lib_normal_opcodes[];
extern struct sg_lib_value_name_t sg_lib_read_buff_arr[];
extern struct sg_lib_value_name_t sg_lib_write_buff_arr[];
extern struct sg_lib_value_name_t sg_lib_maint_in_arr[];
extern struct sg_lib_value_name_t sg_lib_maint_out_arr[];
extern struct sg_lib_value_name_t sg_lib_pr_in_arr[];
extern struct sg_lib_value_name_t sg_lib_pr_out_arr[];
extern struct sg_lib_value_name_t sg_lib_sanitize_sa_arr[];
extern struct sg_lib_value_name_t sg_lib_serv_in12_arr[];
extern struct sg_lib_value_name_t sg_lib_serv_out12_arr[];
extern struct sg_lib_value_name_t sg_lib_serv_in16_arr[];
extern struct sg_lib_value_name_t sg_lib_serv_out16_arr[];
extern struct sg_lib_value_name_t sg_lib_serv_bidi_arr[];
extern struct sg_lib_value_name_t sg_lib_xcopy_sa_arr[];
extern struct sg_lib_value_name_t sg_lib_rec_copy_sa_arr[];
extern struct sg_lib_value_name_t sg_lib_variable_length_arr[];
extern struct sg_lib_value_name_t sg_lib_zoning_out_arr[];
extern struct sg_lib_value_name_t sg_lib_zoning_in_arr[];
extern struct sg_lib_value_name_t sg_lib_read_attr_arr[];
extern struct sg_lib_value_name_t sg_lib_read_pos_arr[];
extern struct sg_lib_asc_ascq_range_t sg_lib_asc_ascq_range[];
extern struct sg_lib_simple_value_name_t sg_lib_sstatus_str_arr[];
extern struct sg_lib_asc_ascq_t sg_lib_asc_ascq[];
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 struct sg_aux_info_t sg_lib_pdt_aux_a[];
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[];
extern struct sg_lib_simple_value_name_t sg_lib_nvme_nvm_cmd_arr[];
extern struct sg_lib_value_name_t sg_lib_nvme_cmd_status_arr[];
extern struct sg_lib_4tuple_u8 sg_lib_scsi_status_sense_arr[];

extern struct sg_value_2names_t sg_exit_str_arr[];
extern const char * const sg_lib_version_str;

extern const struct sg_lib_value_name_t sg_lib_normal_opcodes[];
extern const struct sg_lib_value_name_t sg_lib_read_buff_arr[];
extern const struct sg_lib_value_name_t sg_lib_write_buff_arr[];
extern const struct sg_lib_value_name_t sg_lib_maint_in_arr[];
extern const struct sg_lib_value_name_t sg_lib_maint_out_arr[];
extern const struct sg_lib_value_name_t sg_lib_pr_in_arr[];
extern const struct sg_lib_value_name_t sg_lib_pr_out_arr[];
extern const struct sg_lib_value_name_t sg_lib_sanitize_sa_arr[];
extern const struct sg_lib_value_name_t sg_lib_serv_in12_arr[];
extern const struct sg_lib_value_name_t sg_lib_serv_out12_arr[];
extern const struct sg_lib_value_name_t sg_lib_serv_in16_arr[];
extern const struct sg_lib_value_name_t sg_lib_serv_out16_arr[];
extern const struct sg_lib_value_name_t sg_lib_serv_bidi_arr[];
extern const struct sg_lib_value_name_t sg_lib_xcopy_sa_arr[];
extern const struct sg_lib_value_name_t sg_lib_rec_copy_sa_arr[];
extern const struct sg_lib_value_name_t sg_lib_variable_length_arr[];
extern const struct sg_lib_value_name_t sg_lib_zoning_out_arr[];
extern const struct sg_lib_value_name_t sg_lib_zoning_in_arr[];
extern const struct sg_lib_value_name_t sg_lib_read_attr_arr[];
extern const struct sg_lib_value_name_t sg_lib_read_pos_arr[];
extern const struct sg_lib_asc_ascq_range_t sg_lib_asc_ascq_range[];
extern const struct sg_lib_simple_value_name_t sg_lib_sstatus_str_arr[];
extern const struct sg_lib_asc_ascq_t sg_lib_asc_ascq[];
extern const struct sg_lib_value_name_t sg_lib_scsi_feature_sets[];
extern const char * const sg_lib_sense_key_desc[];
extern const char * const sg_lib_pdt_strs[];
extern const struct sg_aux_info_t sg_lib_pdt_aux_a[];
extern const char * const sg_lib_transport_proto_strs[];
extern const char * const sg_lib_tapealert_strs[];
extern const int sg_lib_pdt_decay_arr[];

extern const struct sg_lib_simple_value_name_t sg_lib_nvme_admin_cmd_arr[];
extern const struct sg_lib_simple_value_name_t sg_lib_nvme_nvm_cmd_arr[];
extern const struct sg_lib_value_name_t sg_lib_nvme_cmd_status_arr[];
extern const struct sg_lib_4tuple_u8 sg_lib_scsi_status_sense_arr[];

extern const struct sg_value_2names_t sg_exit_str_arr[];

#ifdef __cplusplus
}
Expand Down
6 changes: 3 additions & 3 deletions include/sg_lib_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define SG_LIB_NAMES_H

/*
* Copyright (c) 2022 Douglas Gilbert.
* Copyright (c) 2022-2023 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
Expand All @@ -18,8 +18,8 @@
extern "C" {
#endif

extern struct sg_lib_simple_value_name_t sg_lib_names_mode_arr[];
extern struct sg_lib_simple_value_name_t sg_lib_names_vpd_arr[];
extern const struct sg_lib_simple_value_name_t sg_lib_names_mode_arr[];
extern const struct sg_lib_simple_value_name_t sg_lib_names_vpd_arr[];

extern const size_t sg_lib_names_mode_len;
extern const size_t sg_lib_names_vpd_len;
Expand Down
6 changes: 5 additions & 1 deletion include/sg_pt_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define SG_PT_LINUX_H

/*
* Copyright (c) 2017-2018 Douglas Gilbert.
* Copyright (c) 2017-2023 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
Expand All @@ -13,7 +13,11 @@
#include <stdint.h>
#include <stdbool.h>

#ifdef HAVE_LINUX_TYPES_H
#include <linux/types.h>
#else
#include "sg_pt_linux_missing.h"
#endif

#include "sg_pt_nvme.h"

Expand Down
67 changes: 67 additions & 0 deletions include/sg_pt_linux_missing.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#ifndef SG_PT_LINUX_MISSING_H
#define SG_PT_LINUX_MISSING_H

/*
* Copyright (c) 2023 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#include <stdint.h>
#include <stdbool.h>


/* This header is for internal use by the sg3_utils library (libsgutils)
* and is Linux specific. Best not to include it directly in code that
* is meant to be OS independent.
* This header is only used with Linux if linux/types.h and linux/major.h
* are not available. This is the case with MUSL libc for example. */

#ifdef __cplusplus
extern "C" {
#endif

#ifndef HAVE___U64
/* typedefs if linux/types.h header not available */

typedef uint64_t __u64;
typedef int64_t __s64;
typedef uint32_t __u32;
typedef int32_t __s32;
typedef uint16_t __u16;
typedef int16_t __s16;
#endif


/* Following if linux/major.h header is not available */
#define MEM_MAJOR 1
#define IDE0_MAJOR 3
#define SCSI_DISK0_MAJOR 8
#define SCSI_TAPE_MAJOR 9
#define SCSI_CDROM_MAJOR 11
#define SCSI_GENERIC_MAJOR 21
#define IDE1_MAJOR 22
#define IDE2_MAJOR 33
#define IDE3_MAJOR 34
#define IDE4_MAJOR 56
#define IDE5_MAJOR 57
#define SCSI_DISK1_MAJOR 65
#define SCSI_DISK2_MAJOR 66
#define SCSI_DISK3_MAJOR 67
#define SCSI_DISK4_MAJOR 68
#define SCSI_DISK5_MAJOR 69
#define SCSI_DISK6_MAJOR 70
#define SCSI_DISK7_MAJOR 71
#define IDE6_MAJOR 88
#define IDE7_MAJOR 89
#define IDE8_MAJOR 90
#define IDE9_MAJOR 91

#ifdef __cplusplus
}
#endif

#endif /* end of SG_PT_LINUX_MISSING_H */
2 changes: 1 addition & 1 deletion lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ AM_CFLAGS = -Wall -W $(DBG_CFLAGS)
# AM_CFLAGS = -Wall -W -pedantic -std=c++11
# AM_CFLAGS = -Wall -W -pedantic -std=c++14
# AM_CFLAGS = -Wall -W -pedantic -std=c++17 $(DBG_CXXFLAGS)
# AM_CFLAGS = -Wall -W -pedantic -std=c++20 --analyze
# AM_CFLAGS = -Wall -W -pedantic -std=c++20 --analyze $(DBG_CXXFLAGS)
# AM_CFLAGS = -Wall -W -pedantic -std=c++20 $(DBG_CXXFLAGS)
# AM_CFLAGS = -Wall -W -pedantic -std=c++23 $(DBG_CXXFLAGS)

Expand Down
15 changes: 8 additions & 7 deletions lib/sg_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ sg_get_additional_sense_str(int asc, int ascq, bool add_sense_leadin,
return buff;
}
for (k = 0; sg_lib_asc_ascq_range[k].text; ++k) {
struct sg_lib_asc_ascq_range_t * ei2p = &sg_lib_asc_ascq_range[k];
const struct sg_lib_asc_ascq_range_t * ei2p =
&sg_lib_asc_ascq_range[k];

if ((ei2p->asc == asc) &&
(ascq >= ei2p->ascq_min) &&
Expand All @@ -377,7 +378,7 @@ sg_get_additional_sense_str(int asc, int ascq, bool add_sense_leadin,
return buff;

for (k = 0; sg_lib_asc_ascq[k].text; ++k) {
struct sg_lib_asc_ascq_t * eip = &sg_lib_asc_ascq[k];
const struct sg_lib_asc_ascq_t * eip = &sg_lib_asc_ascq[k];

if (eip->asc == asc &&
eip->ascq == ascq) {
Expand Down Expand Up @@ -621,7 +622,7 @@ sg_get_pdt_from_acronym(const char * acron)
{
int k;
int len = strlen(acron);
struct sg_aux_info_t * aip;
const struct sg_aux_info_t * aip;
const char * cc0p;
const char * ccp;
char b[32];
Expand Down Expand Up @@ -2380,11 +2381,11 @@ sg_get_command_name(const uint8_t * cdbp, int peri_type, int buff_len,
struct op_code2sa_t {
int op_code;
int pdt_s;
struct sg_lib_value_name_t * arr;
const struct sg_lib_value_name_t * arr;
const char * prefix;
};

static struct op_code2sa_t op_code2sa_arr[] = {
static const struct op_code2sa_t op_code2sa_arr[] = {
{SG_VARIABLE_LENGTH_CMD, PDT_ALL, sg_lib_variable_length_arr, NULL},
{SG_MAINTENANCE_IN, PDT_ALL, sg_lib_maint_in_arr, NULL},
{SG_MAINTENANCE_OUT, PDT_ALL, sg_lib_maint_out_arr, NULL},
Expand Down Expand Up @@ -2780,8 +2781,8 @@ sg_nvme_status2scsi(uint16_t sct_sc, uint8_t * status_p, uint8_t * sk_p,
{
int k, ind;
uint16_t s = 0x3ff & sct_sc;
struct sg_lib_value_name_t * vp = sg_lib_nvme_cmd_status_arr;
struct sg_lib_4tuple_u8 * mp = sg_lib_scsi_status_sense_arr;
const struct sg_lib_value_name_t * vp = sg_lib_nvme_cmd_status_arr;
const struct sg_lib_4tuple_u8 * mp = sg_lib_scsi_status_sense_arr;

for (k = 0; (vp->name && (k < 1000)); ++k, ++vp) {
if (s == (uint16_t)vp->value)
Expand Down
Loading

0 comments on commit 640cc3d

Please sign in to comment.