diff --git a/messages/tape_linux_sg/root.txt b/messages/tape_linux_sg/root.txt index 5bfc632b..167a2004 100644 --- a/messages/tape_linux_sg/root.txt +++ b/messages/tape_linux_sg/root.txt @@ -138,6 +138,7 @@ root:table { 30295I:string { "Have unstable TUR response, start over (Cur = %d, Prev = %d)." } 30296I:string { "Capturing a stable TUR at line %d." } 30297W:string { "Cannot retrieve drive dump: failed to communicate with drive. Tried (%d) times." } + 30298I:string { "Sense data returned unknown cart type, compat: assume_cart_type from density code (%x %x) " } 30392D:string { "Backend %s %s." } 30393D:string { "Backend %s: %d %s." } diff --git a/src/tape_drivers/linux/sg/sg_tape.c b/src/tape_drivers/linux/sg/sg_tape.c index 19f2beb8..d5910746 100644 --- a/src/tape_drivers/linux/sg/sg_tape.c +++ b/src/tape_drivers/linux/sg/sg_tape.c @@ -2761,6 +2761,12 @@ int sg_load(void *device, struct tc_position *pos) priv->cart_type = buf[2]; } + ret = is_known_tape_type(priv->cart_type); + if (ret == -LTFS_UNSUPPORTED_CART) { + priv->cart_type = assume_cart_type(priv->density_code); + ltfsmsg(LTFS_INFO, 30298I, priv->cart_type, priv->density_code); + } + if (priv->cart_type == 0x00) { ltfsmsg(LTFS_WARN, 30265W); ltfs_profiler_add_entry(priv->profiler, NULL, TAPEBEND_REQ_EXIT(REQ_TC_LOAD)); diff --git a/src/tape_drivers/vendor_compat.c b/src/tape_drivers/vendor_compat.c index 0df8941f..30937371 100644 --- a/src/tape_drivers/vendor_compat.c +++ b/src/tape_drivers/vendor_compat.c @@ -396,6 +396,37 @@ int is_supported_tape(unsigned char type, unsigned char density, bool *is_worm) return ret; } +int is_known_tape_type(unsigned char type) +{ + // Thought about using supported_cart[] here, but it does not contain + // all known tape types. Different use case. + switch (type) { + case TC_MP_LTO1D_CART: + case TC_MP_LTO2D_CART: + case TC_MP_LTO3D_CART: + case TC_MP_LTO4D_CART: + case TC_MP_LTO5D_CART: + case TC_MP_LTO6D_CART: + case TC_MP_LTO7D_CART: + case TC_MP_LTO8D_CART: + case TC_MP_LTO9D_CART: + case TC_MP_LTO10D_CART: + case TC_MP_LTOP10D_CART: + case TC_MP_LTO3W_CART: + case TC_MP_LTO4W_CART: + case TC_MP_LTO5W_CART: + case TC_MP_LTO6W_CART: + case TC_MP_LTO7W_CART: + case TC_MP_LTO8W_CART: + case TC_MP_LTO9W_CART: + case TC_MP_LTO10W_CART: + return 0; + default: + return -LTFS_UNSUPPORTED_CART; + } + return 0; +} + void init_error_table(int vendor, struct error_table **standard_table, struct error_table **vendor_table) diff --git a/src/tape_drivers/vendor_compat.h b/src/tape_drivers/vendor_compat.h index ebf8361c..770a84bc 100644 --- a/src/tape_drivers/vendor_compat.h +++ b/src/tape_drivers/vendor_compat.h @@ -70,6 +70,7 @@ struct supported_device **get_supported_devs(int vendor); bool drive_has_supported_fw(int vendor, int drive_type, const unsigned char * const revision); unsigned char assume_cart_type(const unsigned char dc); int is_supported_tape(unsigned char type, unsigned char density, bool *is_worm); +int is_known_tape_type(unsigned char type); void init_error_table(int vendor, struct error_table **standard_table,