From patchwork Wed Dec 15 01:53:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Campbell Suter X-Patchwork-Id: 1567983 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=snapit.group header.i=@snapit.group header.a=rsa-sha256 header.s=shd header.b=dZgZ4icQ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JDJFN41ppz9sVq for ; Wed, 15 Dec 2021 12:54:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CA7E58192A; Wed, 15 Dec 2021 02:53:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=snapit.group Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=snapit.group header.i=@snapit.group header.b="dZgZ4icQ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 82E2282AB1; Wed, 15 Dec 2021 02:53:52 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 12670811D8 for ; Wed, 15 Dec 2021 02:53:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=snapit.group Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=campbell@snapit.group Received: by mail-pf1-x42b.google.com with SMTP id x131so19306344pfc.12 for ; Tue, 14 Dec 2021 17:53:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=snapit.group; s=shd; h=message-id:date:mime-version:user-agent:content-language:to:cc:from :subject:content-transfer-encoding; bh=dx+qKDVoLYkadAFF3orYr3oBp9eWdmj3EGEBxUd2ZNw=; b=dZgZ4icQrIkoCMQTOCAwhEMdZbXBN7+1N3Cs5t1ljMspEUL0Fwg7iTJ43ZfI6sNpIk Nwubz8+f2UHsxCJJLKbMSXE0vArPz17O1UcVdhzbLdw00nh30ksmMWnT5Pz/8FQKZ3dE cccKifU2I2U+BVgsLm6fRBD9dv+if4bY0ij/U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:from:subject:content-transfer-encoding; bh=dx+qKDVoLYkadAFF3orYr3oBp9eWdmj3EGEBxUd2ZNw=; b=2gr2K4dhmGjfDfPzjvOanHrcCHsmaYj7oOXW8tkRhKZJ8nhY/7WjHB0HSMTMb2ka0S 4XdKurWfzXLS3HilSQDn51UwjudNx/J28fCDx09vDMh6dN/P6q3OZ1HDHv5TMpm7J5Oe IicZ5SlehEfkB/QkDKkivdmK4abe/C+l6Ty881aLmEtvNFR/odUFqQQSjF18bhZoYA6+ t4fbUBEjEN+r++7UNNms1sdTjcs3tJmg9NQ3dTWqpzA+M5jAyMTWFkn5ko1iwltuKhsq PTVb67GBh0SsBwHtoqruqDtGWOYqOItd1N8Laiy0E+NrhO+VBblZAH46jKEYr6E+6hIU d99w== X-Gm-Message-State: AOAM53117hmzYc0A4P7EqsPHivtH+T784oldog7it3NYSAGGW6x/kx5u mCVooIZMbUnpHoSUIAJi0RuQAONmlbRZd2CeY7/sABkIx0HCifY+M3dhO1tj39KhqVFjT3uvSM1 XCYaR854ST4ySJfsxYPmA5ZLmZdvzWlTEdnuDiArnFI7bPekkYLy9mTXv5mH+0Rt795J+Vg== X-Google-Smtp-Source: ABdhPJzDvLHIfBYi+PNqAvaeDwoFz6CVC9KBM9cvklyLtTLOr/9UwtQgaXXgObkS9nUWcosdBnwWhA== X-Received: by 2002:a05:6a00:cc9:b0:49f:b439:8930 with SMTP id b9-20020a056a000cc900b0049fb4398930mr7055933pfv.86.1639533227227; Tue, 14 Dec 2021 17:53:47 -0800 (PST) Received: from ?IPV6:2406:e002:b403:e201:4fe5:a777:7604:98b? ([2406:e002:b403:e201:4fe5:a777:7604:98b]) by smtp.gmail.com with ESMTPSA id v19sm3530551pju.32.2021.12.14.17.53.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Dec 2021 17:53:46 -0800 (PST) Message-ID: <2c0316b0-8f40-550b-d1cf-a72e812d55a4@snapit.group> Date: Wed, 15 Dec 2021 14:53:43 +1300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Content-Language: en-GB To: u-boot@lists.denx.de Cc: Joao Marcos Costa , Miquel Raynal , Thomas Petazzoni From: Campbell Suter Subject: [PATCH] squashfs: Fix sqfsls errors when root is a ldir X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.38 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" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Previously, if root had more than 256 files or otherwise needed to be an ldir, sqfsls would emit the error 'Inode not found.' which was caused by code in sqfs_search_dir assuming it was a regular directory inode. Signed-off-by: Campbell Suter Reviewed-by: Miquel Raynal --- fs/squashfs/sqfs.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c index e2d91c654c..4d7bf76fa3 100644 --- a/fs/squashfs/sqfs.c +++ b/fs/squashfs/sqfs.c @@ -482,13 +482,20 @@ static int sqfs_search_dir(struct squashfs_dir_stream *dirs, char **token_list, /* Initialize squashfs_dir_stream members */ dirs->table += SQFS_DIR_HEADER_SIZE; - dirs->size = get_unaligned_le16(&dir->file_size) - SQFS_DIR_HEADER_SIZE; + if (le16_to_cpu(dirs->i_dir.inode_type) == SQFS_DIR_TYPE) + dirs->size = get_unaligned_le16(&dir->file_size); + else + dirs->size = get_unaligned_le32(&ldir->file_size); + dirs->size -= SQFS_DIR_HEADER_SIZE; dirs->entry_count = dirs->dir_header->count + 1; /* No path given -> root directory */ if (!strcmp(token_list[0], "/")) { dirs->table = &dirs->dir_table[offset]; - memcpy(&dirs->i_dir, dir, sizeof(*dir)); + if (le16_to_cpu(dirs->i_dir.inode_type) == SQFS_DIR_TYPE) + memcpy(&dirs->i_dir, dir, sizeof(*dir)); + else + memcpy(&dirs->i_ldir, ldir, sizeof(*ldir)); return 0; } @@ -608,7 +615,10 @@ static int sqfs_search_dir(struct squashfs_dir_stream *dirs, char **token_list, } dirs->table += SQFS_DIR_HEADER_SIZE; - dirs->size = get_unaligned_le16(&dir->file_size); + if (le16_to_cpu(dirs->i_dir.inode_type) == SQFS_DIR_TYPE) + dirs->size = get_unaligned_le16(&dir->file_size); + else + dirs->size = get_unaligned_le32(&ldir->file_size); dirs->entry_count = dirs->dir_header->count + 1; dirs->size -= SQFS_DIR_HEADER_SIZE; free(dirs->entry);