From patchwork Sun Jan 12 17:59:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 11329307 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 94ADB13A0 for ; Sun, 12 Jan 2020 18:00:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6F61E22314 for ; Sun, 12 Jan 2020 18:00:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i8Qzpy5L" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733173AbgALR7v (ORCPT ); Sun, 12 Jan 2020 12:59:51 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:43759 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733087AbgALR7u (ORCPT ); Sun, 12 Jan 2020 12:59:50 -0500 Received: by mail-wr1-f68.google.com with SMTP id d16so6359663wre.10; Sun, 12 Jan 2020 09:59:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QCSAs9Ek4jI/o8Pi01W4vaQei9UYS3BZtKQ6fy1s4sQ=; b=i8Qzpy5L+m2PxADtTeEwKCopBe2wBnkzJPoh/H3cnWrmCBAmGwymprF6x1GxRkhiwQ DsyTvoeiJU4ftVqF5mwwf8i9omLSc1nYURzpErwRWstbBzVl1PdEUGLM9xIqXPm2Bsge i2kRpEOsS5xutx1r53+jrkQI5t7HGmzs4BsepfO0JxlsjaueZ7nzC2fTGn2irtE0rtB/ 3oofhNscihYresTKOFOJ9G5YVnbpHp/qjlWoo0MogeTZ7wqEkBrErNBN/39ol5Gti4wG RbN5mMxHu8HR4HDycaHkRPnlY2Nl6cM7gSTTXLXMFldS5r+wjdhx0TnMKWOuTvPZ6//1 PExw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QCSAs9Ek4jI/o8Pi01W4vaQei9UYS3BZtKQ6fy1s4sQ=; b=G3eHhVKRVf17rtYsL0ylLrawwgMten6ZqZDBl4qNpnwKHCSctF/pWY4dYfcRG01GdN 3FplyY76tQr25Gtb+ORqzoTfLO/KtWnh/7NyESBw3wfGS/AfgD8q4N23gz1S/KG0AxGi M18e9okvBFEISvHIm92AGSTXtksKv7jA09btUsaxex8oCuuIFfEsbSPbXDRKYwij6tbz nZVKSE/AoGRY4cuwlg9tWA+JUAJOeutQMWtAPMXqApGwSUhxM+VUoBWmAC3FSNgNmD6I kjVDmnnM9swtE6HPZ8on8BM8Nd6JC5myPaXsKWuI/symX2FEcY+TXDhyXpVM8LYYO4Dj YbqA== X-Gm-Message-State: APjAAAUaLk/ZMlLUOY8EmnhcKeo/GKfjgoc6HvhO+k6WPSl5RNbKWYb7 Kj9VVzycfOs2sqXn+tKnTREBj6UV X-Google-Smtp-Source: APXvYqy4y3FhTYRAGrNKSgYn3eCjrHjmdaFH3crGP2UGVYjETXmkDw/81LjqCCdAzsz7tQfdzOMzGQ== X-Received: by 2002:a5d:4983:: with SMTP id r3mr14456440wrq.134.1578851988374; Sun, 12 Jan 2020 09:59:48 -0800 (PST) Received: from Pali-Latitude.lan (ip-89-103-160-142.net.upcbroadband.cz. [89.103.160.142]) by smtp.gmail.com with ESMTPSA id t25sm11076522wmj.19.2020.01.12.09.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 09:59:47 -0800 (PST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara Subject: [WIP PATCH 1/4] udf: Do not access LVIDIU revision members when they are not filled Date: Sun, 12 Jan 2020 18:59:30 +0100 Message-Id: <20200112175933.5259-2-pali.rohar@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200112175933.5259-1-pali.rohar@gmail.com> References: <20200112175933.5259-1-pali.rohar@gmail.com> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org minUDFReadRev, minUDFWriteRev and maxUDFWriteRev members were introduced in UDF 1.02. Previous UDF revisions used that area for implementation specific data. So in this case do not touch these members. To check if LVIDIU contain revisions members, first read UDF revision from LVD. If revision is at least 1.02 LVIDIU should contain revision members. This change should fix mounting UDF 1.01 images in R/W mode. Kernel would not touch, read overwrite implementation specific area of LVIDIU. Signed-off-by: Pali Rohár --- fs/udf/super.c | 37 ++++++++++++++++++++++++++----------- fs/udf/udf_sb.h | 3 +++ 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/fs/udf/super.c b/fs/udf/super.c index 2d0b90800..8df6e9962 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -765,7 +765,7 @@ static int udf_check_vsd(struct super_block *sb) } static int udf_verify_domain_identifier(struct super_block *sb, - struct regid *ident, char *dname) + struct regid *ident, char *dname, u16 *udf_rev) { struct domainIdentSuffix *suffix; @@ -779,6 +779,8 @@ static int udf_verify_domain_identifier(struct super_block *sb, goto force_ro; } suffix = (struct domainIdentSuffix *)ident->identSuffix; + if (udf_rev) + *udf_rev = le16_to_cpu(suffix->UDFRevision); if ((suffix->domainFlags & DOMAIN_FLAGS_HARD_WRITE_PROTECT) || (suffix->domainFlags & DOMAIN_FLAGS_SOFT_WRITE_PROTECT)) { if (!sb_rdonly(sb)) { @@ -801,7 +803,7 @@ static int udf_load_fileset(struct super_block *sb, struct fileSetDesc *fset, { int ret; - ret = udf_verify_domain_identifier(sb, &fset->domainIdent, "file set"); + ret = udf_verify_domain_identifier(sb, &fset->domainIdent, "file set", NULL); if (ret < 0) return ret; @@ -1404,7 +1406,7 @@ static int udf_load_logicalvol(struct super_block *sb, sector_t block, } ret = udf_verify_domain_identifier(sb, &lvd->domainIdent, - "logical volume"); + "logical volume", &sbi->s_lvd_udfrev); if (ret) goto out_bh; ret = udf_sb_alloc_partition_maps(sb, le32_to_cpu(lvd->numPartitionMaps)); @@ -2055,12 +2057,19 @@ static void udf_close_lvid(struct super_block *sb) mutex_lock(&sbi->s_alloc_mutex); lvidiu->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; lvidiu->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; - if (UDF_MAX_WRITE_VERSION > le16_to_cpu(lvidiu->maxUDFWriteRev)) - lvidiu->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION); - if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFReadRev)) - lvidiu->minUDFReadRev = cpu_to_le16(sbi->s_udfrev); - if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFWriteRev)) - lvidiu->minUDFWriteRev = cpu_to_le16(sbi->s_udfrev); + + /* minUDFReadRev, minUDFWriteRev and maxUDFWriteRev members were + * introduced in UDF 1.02. Previous UDF revisions used that area for + * implementation specific data. So in this case do not touch it. */ + if (sbi->s_lvd_udfrev >= 0x0102) { + if (UDF_MAX_WRITE_VERSION > le16_to_cpu(lvidiu->maxUDFWriteRev)) + lvidiu->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION); + if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFReadRev)) + lvidiu->minUDFReadRev = cpu_to_le16(sbi->s_udfrev); + if (sbi->s_udfrev > le16_to_cpu(lvidiu->minUDFWriteRev)) + lvidiu->minUDFWriteRev = cpu_to_le16(sbi->s_udfrev); + } + if (!UDF_QUERY_FLAG(sb, UDF_FLAG_INCONSISTENT)) lvid->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE); @@ -2220,8 +2229,14 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) ret = -EINVAL; goto error_out; } - minUDFReadRev = le16_to_cpu(lvidiu->minUDFReadRev); - minUDFWriteRev = le16_to_cpu(lvidiu->minUDFWriteRev); + + 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 { + minUDFReadRev = minUDFWriteRev = sbi->s_lvd_udfrev; + } + if (minUDFReadRev > UDF_MAX_READ_VERSION) { udf_err(sb, "minUDFReadRev=%x (max is %x)\n", minUDFReadRev, diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h index 3d83be54c..6bd0d4430 100644 --- a/fs/udf/udf_sb.h +++ b/fs/udf/udf_sb.h @@ -137,6 +137,9 @@ struct udf_sb_info { /* Fileset Info */ __u16 s_serial_number; + /* LVD UDF revision filled to media at format time */ + __u16 s_lvd_udfrev; + /* highest UDF revision we have recorded to this media */ __u16 s_udfrev; From patchwork Sun Jan 12 17:59:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 11329301 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A6C8D14B7 for ; Sun, 12 Jan 2020 18:00:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7AF7021744 for ; Sun, 12 Jan 2020 18:00:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="APD6gBkA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733197AbgALR7v (ORCPT ); Sun, 12 Jan 2020 12:59:51 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:39083 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733155AbgALR7v (ORCPT ); Sun, 12 Jan 2020 12:59:51 -0500 Received: by mail-wr1-f66.google.com with SMTP id y11so6379353wrt.6; Sun, 12 Jan 2020 09:59:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=I7p3MTVh7YW9DcnuTnIP7pDzwPRCSGKLfSdL+8Sg37M=; b=APD6gBkArkoCRa5hy0KIkpF9vcj82jkyOWBkslfE0wW7/PzK87pTLmwiYM6a7yM90a 8wzH0lzDh+vYapb5+OotTkwql512VUuDVJou0acaXY5hobfJz0MQWpbcOijOs/0YM/ue Ws/Z/zQeQ7TNy7btBJ52k0A1rn1SrOCjf8CqWO/MXGQdoDIknS4nbhPcmMQjJ7XAD52H Oybo1fnhoeu3Pc1ZPp6g2OdgUvE33DxP7/3sfxgGl3woY76uwmumXd1A9TXmSvu2gyXw 6LN/jIh2fL+SS4B4tmjFQDiJEAg9vyJH9ETqz9hBOr7LgibghfiTuNeqgUR83jfZdipv I9lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=I7p3MTVh7YW9DcnuTnIP7pDzwPRCSGKLfSdL+8Sg37M=; b=KwfQCTtlpq6+y1R8OiO0UNGnBKvWG0Z12w4/kM90AhQ+Yz7ydzuJMC3mAA2NOiJjGy 6Y6RkW9R/XMiLcxGM39vuLzOTS4uzLxZIdhQV45JDlnZ8c2y0FG9lrw9GeMLSneKJbeG l0i+k9RGSUlnm4uAiF00rguu9rV7SOjmlyivK0xStYeDU6Di3AcHeic4+HTEyXadBjt8 M5h1+Ft8dL9iP2TqwQLagZmDDaW3Hak6AHaEDYOfND5iZ5V2Yvl6zOCXrddZu8r7q3s9 5FsRk8NrtyVPg7Sdiq7J+PzMs6okaA6FNaVxU0+MoqrevoO/37T1/WeZibQ1fkF+fUqr 5gdw== X-Gm-Message-State: APjAAAUpmBkn4GJW4LbcXHwBi/IW/8zEdeft/8x4SesGBfshHk3fbtyj iF7dt1puNBBa6AHeq2b3A+RQPM33 X-Google-Smtp-Source: APXvYqx8jVVXP2mT9xjVxDqVe2Ls7boR3vrxUDKVudBmPvhg1niv2uT8b9SxZjnAcIt0ulVVbx7gVg== X-Received: by 2002:a5d:4b8f:: with SMTP id b15mr15105861wrt.100.1578851989330; Sun, 12 Jan 2020 09:59:49 -0800 (PST) Received: from Pali-Latitude.lan (ip-89-103-160-142.net.upcbroadband.cz. [89.103.160.142]) by smtp.gmail.com with ESMTPSA id t25sm11076522wmj.19.2020.01.12.09.59.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 09:59:48 -0800 (PST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara Subject: [WIP PATCH 2/4] udf: Fix reading numFiles and numDirs from UDF 2.00+ VAT discs Date: Sun, 12 Jan 2020 18:59:31 +0100 Message-Id: <20200112175933.5259-3-pali.rohar@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200112175933.5259-1-pali.rohar@gmail.com> References: <20200112175933.5259-1-pali.rohar@gmail.com> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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 --- fs/udf/super.c | 25 ++++++++++++++++++++++--- fs/udf/udf_sb.h | 3 +++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/fs/udf/super.c b/fs/udf/super.c index 8df6e9962..e8661bf01 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c @@ -1202,6 +1202,8 @@ static int udf_load_vat(struct super_block *sb, int p_index, int type1_index) map->s_type_specific.s_virtual.s_start_offset = 0; map->s_type_specific.s_virtual.s_num_entries = (sbi->s_vat_inode->i_size - 36) >> 2; + /* TODO: Add support for reading Logical Volume Extended Information (UDF 1.50 Errata, DCN 5003, 3.3.4.5.1.3) */ + map->s_type_specific.s_virtual.s_has_additional_data = false; } else if (map->s_partition_type == UDF_VIRTUAL_MAP20) { vati = UDF_I(sbi->s_vat_inode); if (vati->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) { @@ -1215,6 +1217,12 @@ static int udf_load_vat(struct super_block *sb, int p_index, int type1_index) vati->i_ext.i_data; } + map->s_type_specific.s_virtual.s_has_additional_data = + true; + map->s_type_specific.s_virtual.s_num_files = + 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_start_offset = le16_to_cpu(vat20->lengthHeader); map->s_type_specific.s_virtual.s_num_entries = @@ -2417,9 +2425,20 @@ static int udf_statfs(struct dentry *dentry, struct kstatfs *buf) buf->f_blocks = sbi->s_partmaps[sbi->s_partition].s_partition_len; buf->f_bfree = udf_count_free(sb); buf->f_bavail = buf->f_bfree; - buf->f_files = (lvidiu != NULL ? (le32_to_cpu(lvidiu->numFiles) + - le32_to_cpu(lvidiu->numDirs)) : 0) - + buf->f_bfree; + + 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) + buf->f_files = sbi->s_partmaps[sbi->s_partition].s_type_specific.s_virtual.s_num_files + + sbi->s_partmaps[sbi->s_partition].s_type_specific.s_virtual.s_num_dirs + + buf->f_bfree; + else if (lvidiu != NULL) + buf->f_files = le32_to_cpu(lvidiu->numFiles) + + le32_to_cpu(lvidiu->numDirs) + + buf->f_bfree; + else + buf->f_files = buf->f_bfree; + buf->f_ffree = buf->f_bfree; buf->f_namelen = UDF_NAME_LEN; buf->f_fsid.val[0] = (u32)id; diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h index 6bd0d4430..c74abbc84 100644 --- a/fs/udf/udf_sb.h +++ b/fs/udf/udf_sb.h @@ -78,6 +78,9 @@ struct udf_sparing_data { struct udf_virtual_data { __u32 s_num_entries; __u16 s_start_offset; + bool s_has_additional_data; + __u32 s_num_files; + __u32 s_num_dirs; }; struct udf_bitmap { From patchwork Sun Jan 12 17:59:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 11329303 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DB80592A for ; Sun, 12 Jan 2020 18:00:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B034421569 for ; Sun, 12 Jan 2020 18:00:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="u4VYHSVt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733220AbgALR7w (ORCPT ); Sun, 12 Jan 2020 12:59:52 -0500 Received: from mail-wm1-f52.google.com ([209.85.128.52]:51302 "EHLO mail-wm1-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733191AbgALR7w (ORCPT ); Sun, 12 Jan 2020 12:59:52 -0500 Received: by mail-wm1-f52.google.com with SMTP id d73so7216562wmd.1; Sun, 12 Jan 2020 09:59:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=UI0olG8Ukex2VWgAiT/l06nIRGJslLR40+ZHv7ZVUKc=; b=u4VYHSVtc62kKwCw8LfnRdHaQz785lmJ/mFM6OwbwFG5eM/ox/lljIrE490W5Ivl1E TvVGQ031Wu269rPLrJPT61hw4wFDbd0xQCLGONvT5PjYTWlcqw4QShlWzkiLJbcP4LwE D6MWSImvjwW4uiJMmKNF53GD2dPjUUlr2IioWYh5HS/wTnORZellfnu04Kk2zewQvGuk Kpra+pFY6+0LbSt5aIzuTrBKAD1weJI0gpgLdelEgDO/LeUeoUkI+kwV827xCOnoo3n5 m4c8iICpKkPWsMqwIOpYu/btWo08a4CN6V31UoN7g1JQrSJFtNp5SYd74G4ECIc94uyd r+Uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UI0olG8Ukex2VWgAiT/l06nIRGJslLR40+ZHv7ZVUKc=; b=K8cyzcYICi0OOSeh6OeMpz0pbHh2kbE3csN7yHbs0hWM/x7VF8lx4rXZwedu7iyt4h xbzuTmEvSMRQ5hRDZcUpRLmmkwr4KBjcs46w9EBjc9Z4phkGOhOikVStmc+ENwSyJh2n tdFVOSP+CqJ7Nix3CyGFuUEdGpBLZl8spZkxbUst22hfClGfLTtF6FYCJOfB0ic8u5vC wwvszQzKODwIXPiQvEVLEOVqACrwfvyy8pFQ0PVD/hq1XEokQYZe0ZvYcnJv4cRXNLYP GVlXkXE1cpi1dTZeESKs+QDBI7hWPDMnnWwBLt4qSmg4Q4EnxH1ud7MttkHhDWHzZ/bN CEbg== X-Gm-Message-State: APjAAAUe+zPWUiZXaeBuEGmvy8VYd/nInxGosEjh6NRxSPl3fNFCYHBK yrAGx4AuCqKjm0m4mD0lYYVstTbQ X-Google-Smtp-Source: APXvYqwIILguQViiff3Pti4Cez1bl6U3fwyMu1qvpJl99JqO/PKZcXKhB0sk5rqPaBqdjWso1LIdyA== X-Received: by 2002:a7b:c450:: with SMTP id l16mr14913994wmi.166.1578851990392; Sun, 12 Jan 2020 09:59:50 -0800 (PST) Received: from Pali-Latitude.lan (ip-89-103-160-142.net.upcbroadband.cz. [89.103.160.142]) by smtp.gmail.com with ESMTPSA id t25sm11076522wmj.19.2020.01.12.09.59.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 09:59:49 -0800 (PST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara Subject: [WIP PATCH 3/4] udf: Fix reading minUDFReadRev and minUDFWriteRev from UDF 2.00+ VAT discs Date: Sun, 12 Jan 2020 18:59:32 +0100 Message-Id: <20200112175933.5259-4-pali.rohar@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200112175933.5259-1-pali.rohar@gmail.com> References: <20200112175933.5259-1-pali.rohar@gmail.com> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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 --- 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 { From patchwork Sun Jan 12 17:59:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 11329305 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2134D18B6 for ; Sun, 12 Jan 2020 18:00:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E871921569 for ; Sun, 12 Jan 2020 18:00:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rXMVpie4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733237AbgALR7z (ORCPT ); Sun, 12 Jan 2020 12:59:55 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:37616 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733203AbgALR7x (ORCPT ); Sun, 12 Jan 2020 12:59:53 -0500 Received: by mail-wr1-f68.google.com with SMTP id w15so6401250wru.4; Sun, 12 Jan 2020 09:59:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=2z5jKKd1kP0MGK92fjPfQhagxUNB4WYrYfTGQCeaJaI=; b=rXMVpie4I6835JSVbDI3sQTxOTKQBd4BFGhjhKZrbphGEySSZzqRSr0qnd2eIKPPo8 vdvgA7v/itexM++eH+lQ1NpYal+yPaIg3u7nvqBVXSwIAHraetE+pj0VG571Gd1ofU4T lQ4OnuIdr0s0UjvdY2QwqFNLFQM/L/nOGg+0OUu2+NwqxbNNT0Lj0VRa/y682ZwvHLXW ul72ef0RkEjARu+VTWER4uOHcsqDgoZaCpf3htgZhd/Y86waa6n4Wh18RjCLljM4BiFB CYcVOizz3KjADECUewAdUh8eJgBkdoTnr1ZgD1pFsD2K9jdWnmuQNL4QXal/E9o9apje 7Kww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2z5jKKd1kP0MGK92fjPfQhagxUNB4WYrYfTGQCeaJaI=; b=hL8POZuczpWDDAddz/SKEF8H75kj+zqRHmZUvo24JDyMrNwCuvKWSoVBb+K7KKZ/8g CS8sJjj1nPrCP3B8RuyVSk6X87PDw8lpw62OPhX6xXGPHBCKfgUeceZfayQsmteG2TjM 2dhi8ayMeM4qX7wcuddLSL2vphhOS2r2ssl463h8VO5yh4Vrzagzst3QyESnAU6AWJJM Omx4mnhNIdxgQ33EkPdbDHrTEhQLKOj0yQ5M5a7GUCLLeXyl9QA3dn99kTELe3ykiqnK 4csGqNhwZcL8Ywpk66VDhn2cJhXX9NZNFZmIGVjmm2EvDY4ehTrUmZtdC87k1umMHyKL XnCw== X-Gm-Message-State: APjAAAWChXJnTT7KLn81ioe1dwYZK5MtBwxw3cP5tj4P8R5x5HSjID2v CtzBlq1NsCNE1lfv9DVDa6xWZ+C8 X-Google-Smtp-Source: APXvYqzgINU2cjDfDKUuG7UoPCMbyduVF4vZdkmSesEde07NJ1C2f9Pfn0IOeksN6sakxsL/wGRVyA== X-Received: by 2002:adf:f5cf:: with SMTP id k15mr14775327wrp.182.1578851991201; Sun, 12 Jan 2020 09:59:51 -0800 (PST) Received: from Pali-Latitude.lan (ip-89-103-160-142.net.upcbroadband.cz. [89.103.160.142]) by smtp.gmail.com with ESMTPSA id t25sm11076522wmj.19.2020.01.12.09.59.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2020 09:59:50 -0800 (PST) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara Subject: [WIP PATCH 4/4] udf: Allow to read UDF 2.60 discs Date: Sun, 12 Jan 2020 18:59:33 +0100 Message-Id: <20200112175933.5259-5-pali.rohar@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200112175933.5259-1-pali.rohar@gmail.com> References: <20200112175933.5259-1-pali.rohar@gmail.com> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Current udf implementation now should be able to properly mount and read images with UDF 2.60 revision in R/O mode without any problem. Signed-off-by: Pali Rohár --- fs/udf/udf_sb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h index baac0357b..be8cb9f3b 100644 --- a/fs/udf/udf_sb.h +++ b/fs/udf/udf_sb.h @@ -6,7 +6,7 @@ #include #include -#define UDF_MAX_READ_VERSION 0x0250 +#define UDF_MAX_READ_VERSION 0x0260 #define UDF_MAX_WRITE_VERSION 0x0201 #define UDF_FLAG_USE_EXTENDED_FE 0