From patchwork Mon May 13 05:49:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1098661 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="DmyPas7/"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 452VLR6S7xz9sBr for ; Mon, 13 May 2019 15:51:27 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 90B1DC21EE5; Mon, 13 May 2019 05:50:19 +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=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 B1932C21ECA; Mon, 13 May 2019 05:50:02 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0FE1DC21EE3; Mon, 13 May 2019 05:49:53 +0000 (UTC) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by lists.denx.de (Postfix) with ESMTPS id ADA1DC21EE3 for ; Mon, 13 May 2019 05:49:52 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id v80so6577870pfa.3 for ; Sun, 12 May 2019 22:49:52 -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 :mime-version:content-transfer-encoding; bh=92navjrFEoO+jjF1XDsnouVBrx0e0+dsjONl8lKaFSU=; b=DmyPas7/QZk5IVOB6Wk2QsLnENlEnDc/9BfvlrtPKlSJxNAEHGxQVfF74D3NiOxFDQ V7iLz0IbZc/pgYPEAA6HgCNqIRqjCLDj57L5J2urj++zPfbdFH962Y4FREkmgepuC13b VNYZfs89i+f8IBLuQIvH8MvSnQVuekmZNNirpgOk+2d9wlbJ3xVJNkmcjYkQkGP45EMr fXH1zED+oWsI4RJV+xIdyxTPWEWvit8sZ9x3fL3Mndcd3MBbuGfuZm6zKAVbB96ZrUh3 7BL37ZJ6nElCxpm449z8qW6G4SFW7JA46VkhzYx7IRBBRk7ljqf3dZIqn7d6Pv+s5IhZ AYGQ== 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:mime-version:content-transfer-encoding; bh=92navjrFEoO+jjF1XDsnouVBrx0e0+dsjONl8lKaFSU=; b=SpuxkzRVPR09apZ2qiZ/14q1OLYiyBUUDntN4CMbHBGBZW9FlyCFzTbNYblqL7oCE3 pbnOG1UdO5K296mptVFsZNhzl9yP7IGWuHDyKRwgyvoPBkE5sfWyZ9OXQV89XuNUCiAN hkNRwerbkNd4D+28pFVdNGT1CfjiYeDYztq4ClNFTB725nFYsqR22RPPp5DxCo7INkMv yyl8jy1uR4XIuckEYRkqp5qqUKNfNW3a0b2pzIoMiJ82J2lDrQsbtOrkNCOcvJM0uzRx xVY+PtLCPRgHRKAonUvkEf9U2PdPWzRTT4+c7B0pD0iLZ4TtLw7ToMTUfkYw3XFi4IuW teGQ== X-Gm-Message-State: APjAAAVKlUtZdRyLqh4MtuiSRNOyFVayaZOt1lSBFHAWpIxHkYGv/aOV DmanCAuUTvlZgVCrLjjK9VPgSg== X-Google-Smtp-Source: APXvYqx7N6AS1jXqJxm9KY1Ws4I7XmqHrb+q6uJP93rivacZ72k10X6PD6v+3DTJxSM5eq7omScYDw== X-Received: by 2002:a63:7887:: with SMTP id t129mr28519517pgc.339.1557726591395; Sun, 12 May 2019 22:49:51 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id r124sm9602168pgr.91.2019.05.12.22.49.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 May 2019 22:49:50 -0700 (PDT) From: AKASHI Takahiro To: trini@konsulko.com Date: Mon, 13 May 2019 14:49:26 +0900 Message-Id: <20190513054927.17890-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190513054927.17890-1-takahiro.akashi@linaro.org> References: <20190513054927.17890-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH 3/4] fs: fat: allocate a new cluster for root directory of fat32 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Contrary to fat12/16, fat32 can have root directory at any location and its size can be expanded. Without this patch, root directory won't grow properly and so we will eventually fail to add files under root directory. Please note that this can happen even if you delete many files as deleted directory entries are not reclaimed but just marked as "deleted" under the current implementation. Signed-off-by: AKASHI Takahiro Tested-by: Heinrich Schuchardt --- fs/fat/fat_write.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c index da1753d545ac..3bb9eac097eb 100644 --- a/fs/fat/fat_write.c +++ b/fs/fat/fat_write.c @@ -247,8 +247,11 @@ fill_dir_slot(fat_itr *itr, const char *l_name) if (itr->remaining == 0) flush_dir(itr); + /* allocate a cluster for more entries */ if (!fat_itr_next(itr)) - if (!itr->dent && !itr->is_root && new_dir_table(itr)) + if (!itr->dent && + (!itr->is_root || itr->fsdata->fatsize == 32) && + new_dir_table(itr)) return -1; } @@ -980,7 +983,10 @@ static dir_entry *find_directory_entry(fat_itr *itr, char *filename) return itr->dent; } - if (!itr->dent && !itr->is_root && new_dir_table(itr)) + /* allocate a cluster for more entries */ + if (!itr->dent && + (!itr->is_root || itr->fsdata->fatsize == 32) && + new_dir_table(itr)) /* indicate that allocating dent failed */ itr->dent = NULL;