[WIP PATCH 3/4] udf: Fix reading minUDFReadRev and minUDFWriteRev from UDF 2.00+ VAT discs

From: Pali RohÃr
Date: Sun Jan 12 2020 - 13:00:08 EST


These two fields are stored in VAT and override previous values stored in
LVIDIU.

This change contains only implementation for UDF 2.00+. For UDF 1.50 there
is an optional structure "Logical Volume Extended Information" which is not
implemented in this change yet.

Signed-off-by: Pali RohÃr <pali.rohar@xxxxxxxxx>
---
fs/udf/super.c | 11 ++++++++++-
fs/udf/udf_sb.h | 2 ++
2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/fs/udf/super.c b/fs/udf/super.c
index e8661bf01..0dad63f88 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -1223,6 +1223,10 @@ static int udf_load_vat(struct super_block *sb, int p_index, int type1_index)
le32_to_cpu(vat20->numFiles);
map->s_type_specific.s_virtual.s_num_dirs =
le32_to_cpu(vat20->numDirs);
+ map->s_type_specific.s_virtual.s_min_udf_read_rev =
+ le16_to_cpu(vat20->minUDFReadRev);
+ map->s_type_specific.s_virtual.s_min_udf_write_rev =
+ le16_to_cpu(vat20->minUDFWriteRev);
map->s_type_specific.s_virtual.s_start_offset =
le16_to_cpu(vat20->lengthHeader);
map->s_type_specific.s_virtual.s_num_entries =
@@ -2238,7 +2242,12 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
goto error_out;
}

- if (sbi->s_lvd_udfrev >= 0x0102) { /* minUDFReadRev and minUDFWriteRev were introduced in UDF 1.02 */
+ if ((sbi->s_partmaps[sbi->s_partition].s_partition_type == UDF_VIRTUAL_MAP15 ||
+ sbi->s_partmaps[sbi->s_partition].s_partition_type == UDF_VIRTUAL_MAP20) &&
+ sbi->s_partmaps[sbi->s_partition].s_type_specific.s_virtual.s_has_additional_data) {
+ minUDFReadRev = sbi->s_partmaps[sbi->s_partition].s_type_specific.s_virtual.s_min_udf_read_rev;
+ minUDFWriteRev = sbi->s_partmaps[sbi->s_partition].s_type_specific.s_virtual.s_min_udf_write_rev;
+ } else if (sbi->s_lvd_udfrev >= 0x0102) { /* minUDFReadRev and minUDFWriteRev were introduced in UDF 1.02 */
minUDFReadRev = le16_to_cpu(lvidiu->minUDFReadRev);
minUDFWriteRev = le16_to_cpu(lvidiu->minUDFWriteRev);
} else {
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index c74abbc84..baac0357b 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -81,6 +81,8 @@ struct udf_virtual_data {
bool s_has_additional_data;
__u32 s_num_files;
__u32 s_num_dirs;
+ __u16 s_min_udf_read_rev;
+ __u16 s_min_udf_write_rev;
};

struct udf_bitmap {
--
2.20.1