-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'e64269c521429d942c67841305a2750f55000910'
Makes libscsicmd work better with a build dir
- Loading branch information
Showing
6 changed files
with
366 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,316 @@ | ||
/* Generated file, do not edit */ | ||
#ifndef ATA_PARSE_H | ||
#define ATA_PARSE_H | ||
#include "ata.h" | ||
static inline bool ata_get_ata_identify_smart_enabled(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 85); | ||
return val & (1 << 0); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_cfast_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 69); | ||
return val & (1 << 15); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_sct_write_same_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 206); | ||
return val & (1 << 2); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_lps_misalignment_reporting_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 69); | ||
return val & (1 << 13); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_extended_number_of_user_addressable_sectors(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 69); | ||
return val & (1 << 3); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_sense_data_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 119); | ||
return val & (1 << 6); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_fields_valid_words_64_70(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 53); | ||
return val & (1 << 1); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_crypto_scramble_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 59); | ||
return val & (1 << 13); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_rzat_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 69); | ||
return val & (1 << 5); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_address_48bit_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 83); | ||
return val & (1 << 10); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_set_max_set_password_dma_and_set_max_unlock_dma_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 69); | ||
return val & (1 << 9); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_volatile_write_cache_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 82); | ||
return val & (1 << 5); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_standby_timer_values_settable(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 49); | ||
return val & (1 << 13); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_sata_dma_setup_auto_activation_enabled(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 79); | ||
return val & (1 << 2); | ||
} | ||
|
||
static inline void ata_get_ata_identify_fw_rev(const char *buf, char *out) { | ||
ata_get_string(buf, 23, 26, out); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_write_buffer_dma_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 69); | ||
return val & (1 << 10); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_major_version_ata_atapi_6(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 80); | ||
return val & (1 << 6); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_major_version_ata_atapi_5(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 80); | ||
return val & (1 << 5); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_sct_error_recovery_control_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 206); | ||
return val & (1 << 3); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_block_erase_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 59); | ||
return val & (1 << 15); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_sata_software_settings_preservation_enabled(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 79); | ||
return val & (1 << 6); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_dma_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 49); | ||
return val & (1 << 8); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_write_uncorrectable_enabled(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 120); | ||
return val & (1 << 2); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_sct_command_transport_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 206); | ||
return val & (1 << 0); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_not_ata_device(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 0); | ||
return val & (1 << 15); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_read_buffer_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 82); | ||
return val & (1 << 13); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_read_buffer_dma_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 69); | ||
return val & (1 << 11); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_address_28bit_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 69); | ||
return val & (1 << 6); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_download_microcode_dma_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 69); | ||
return val & (1 << 8); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_mandatory_power_management_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 82); | ||
return val & (1 << 3); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_fields_valid_word_88(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 53); | ||
return val & (1 << 2); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_packet_feature_set_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 82); | ||
return val & (1 << 4); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_smart_self_test_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 84); | ||
return val & (1 << 1); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_sata_in_order_data_delivery_enabled(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 79); | ||
return val & (1 << 4); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_major_version_acs_2(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 80); | ||
return val & (1 << 9); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_encrypt_all_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 69); | ||
return val & (1 << 4); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_iordy_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 49); | ||
return val & (1 << 11); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_nop_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 82); | ||
return val & (1 << 14); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_sata_device_initiated_power_management_enabled(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 79); | ||
return val & (1 << 3); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_response_incomplete(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 0); | ||
return val & (1 << 2); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_sata_automatic_partial_to_slumber_transitions_enabled(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 79); | ||
return val & (1 << 7); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_sct_feature_control_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 206); | ||
return val & (1 << 4); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_major_version_ata_8_acs(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 80); | ||
return val & (1 << 8); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_trusted_computing_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 48); | ||
return val & (1 << 0); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_sanitize_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 59); | ||
return val & (1 << 12); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_non_volatile_cache(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 69); | ||
return val & (1 << 2); | ||
} | ||
|
||
static inline void ata_get_ata_identify_serial_number(const char *buf, char *out) { | ||
ata_get_string(buf, 10, 19, out); | ||
} | ||
|
||
static inline ata_longword_t ata_get_ata_identify_total_addressable_sectors_28bit(const char *buf) { | ||
return ata_get_longword(buf, 60); | ||
} | ||
|
||
static inline void ata_get_ata_identify_model(const char *buf, char *out) { | ||
ata_get_string(buf, 27, 46, out); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_overwrite_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 59); | ||
return val & (1 << 14); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_write_uncorrectable_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 119); | ||
return val & (1 << 2); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_smart_error_logging_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 84); | ||
return val & (1 << 0); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_sense_data_enabled(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 120); | ||
return val & (1 << 6); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_smart_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 82); | ||
return val & (1 << 0); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_sct_data_tables_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 206); | ||
return val & (1 << 5); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_major_version_ata_atapi_7(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 80); | ||
return val & (1 << 7); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_iordy_disable_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 49); | ||
return val & (1 << 10); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_sata_non_zero_buffer_offsets_enabled(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 79); | ||
return val & (1 << 1); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_sata_hardware_feature_control_enabled(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 79); | ||
return val & (1 << 5); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_write_buffer_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 82); | ||
return val & (1 << 12); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_drat_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 69); | ||
return val & (1 << 14); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_read_look_ahead_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 82); | ||
return val & (1 << 6); | ||
} | ||
|
||
static inline bool ata_get_ata_identify_security_feature_set_supported(const char *buf) { | ||
ata_word_t val = ata_get_word(buf, 82); | ||
return val & (1 << 1); | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
|
||
echo "Regenerate generated files" | ||
|
||
src/smartdb/smartdb_gen_c.py src/smartdb/smartdb.xml > src/smartdb/smartdb_gen.c | ||
git add src/smartdb/smartdb_gen.c | ||
|
||
structs/ata_struct_2_h.py structs/ata_identify.yaml > include/ata_parse.h | ||
git add include/ata_parse.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1 @@ | ||
add_custom_command(OUTPUT smartdb/smartdb_gen.c | ||
COMMAND smartdb/smartdb_gen_c.py smartdb/smartdb.xml > smartdb/smartdb_gen.c | ||
DEPENDS smartdb/smartdb_gen_c.py smartdb/smartdb.xml | ||
) | ||
add_custom_target(ata_parse.h | ||
COMMAND ../structs/ata_struct_2_h.py ../structs/ata_identify.yaml > ../include/ata_parse.h | ||
DEPENDS ../structs/ata_struct_2_h.py ../structs/ata_identify.yaml) | ||
|
||
add_library(scsicmd STATIC ata.c ata_smart.c cdb.c parse_inquiry.c parse_read_cap.c parse_sense.c str_map.c smartdb/smartdb.c smartdb/smartdb_gen.c) | ||
add_dependencies(scsicmd ata_parse.h) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "smartdb.h" | ||
static const smart_table_t defaults = { | ||
.num_attrs = 26, | ||
.attrs = { | ||
{.id=1, .type=SMART_ATTR_TYPE_NONE, .name="Raw Read Error Rate", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=2, .type=SMART_ATTR_TYPE_NONE, .name="Throughput Performance", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=3, .type=SMART_ATTR_TYPE_NONE, .name="Spin Up Time", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=4, .type=SMART_ATTR_TYPE_NONE, .name="Start/Stop Count", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=5, .type=SMART_ATTR_TYPE_REALLOC, .name="Reallocated Sectors Count", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=7, .type=SMART_ATTR_TYPE_NONE, .name="Seek Error Rate", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=8, .type=SMART_ATTR_TYPE_NONE, .name="Seek Time Performance", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=9, .type=SMART_ATTR_TYPE_POH, .name="Power On Hours", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=10, .type=SMART_ATTR_TYPE_NONE, .name="Spin Retry Count", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=11, .type=SMART_ATTR_TYPE_NONE, .name="Drive Calibration Retry Count", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=12, .type=SMART_ATTR_TYPE_NONE, .name="Device Power Cycle Count", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=13, .type=SMART_ATTR_TYPE_NONE, .name="Read Soft Error Rate", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=191, .type=SMART_ATTR_TYPE_NONE, .name="G Sense Error Rate", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=192, .type=SMART_ATTR_TYPE_NONE, .name="Power Off Retract Count", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=193, .type=SMART_ATTR_TYPE_NONE, .name="Load/Unload Cycle Count", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=194, .type=SMART_ATTR_TYPE_TEMP, .name="Temperature", .raw=SMART_ATTR_RAW_DEC48, .offset=150}, | ||
{.id=195, .type=SMART_ATTR_TYPE_NONE, .name="Hardware ECC Recovered", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=196, .type=SMART_ATTR_TYPE_NONE, .name="Reallocation Event Count", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=197, .type=SMART_ATTR_TYPE_REALLOC_PENDING, .name="Pending Sector Reallocation Count", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=198, .type=SMART_ATTR_TYPE_NONE, .name="Off-Line Scan Uncorrecable Sector Count", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=199, .type=SMART_ATTR_TYPE_CRC_ERRORS, .name="CRC Error Count", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=200, .type=SMART_ATTR_TYPE_NONE, .name="Multi-zone Error Rate", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=240, .type=SMART_ATTR_TYPE_NONE, .name="Head Flying Hours", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=241, .type=SMART_ATTR_TYPE_NONE, .name="Total LBAs Written", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=242, .type=SMART_ATTR_TYPE_NONE, .name="Total LBAs Read", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
{.id=254, .type=SMART_ATTR_TYPE_NONE, .name="Free Fall Sensor", .raw=SMART_ATTR_RAW_DEC48, .offset=-1}, | ||
} | ||
}; | ||
const smart_table_t * smart_table_for_disk(const char *vendor, const char *model, const char *firmware) | ||
{ | ||
(void)vendor; | ||
(void)model; | ||
(void)firmware; | ||
return &defaults; | ||
} |