From patchwork Tue Sep 4 07:49:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 145854 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3363932ljw; Tue, 4 Sep 2018 00:52:09 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYeb7nxrz2vRHvkQNBRlOGxTkx27Oq+j1UxEL9A+VviVt55VGx5MkBwxcDwoHeozQY4Y0R6 X-Received: by 2002:a50:9943:: with SMTP id l3-v6mr36342337edb.198.1536047529237; Tue, 04 Sep 2018 00:52:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536047529; cv=none; d=google.com; s=arc-20160816; b=glA/zLIEt3iC/QGWXvbXpvBGQHGbPDdwn1L5p0wyx3ez5CQPRewNZRG6JlwhhPDHWo 9uT68KYFP/OlQ2DgV9muN2AqelnM1QfWj5E38/9rA9SeOa4NfaREflWUXjTRJW2ywTWX BlbeVFWIdcVxtl6y247BOA4G5yz+mKBQ/HtHvZLoJlGQw1JDJyTczH+Bml3TPynKdDZU AM+s4aZe+ieFvKtqeb0mJCQWr/K9Cc8uxKT0ShCyly6TOVHNNJbEQz1QtPKdT3vK6aKh tSaW4ZKOTV6ODkkwkooBT99yTkriYr6d/CgnjCsmEQu76mlnoIz1+HpE9rxX022OlgY5 LqyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:arc-authentication-results; bh=zzLvVeu9I30xNtYdIfH1X8vn7lxPReL5Oym6eFAN7TE=; b=n/ggM1VW4u5G4g0+OPuqYIvOr0sP1H1Kc2JaxgSEIDqbAiILBCBlGE+NChdPI7x416 5bV5xUxxvNFw2C3mRhMk6lmhYbG+B/nirfM7NIRla8L3DOEshJn7ctF+YI45Prdo41UB 980awGOEWYXAIpIG6UjjkwBY9ACnplI1cgXjJg6wYUIgZZZEnJi1nkjswo6RGGr2G5x8 8c0D5XaeCfBzRT4U4mLZnp43q6WYgzJv0MCBKKyok28v8T5uMkZmXC2TGslZkPdqqQrP Zy1hRRGp+M0zAT+onpxnVAnTYIB/7T+lfwRhZDjU7vLkDgr9BXMR614KkAIy+ZX3No+W uo3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=eJxWPKOz; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id q23-v6si4055430eds.14.2018.09.04.00.52.09; Tue, 04 Sep 2018 00:52:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=eJxWPKOz; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id DAADEC21E49; Tue, 4 Sep 2018 07:50:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id D6573C21F00; Tue, 4 Sep 2018 07:50:17 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D6455C21DA6; Tue, 4 Sep 2018 07:50:07 +0000 (UTC) Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by lists.denx.de (Postfix) with ESMTPS id 10092C21F24 for ; Tue, 4 Sep 2018 07:50:07 +0000 (UTC) Received: by mail-pf1-f171.google.com with SMTP id l9-v6so1270728pff.9 for ; Tue, 04 Sep 2018 00:50:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3qrr9QH6inJDbghfQTPCEefOHDyZ8p0CbM4DD7Np98c=; b=eJxWPKOzKZGBivwX8oer+YhGAafi9W8uVblp71/ioprob9CKN83gDe+qQtdGp6Jupb D3/UPfmkerS3TtRFeDxEwQ2JqsjZT7d/eh/uJffQa4Ja153nZFqeTGzq4ZltE0gtrru9 lHAuBb7fq6LHeC3ckU0LfkkR/gvYmSHs6x5lI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3qrr9QH6inJDbghfQTPCEefOHDyZ8p0CbM4DD7Np98c=; b=NUdRNqrtxpdEP2YO824wFDf6AidRh+y9/v4obmb99ao4rfyPfHJX8bYnEu1iMvdTKz dxeuY7fQzG2nmmFaG3tSfTUJ0PFB4gDy/4roFQkLHOngNod8+nkE2C/4qiUctb2UtSvS 3Q67OFHhzJF6mbNz2/4srFzkyPVzNKbnOiRO6qrUmWn2sDyTitVN0dcGa/0zh4KVgg9H wqsNJOyT8Q1VX34dyr8f+2FObeEIZYNyeR0ocKqE0oYpSDBQy0UgLFn/R2kolJ69JTCs PR3evfEzAD5Uwk/mnS1no3B7D4UY3tiyg/me2PlUnD7kGiUyHYgkiqbzU5PSpyDBgNzJ lMvA== X-Gm-Message-State: APzg51BItPwvqtoX0u3frxQ1s4JJlBr+N4ZoSKGJKDGi3ubByPRTeCJe tkCSX5Mqz3N8cQ/YhUwPPUYy3w== X-Received: by 2002:a63:4306:: with SMTP id q6-v6mr28902917pga.181.1536047405732; Tue, 04 Sep 2018 00:50:05 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id p19-v6sm24517679pgh.60.2018.09.04.00.50.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Sep 2018 00:50:05 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com Date: Tue, 4 Sep 2018 16:49:27 +0900 Message-Id: <20180904074948.18146-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180904074948.18146-1-takahiro.akashi@linaro.org> References: <20180904074948.18146-1-takahiro.akashi@linaro.org> Cc: xypron.glpk@gmx.de, agraf@suse.de, u-boot@lists.denx.de Subject: [U-Boot] [PATCH v2 02/23] fs: fat: extend get_fs_info() for write use X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" get_fs_info() was introduced in major re-work of read operation by Rob. We want to reuse this function in write operation by extending it with additional members in fsdata structure. Signed-off-by: AKASHI Takahiro --- fs/fat/fat.c | 7 +++++++ include/fat.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/fs/fat/fat.c b/fs/fat/fat.c index 4efe8a3edaf1..0576658dde09 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -558,10 +558,17 @@ static int get_fs_info(fsdata *mydata) if (mydata->fatsize == 32) { mydata->fatlength = bs.fat32_length; + mydata->total_sect = bs.total_sect; } else { mydata->fatlength = bs.fat_length; + mydata->total_sect = (bs.sectors[1] << 8) + bs.sectors[0]; + if (!mydata->total_sect) + mydata->total_sect = bs.total_sect; } + if (!mydata->total_sect) /* unlikely */ + mydata->total_sect = (u32)cur_part_info.size; + mydata->fats = bs.fats; mydata->fat_sect = bs.reserved; mydata->rootdir_sect = mydata->fat_sect + mydata->fatlength * bs.fats; diff --git a/include/fat.h b/include/fat.h index c02839dcb040..127e6622a9b0 100644 --- a/include/fat.h +++ b/include/fat.h @@ -175,6 +175,8 @@ typedef struct { int fatbufnum; /* Used by get_fatent, init to -1 */ int rootdir_size; /* Size of root dir for non-FAT32 */ __u32 root_cluster; /* First cluster of root dir for FAT32 */ + u32 total_sect; /* Number of sectors */ + int fats; /* Number of FATs */ } fsdata; static inline u32 clust_to_sect(fsdata *fsdata, u32 clust)