From nobody Mon Nov 25 09:19:03 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1716717452; cv=none; d=zohomail.com; s=zohoarc; b=SH5wjJW3gWIkzkWrBkqB0I/kVOyj7bSSnfZXhVylOXAJt3wkpyUJ1RgGGhN6dMNeV10CKXQ2DDKzBYH6XLpt11GcbaCRHn31XrVZG3ubKMVe2NCLufmK9abf17Kw5As/ErsrhmDZwxb5yf7FH3FMYrUPCOu49cARL/EqGL/B/GQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716717452; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/aGPsWq5Naz4uqiF5AmaN5boMB6iQaQGhjOrt7FuaD8=; b=P2GzlPYcAMpfXXd2lzOjMvshfMvCkSgW/MqxYld3EoPkvKKNK238TI0nAjXijT+7rB2hCueJ9YtsB7WdMP4/T4qohIeS/tjcWxC6q2gVuxPlYB26X2eIm+7V1U93px9paBrEQ7VivZAjL/XHyJVnki8cSshSp+EvhpcBWdUyySA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1716717452673796.8794969514843; Sun, 26 May 2024 02:57:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sBAcP-0006DM-TB; Sun, 26 May 2024 05:56:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sBAcO-0006Co-IC; Sun, 26 May 2024 05:56:44 -0400 Received: from mail-oo1-xc2c.google.com ([2607:f8b0:4864:20::c2c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sBAcM-0003oq-VE; Sun, 26 May 2024 05:56:44 -0400 Received: by mail-oo1-xc2c.google.com with SMTP id 006d021491bc7-5b680c1fdd4so3031968eaf.1; Sun, 26 May 2024 02:56:42 -0700 (PDT) Received: from amjad-pc.. ([192.228.203.229]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-682227f1838sm4021368a12.46.2024.05.26.02.56.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 02:56:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716717401; x=1717322201; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/aGPsWq5Naz4uqiF5AmaN5boMB6iQaQGhjOrt7FuaD8=; b=cqtFrlpTfWF3oLWZGUS0VpUtipoEyofj3s4zA6w8w6cVM51ZmNpGWMqicLabtgYHCl G5xj55IdWqZPX9b+DcWmJejcC9f1RC4DyAVbVlUrYmUYCeuMiyyPDhlOJVWogtOGAryA prA73+0pIWHjbJe/CDYGNPL3XVKjRARQ1y5y8KAMKHrGLH2vZe4ryj7o+sAsrhNaxxrV iBPboS3S1Xt3T1/3b2uqFjFwPOhZkd7c8v5vgOGy+ZIk+qCEUt/OalVi3dGFcteC/DCG w6lyDeaRpRSUALTR03vxa1xxWFh0jAw4a/lf9jBG3FgHt41Y4ixfLtgorX9lfldW80nq en4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716717401; x=1717322201; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/aGPsWq5Naz4uqiF5AmaN5boMB6iQaQGhjOrt7FuaD8=; b=XFADQgT9byKLZIwjZBPNXeP+QMPS7VMHFtWa3jnfJ+ib8k4rESSE5xbXBVP8kL80/9 f5b4gH/MECxAIiQtdDxmvmLNJuNtxJjvlhLktrtk0/sr+AeHNzKpBQAqnZX/sFPsA4k6 V4IDOnH0B4JT+mmWBS1vC4tkZaUsIU9C65TGfpQ8U/s/qMMAVDcJkappVVrQpCS7MibH jxk/gGV5N36NxK8fHFGfZ+U6A1GzJnQXx8L6coQ+18FdYa+9TDAWgpILlR0ye5lqRzFQ Eh4Bhavku5XFxMAROaabMGjNGoxAtdB+c1+WUbeChYUHL+DmtRC+U89swxQyrqukOaqg SLPg== X-Forwarded-Encrypted: i=1; AJvYcCWisa0VIVhtk1sSvwzV5qAzqaOAE/6t+eIaTXVWDhEeGqqb6oFnjGNBXw6C17cn68LPs/3yElwVKPcSQUSTRZMudjw/FuY= X-Gm-Message-State: AOJu0Ywptra4sGKGxjtEMcshWw52dB48JMnfCxYm24Nu/nvJ8Nxe/FDb KCMKtoCz00oNUFyIzPQw5jYG0TAiSj5WaM4NeM8dNQkece34HB3vApTBETOG X-Google-Smtp-Source: AGHT+IF02c68RQd9m1+GGCU7SgrZ1UbneVRrtUhdeit643bsF4MvBK5VFkvPFD2lad4SmuiWYaCg/A== X-Received: by 2002:a05:6358:71cc:b0:18d:9e17:455f with SMTP id e5c5f4694b2df-197e5101158mr891480055d.12.1716717400688; Sun, 26 May 2024 02:56:40 -0700 (PDT) From: Amjad Alsharafi To: qemu-devel@nongnu.org Cc: Hanna Reitz , Kevin Wolf , "open list:vvfat" , Amjad Alsharafi Subject: [PATCH v3 2/6] vvfat: Fix usage of `info.file.offset` Date: Sun, 26 May 2024 17:56:02 +0800 Message-ID: <836a0ea26f641a4f0ff4b2bd8e9c9d17c59ef2d7.1716717181.git.amjadsharafi10@gmail.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::c2c; envelope-from=amjadsharafi10@gmail.com; helo=mail-oo1-xc2c.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1716717453850100002 Content-Type: text/plain; charset="utf-8" The field is marked as "the offset in the file (in clusters)", but it was being used like this `cluster_size*(nums)+mapping->info.file.offset`, which is incorrect. Additionally, removed the `abort` when `first_mapping_index` does not match, as this matches the case when adding new clusters for files, and its inevitable that we reach this condition when doing that if the clusters are not after one another, so there is no reason to `abort` here, execution continues and the new clusters are written to disk correctly. Signed-off-by: Amjad Alsharafi --- block/vvfat.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/block/vvfat.c b/block/vvfat.c index ab342f0743..cb3ab81e29 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1408,7 +1408,7 @@ read_cluster_directory: =20 assert(s->current_fd); =20 - offset=3Ds->cluster_size*(cluster_num-s->current_mapping->begin)+s= ->current_mapping->info.file.offset; + offset=3Ds->cluster_size*((cluster_num - s->current_mapping->begin= ) + s->current_mapping->info.file.offset); if(lseek(s->current_fd, offset, SEEK_SET)!=3Doffset) return -3; s->cluster=3Ds->cluster_buffer; @@ -1929,8 +1929,8 @@ get_cluster_count_for_direntry(BDRVVVFATState* s, dir= entry_t* direntry, const ch (mapping->mode & MODE_DIRECTORY) =3D=3D 0) { =20 /* was modified in qcow */ - if (offset !=3D mapping->info.file.offset + s->cluster= _size - * (cluster_num - mapping->begin)) { + if (offset !=3D s->cluster_size + * ((cluster_num - mapping->begin) + mapping->i= nfo.file.offset)) { /* offset of this cluster in file chain has change= d */ abort(); copy_it =3D 1; @@ -1944,7 +1944,6 @@ get_cluster_count_for_direntry(BDRVVVFATState* s, dir= entry_t* direntry, const ch =20 if (mapping->first_mapping_index !=3D first_mapping_in= dex && mapping->info.file.offset > 0) { - abort(); copy_it =3D 1; } =20 @@ -2404,7 +2403,7 @@ static int commit_mappings(BDRVVVFATState* s, (mapping->end - mapping->begin); } else next_mapping->info.file.offset =3D mapping->info.file.offs= et + - mapping->end - mapping->begin; + (mapping->end - mapping->begin); =20 mapping =3D next_mapping; } --=20 2.45.0