From patchwork Mon Sep 25 19:06:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tuomas Tynkkynen X-Patchwork-Id: 818337 X-Patchwork-Delegate: trini@ti.com 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; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Xpgy7G10"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3y1D8z17f7z9s7g for ; Tue, 26 Sep 2017 05:06:58 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id B62AFC21C4C; Mon, 25 Sep 2017 19:06:51 +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_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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 C1BCAC21C4C; Mon, 25 Sep 2017 19:06:48 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id AE33BC21C45; Mon, 25 Sep 2017 19:06:47 +0000 (UTC) Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by lists.denx.de (Postfix) with ESMTPS id 4C6DCC21C26 for ; Mon, 25 Sep 2017 19:06:47 +0000 (UTC) Received: by mail-wr0-f195.google.com with SMTP id k20so366297wre.1 for ; Mon, 25 Sep 2017 12:06:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=4bQZ69wl2PLyez/10/ENzSunfD/4EcRBXYIFUhr99LA=; b=Xpgy7G10zR5WTuypBx6O8z3pHBF1H1Y3c8Z22W8+WmZh2VRcbVTXd7YD7jV/ctOuHi qQwe3lcRtzJu8M4D/llmLOlh7R2GlhMS2qvPcPak5IiTSwSFwDqc/vaHo3YmwojtBjK0 1PGQZ8EzTwoTCu5hSrYpmYzNN2Gg9BvcH22FK6H+ajfuv1TOux92x6ytdNzKVCedFH+b cqgIMuPMmXDvujh71EOXqgR8jWc5V41Vut0/hEfWCAxmZx3HjfRC190jXD4uy1EJ4/co fhcP5oFHt3VZp2bx15SRAs/qZEaNQWfdZyBMX4bhoYWtMYBvs92MGwB/zkj+iNqkmkhF Wa5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=4bQZ69wl2PLyez/10/ENzSunfD/4EcRBXYIFUhr99LA=; b=IgnbgTJ7Zjcgfjl6G3Utvij4smt2kLIEVaIMtgSOlTVuQ+D5KIrIy0SdmejFIqiD4S 1Qzx2pVjp5O0jupe+CaFGAwxQWDGW+IOzdvhf6rHose8zMuPOLUkiCncwf/0tuUr+eXj gvToG2KvlqC6eXmg+ugleXuUMjkM+h9CSkRNj9oHJMBOERM0jwZS/djlUhf4ATcwgSTn uC6naHKYuLItOUvrJ4RohviYRw0b70pr+cyH280ptWNQTx+RAQRtI2cgOz807RcHTDqh ci1d8RDggk3l2REkCCZ4GYhnM9/jmVMHlvyhltVTCaAgMFaUjkRr4La4aVJE8YoSz1QQ F+rg== X-Gm-Message-State: AHPjjUivQZ+jIOohYcwCjvYZVPW0l2rbAE5wRAB4d8lnVuqY9U+i8RYs AwS8oQgjvPmIpo5e+QtrHujt2xx8 X-Google-Smtp-Source: AOwi7QDB0ycxOYK76wwAF8WJU2fsMcufGpoxgYchiQQHrsgEjHYX7DW9RAmiK7+/DToWEUnczJV48Q== X-Received: by 10.46.25.81 with SMTP id p78mr3342763lje.65.1506366406660; Mon, 25 Sep 2017 12:06:46 -0700 (PDT) Received: from duuni.srv.tuxera.com ([194.100.106.190]) by smtp.gmail.com with ESMTPSA id 15sm1564203ljf.22.2017.09.25.12.06.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Sep 2017 12:06:45 -0700 (PDT) From: Tuomas Tynkkynen To: u-boot@lists.denx.de Date: Mon, 25 Sep 2017 22:06:31 +0300 Message-Id: <20170925190634.21738-1-tuomas.tynkkynen@iki.fi> X-Mailer: git-send-email 2.13.0 Cc: Tom Rini Subject: [U-Boot] [PATCH v2 1/4] fs/ext4: Fix group descriptor checksum calculation 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" The current code doesn't compute the group descriptor checksum correctly for the filesystems that e2fsprogs 1.43.4 creates (they have 'Group descriptor size: 64' as reported by tune2fs). Extend the checksum calculation to be done as ext4_group_desc_csum() does in Linux. This fixes these errors in dmesg from running fs-test.sh and makes it succeed again: [1671902.620699] EXT4-fs (loop1): ext4_check_descriptors: Checksum for group 0 failed (35782!=10965) [1671902.620706] EXT4-fs (loop1): group descriptors corrupted! Signed-off-by: Tuomas Tynkkynen --- v2: New patch --- fs/ext4/ext4_common.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c index 621c61e5c7..31952f48b9 100644 --- a/fs/ext4/ext4_common.c +++ b/fs/ext4/ext4_common.c @@ -432,6 +432,10 @@ uint16_t ext4fs_checksum_update(uint32_t i) crc = ext2fs_crc16(crc, desc, offset); offset += sizeof(desc->bg_checksum); /* skip checksum */ assert(offset == sizeof(*desc)); + if (offset < fs->gdsize) { + crc = ext2fs_crc16(crc, (__u8 *)desc + offset, + fs->gdsize - offset); + } } return crc; From patchwork Mon Sep 25 19:06:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tuomas Tynkkynen X-Patchwork-Id: 818339 X-Patchwork-Delegate: trini@ti.com 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; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Y2Rz9+To"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3y1D9t6Q6dz9s7g for ; Tue, 26 Sep 2017 05:07:36 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id E8E59C21DA1; Mon, 25 Sep 2017 19:07:10 +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_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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 165F1C21E39; Mon, 25 Sep 2017 19:06:51 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E6678C21C26; Mon, 25 Sep 2017 19:06:48 +0000 (UTC) Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by lists.denx.de (Postfix) with ESMTPS id 811D5C21C26 for ; Mon, 25 Sep 2017 19:06:48 +0000 (UTC) Received: by mail-wr0-f196.google.com with SMTP id g50so366425wra.3 for ; Mon, 25 Sep 2017 12:06:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=VX6KAVsnvf7LYuHcE5N33m4vob7zCLbmyGe0hv6Hg7M=; b=Y2Rz9+TomzUpOta8SymfKasO8neoQwHonwDc1gwKj0/hp1Hqznd2FZQ8OjTInodHH7 xIoy+6x+qeKj2BYGNRiBeXAHmncMPN3/PShtBVsGDPEueKcDZKTgRdCKPbsZH8wvqw7w IxCcamioYjKnz3lsw9drO+7gQcIA8dotza7ogP9O5WlF4WzzODMs0e2iGvStPG1EaT9k LLHbBfYgzr3Clgo+BycCuSXoO0YX+i4iAODPRXPyTmEUvHa61Fc258anE5fItlBfDLLg N4v9gCJ2JY+PFpZEZJ/BWy3qMwejDEZfeIWnK0BTjzFwYnKUfU48eU+iTfhc22mm6iE2 L4zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=VX6KAVsnvf7LYuHcE5N33m4vob7zCLbmyGe0hv6Hg7M=; b=OkMM7ap7keBw7fOka61EMv1uE5vcVGZwuxhyjNABa3HZREDl4nJn/tLfBTQ3u9mA/N oysadcFYU6rbw1ezKGfKdxwp3fEE0+g5VwW6RqclVew10fJhyjVobxK3GjBwTUNonYG8 DlQm1HlzbTV35vMss1TykfT0uchtIK22LZGdJpSiSzmMYriewC0skzvKaCAjvfZ3H84V T98qHnrO3j9jecSrtsW2B3Yh4ruk2tEdF6ImKh2isDpkqpqB+RAQbMImUVcnm+5ZmRYy UU11KPRAu6xSwvvIk3wDP73Ooh39+J8WJJDc7yBWvKl+3FdnBYrLg3At4kYcoKDMUa9w tLfA== X-Gm-Message-State: AHPjjUjbcUlCIMAp83xog0b7Hlm63CHmr6H69c0UQH+e2b+bnH0U8Drx 68R6f7PYgHtPgDfZOmCPtljDk+/d X-Google-Smtp-Source: AOwi7QDfxb4HvTHzpgeyHV4saLuTvIrPDu5zI9xY05IfAbSXTl4H5QRaTOX86aiFj5dlfnuwUyO5CQ== X-Received: by 10.46.75.18 with SMTP id y18mr3224815lja.113.1506366407887; Mon, 25 Sep 2017 12:06:47 -0700 (PDT) Received: from duuni.srv.tuxera.com ([194.100.106.190]) by smtp.gmail.com with ESMTPSA id 15sm1564203ljf.22.2017.09.25.12.06.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Sep 2017 12:06:47 -0700 (PDT) From: Tuomas Tynkkynen To: u-boot@lists.denx.de Date: Mon, 25 Sep 2017 22:06:32 +0300 Message-Id: <20170925190634.21738-2-tuomas.tynkkynen@iki.fi> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170925190634.21738-1-tuomas.tynkkynen@iki.fi> References: <20170925190634.21738-1-tuomas.tynkkynen@iki.fi> Cc: Tom Rini Subject: [U-Boot] [PATCH v2 2/4] fs-test: Add FAT16 support 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" Currently we can only test FAT32 which is the default FAT version that mkfs.vfat creates by default. Instead make it explicitly create either a FAT16 or a FAT32 volume. This allows us to exercise more code, for instance the root directory handling is done differently in FAT32 than the older FATs. Adding FAT12 support is a much bigger job since the test creates a 2.5GB file and the FAT12 maximum partition size is way smaller than that. Signed-off-by: Tuomas Tynkkynen Reviewed-by: Tom Rini --- v2: Update result summary in the header --- test/fs/fs-test.sh | 55 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/test/fs/fs-test.sh b/test/fs/fs-test.sh index b19486419e..0ac34983a1 100755 --- a/test/fs/fs-test.sh +++ b/test/fs/fs-test.sh @@ -12,11 +12,15 @@ # fs-test.sb.ext4.out: Summary: PASS: 23 FAIL: 0 # fs-test.ext4.out: Summary: PASS: 23 FAIL: 0 # fs-test.fs.ext4.out: Summary: PASS: 23 FAIL: 0 -# FAT tests: -# fs-test.sb.fat.out: Summary: PASS: 23 FAIL: 0 -# fs-test.fat.out: Summary: PASS: 20 FAIL: 3 -# fs-test.fs.fat.out: Summary: PASS: 20 FAIL: 3 -# Total Summary: TOTAL PASS: 132 TOTAL FAIL: 6 +# FAT16 tests: +# fs-test.sb.fat16.out: Summary: PASS: 23 FAIL: 0 +# fs-test.fat16.out: Summary: PASS: 20 FAIL: 3 +# fs-test.fs.fat16.out: Summary: PASS: 20 FAIL: 3 +# FAT32 tests: +# fs-test.sb.fat32.out: Summary: PASS: 23 FAIL: 0 +# fs-test.fat32.out: Summary: PASS: 20 FAIL: 3 +# fs-test.fs.fat32.out: Summary: PASS: 20 FAIL: 3 +# Total Summary: TOTAL PASS: 195 TOTAL FAIL: 12 # pre-requisite binaries list. PREREQ_BINS="md5sum mkfs mount umount dd fallocate mkdir" @@ -41,7 +45,7 @@ SMALL_FILE="1MB.file" BIG_FILE="2.5GB.file" # $MD5_FILE will have the expected md5s when we do the test -# They shall have a suffix which represents their file system (ext4/fat) +# They shall have a suffix which represents their file system (ext4/fat16/...) MD5_FILE="${OUT_DIR}/md5s.list" # $OUT shall be the prefix of the test output. Their suffix will be .out @@ -104,15 +108,25 @@ function prepare_env() { } # 1st parameter is the name of the image file to be created -# 2nd parameter is the filesystem - fat ext4 etc +# 2nd parameter is the filesystem - fat16 ext4 etc # -F cant be used with fat as it means something else. function create_image() { # Create image if not already present - saves time, while debugging - if [ "$2" = "ext4" ]; then + case "$2" in + fat16) + MKFS_OPTION="-F 16" + FS_TYPE="fat" + ;; + fat32) + MKFS_OPTION="-F 32" + FS_TYPE="fat" + ;; + ext4) MKFS_OPTION="-F" - else - MKFS_OPTION="" - fi + FS_TYPE="ext4" + ;; + esac + if [ ! -f "$1" ]; then fallocate -l 3G "$1" &> /dev/null if [ $? -ne 0 ]; then @@ -123,8 +137,8 @@ function create_image() { exit $? fi fi - mkfs -t "$2" $MKFS_OPTION "$1" &> /dev/null - if [ $? -ne 0 -a "$2" = "fat" ]; then + mkfs -t "$FS_TYPE" $MKFS_OPTION "$1" &> /dev/null + if [ $? -ne 0 -a "$FS_TYPE" = "fat" ]; then # If we fail and we did fat, try vfat. mkfs -t vfat $MKFS_OPTION "$1" &> /dev/null fi @@ -136,7 +150,7 @@ function create_image() { } # 1st parameter is image file -# 2nd parameter is file system type - fat/ext4 +# 2nd parameter is file system type - fat16/ext4/... # 3rd parameter is name of small file # 4th parameter is name of big file # 5th parameter is fs/nonfs/sb - to dictate generic fs commands or @@ -149,7 +163,7 @@ function test_image() { length="0x00100000" case "$2" in - fat) + fat*) FPATH="" PREFIX="fat" WRITE="write" @@ -550,7 +564,7 @@ TOTAL_PASS=0 # In each loop, for a given file system image, we test both the # fs command, like load/size/write, the file system specific command # like: ext4load/ext4size/ext4write and the sb load/ls/save commands. -for fs in ext4 fat; do +for fs in ext4 fat16 fat32; do echo "Creating $fs image if not already present." IMAGE=${IMG}.${fs}.img @@ -563,11 +577,14 @@ for fs in ext4 fat; do # Lets mount the image and test sb hostfs commands mkdir -p "$MOUNT_DIR" - if [ "$fs" = "fat" ]; then + case "$fs" in + fat*) uid="uid=`id -u`" - else + ;; + *) uid="" - fi + ;; + esac sudo mount -o loop,rw,$uid "$IMAGE" "$MOUNT_DIR" sudo chmod 777 "$MOUNT_DIR" From patchwork Mon Sep 25 19:06:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tuomas Tynkkynen X-Patchwork-Id: 818338 X-Patchwork-Delegate: trini@ti.com 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; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="uY1TmGg7"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3y1DBK6J1Hz9sBZ for ; Tue, 26 Sep 2017 05:08:09 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id EB5D9C21F36; Mon, 25 Sep 2017 19:07:26 +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_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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 1DF62C21D5B; Mon, 25 Sep 2017 19:06:56 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0C2AFC21EA9; Mon, 25 Sep 2017 19:06:52 +0000 (UTC) Received: from mail-wr0-f193.google.com (mail-wr0-f193.google.com [209.85.128.193]) by lists.denx.de (Postfix) with ESMTPS id A8245C21DA1 for ; Mon, 25 Sep 2017 19:06:49 +0000 (UTC) Received: by mail-wr0-f193.google.com with SMTP id p37so365728wrb.5 for ; Mon, 25 Sep 2017 12:06:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=3YtZZjrthh4s33OAJmZ0AkEgC7bQZKxvEMzqn4QVVWg=; b=uY1TmGg7gZgWR0IrY6nEFnGLyvTxJeREtTUvVms735sMdqleUlkA7ROL0LeXxFNspo bVBvqAFp1Fo70rUziVpwo19ZSfRe2DkJ1oaF6+JIgBABuWduYCBwewWukZii7Ed0gnSm w4MaAxXtvFT/JKm8xBjEn1Wr2NVQb0q7b4Ga7Gl1bJikhk0yuOqMtSzc6KsjzsbfS5EF ROHtvi6oSGBQJvYWtOzx78UEoJxeODHEUKobSr6H/4dS27WnrfLZHd368MMuuD13ix53 VTl2hAvq63ftPFGv1YB7InpYnbzC41jJRH3soAr22Z9zkJXXMlu+DI0wPoe9/JVL6ytT 2tkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=3YtZZjrthh4s33OAJmZ0AkEgC7bQZKxvEMzqn4QVVWg=; b=eabXfle3K4TQd/SKh7QRKZQFJJ5leA1XJzZolvbndeb5mTSqLuISkvPOcEVeZLiZMV hr+R1B2lxo9U3ihhapSERW0SDQRQbZtCLEmknOlKOju7qyxfB+O6IsbQA+Vr9rEnupeG m2IsMyH2t4tC4hvhXVDha/hGU9MLb7OcrQutJtnaXT2FBX5ozWe32nF1GK4iZRP5qWS9 jnW62bjjuoEXJuPFAMBt4zbfnWMEB7Wj1tQU4rqlaMbA1h7CKQsOZL+crf7NWc3LDNNj cyM+zWJimj3ReaBMkXqCQ0bA8ODw8HtiMfynZLentwvyCyBNa51ps9jstyRLozETSjLu KIfg== X-Gm-Message-State: AHPjjUiQoZkC6P79RHweH3VQw4fQA2iLyb5rxj3ca6b0DDZ4OIBfKqMS YMmv4qnt8BwkBC4Z1+26nFEyDluj X-Google-Smtp-Source: AOwi7QAh7n4vuf5fyhYW4FHbh3tlU9bd1yxF+EQxHBkYR+i0mf44B/jfk+m0OGFmsR0gWM3V7GIAIQ== X-Received: by 10.25.42.144 with SMTP id q16mr2561894lfq.134.1506366409007; Mon, 25 Sep 2017 12:06:49 -0700 (PDT) Received: from duuni.srv.tuxera.com ([194.100.106.190]) by smtp.gmail.com with ESMTPSA id 15sm1564203ljf.22.2017.09.25.12.06.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Sep 2017 12:06:48 -0700 (PDT) From: Tuomas Tynkkynen To: u-boot@lists.denx.de Date: Mon, 25 Sep 2017 22:06:33 +0300 Message-Id: <20170925190634.21738-3-tuomas.tynkkynen@iki.fi> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170925190634.21738-1-tuomas.tynkkynen@iki.fi> References: <20170925190634.21738-1-tuomas.tynkkynen@iki.fi> Cc: Tom Rini Subject: [U-Boot] [PATCH v2 3/4] fs/fat: Fix pathnames using '..' that lead to the root directory 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" If we end up back in the root directory via a '..' directory entry, set itr->is_root accordingly. Failing to do that gives spews like "Invalid FAT entry" and being unable to access directory entries located past the first cluster of the root directory. Fixes: 8eafae209c35 ("fat/fs: convert to directory iterators") Reviewed-by: Tom Rini Signed-off-by: Tuomas Tynkkynen --- v2: Add Reviewed-by --- fs/fat/fat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/fat/fat.c b/fs/fat/fat.c index 36a309c73c..3d3e17e8fa 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -710,13 +710,14 @@ static void fat_itr_child(fat_itr *itr, fat_itr *parent) itr->fsdata = parent->fsdata; if (clustnum > 0) { itr->clust = clustnum; + itr->is_root = 0; } else { itr->clust = parent->fsdata->root_cluster; + itr->is_root = 1; } itr->dent = NULL; itr->remaining = 0; itr->last_cluster = 0; - itr->is_root = 0; } static void *next_cluster(fat_itr *itr) From patchwork Mon Sep 25 19:06:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tuomas Tynkkynen X-Patchwork-Id: 818340 X-Patchwork-Delegate: trini@ti.com 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; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="EN0nk0hy"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3y1DD61jrpz9t16 for ; Tue, 26 Sep 2017 05:08:29 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 0DA61C21F2D; Mon, 25 Sep 2017 19:07:41 +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_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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 D35FDC21F70; Mon, 25 Sep 2017 19:06:59 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 41E8DC21F36; Mon, 25 Sep 2017 19:06:54 +0000 (UTC) Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by lists.denx.de (Postfix) with ESMTPS id AD913C21D5B for ; Mon, 25 Sep 2017 19:06:50 +0000 (UTC) Received: by mail-wr0-f196.google.com with SMTP id p37so365772wrb.5 for ; Mon, 25 Sep 2017 12:06:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=1ONQszToG/6Ntbek0gXC9tFLZAMrJKPUEyg15QBRRbo=; b=EN0nk0hygRXRS5adFT/0s8LMtiUvzHFSz9DZkhAlHKwgQCzfZ3ZCBvOOkJCLb9Ensc wMSeqaRX0J+aHFA4gi4m7gFhvg2c/xgJ/4rFf/Bu/Np0Fna3LrsMZ6cuVrGvdzOP7db7 VXtfgQq3joiKR7CEACtt7xQW1DFtDTqbn44GjtP4Qy/NE35CIdQbwSG0V/md3vzfKV/0 lQafpdbHix79C8Dc/UWxgZ5G71sitn8JCXTScTGjzUP5U7Me3zOhgqaJgdXl3mp7/r8h bZA0LOYU0moxL29PXY4qr6akI3W2hEL2P8fHTdIFKRZZIpDsuMNjDR4vIxYpAIMaZvTJ gb/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=1ONQszToG/6Ntbek0gXC9tFLZAMrJKPUEyg15QBRRbo=; b=OwajMcnYIMG0pgj2E2Jl2OdU09Qux1KEzkNM8YIHsdxLlch9ywLW7/ZO0VSNyQ+jyL ZIyOaJ3xXUDBY3tXf3ZQfji5cKhyXWUdd+D03f//bYAuua3bXTqUa3FnOq2KyzuIIZrO Cr5ESmU1nDWM8RZptusdvAesFpHrGtyCWPCoZDLvGJJ37WbYT0bNizJtz6beWpTp8hLf YZu8PXwDp2PIiPlcdD4S07KyAu7aXjRblmhP1IM4tBIzEtc0/PHMne9p3cthPE/sMOSU 0DSykUb6rCRhgU+ZgRVPO6R26Jc1pllzWoe32hWT/v2DrP2cR1PMt4S6OP14oKwBaB4H arCQ== X-Gm-Message-State: AHPjjUimwwzj2t7imy6poqwzHAsCYSvC+mA7nOxSksTbLb/Nevq16a/g A+c2Q7JhUqcM8PCfujrVQKwyADvN X-Google-Smtp-Source: AOwi7QBOobexUC5QSLkhAeUrbF3fT4sHcjp0PRdsTs3tBYUWQnkHBKlXJqqA/DlKUN7mgKvX7/dbyQ== X-Received: by 10.25.83.144 with SMTP id h16mr2461517lfl.29.1506366410040; Mon, 25 Sep 2017 12:06:50 -0700 (PDT) Received: from duuni.srv.tuxera.com ([194.100.106.190]) by smtp.gmail.com with ESMTPSA id 15sm1564203ljf.22.2017.09.25.12.06.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Sep 2017 12:06:49 -0700 (PDT) From: Tuomas Tynkkynen To: u-boot@lists.denx.de Date: Mon, 25 Sep 2017 22:06:34 +0300 Message-Id: <20170925190634.21738-4-tuomas.tynkkynen@iki.fi> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170925190634.21738-1-tuomas.tynkkynen@iki.fi> References: <20170925190634.21738-1-tuomas.tynkkynen@iki.fi> Cc: Tom Rini Subject: [U-Boot] [PATCH v2 4/4] fs-test: Add test for a filename using '..' to go back to the root 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" The previous commit fixed a problem in FAT code where going back to the root directory using '..' wouldn't work correctly on FAT12 or FAT16. Add a test to exercise this case (which was once fixed in commit 18a10d46f26 "fat: handle paths that include ../" but reintroduced due to the directory iterator refactoring). This test only very barely catches the problem - without the fix the size command still gives valid output but the additional spurious "Invalid FAT entry" error message makes it not get caught in the 'egrep -A3 ' output. I tried to make a proper test that grows the root directory to two clusters lots of with dummy files but that causes the write tests to crash the sandbox totally... Signed-off-by: Tuomas Tynkkynen Reviewed-by: Tom Rini --- v2: - Increase context of the 'ls' test to also pass on ext4 (due to the added SUBDIR subdirectory) - Update the result summary in the header --- test/fs/fs-test.sh | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/test/fs/fs-test.sh b/test/fs/fs-test.sh index 0ac34983a1..20d5dd8a47 100755 --- a/test/fs/fs-test.sh +++ b/test/fs/fs-test.sh @@ -9,18 +9,18 @@ # It currently tests the fs/sb and native commands for ext4 and fat partitions # Expected results are as follows: # EXT4 tests: -# fs-test.sb.ext4.out: Summary: PASS: 23 FAIL: 0 -# fs-test.ext4.out: Summary: PASS: 23 FAIL: 0 -# fs-test.fs.ext4.out: Summary: PASS: 23 FAIL: 0 +# fs-test.sb.ext4.out: Summary: PASS: 24 FAIL: 0 +# fs-test.ext4.out: Summary: PASS: 24 FAIL: 0 +# fs-test.fs.ext4.out: Summary: PASS: 24 FAIL: 0 # FAT16 tests: -# fs-test.sb.fat16.out: Summary: PASS: 23 FAIL: 0 -# fs-test.fat16.out: Summary: PASS: 20 FAIL: 3 -# fs-test.fs.fat16.out: Summary: PASS: 20 FAIL: 3 +# fs-test.sb.fat16.out: Summary: PASS: 24 FAIL: 0 +# fs-test.fat16.out: Summary: PASS: 21 FAIL: 3 +# fs-test.fs.fat16.out: Summary: PASS: 21 FAIL: 3 # FAT32 tests: -# fs-test.sb.fat32.out: Summary: PASS: 23 FAIL: 0 -# fs-test.fat32.out: Summary: PASS: 20 FAIL: 3 -# fs-test.fs.fat32.out: Summary: PASS: 20 FAIL: 3 -# Total Summary: TOTAL PASS: 195 TOTAL FAIL: 12 +# fs-test.sb.fat32.out: Summary: PASS: 24 FAIL: 0 +# fs-test.fat32.out: Summary: PASS: 21 FAIL: 3 +# fs-test.fs.fat32.out: Summary: PASS: 21 FAIL: 3 +# Total Summary: TOTAL PASS: 204 TOTAL FAIL: 12 # pre-requisite binaries list. PREREQ_BINS="md5sum mkfs mount umount dd fallocate mkdir" @@ -229,10 +229,14 @@ ${PREFIX}ls host${SUFFIX} $6 # We want ${PREFIX}size host 0:0 $3 for host commands and # sb size hostfs - $3 for hostfs commands. # 1MB is 0x0010 0000 -# Test Case 2 - size of small file +# Test Case 2a - size of small file ${PREFIX}size host${SUFFIX} ${FPATH}$FILE_SMALL printenv filesize setenv filesize +# Test Case 2b - size of small file via a path using '..' +${PREFIX}size host${SUFFIX} ${FPATH}SUBDIR/../$FILE_SMALL +printenv filesize +setenv filesize # 2.5GB (1024*1024*2500) is 0x9C40 0000 # Test Case 3 - size of big file @@ -347,6 +351,9 @@ function create_files() { mkdir -p "$MOUNT_DIR" sudo mount -o loop,rw "$1" "$MOUNT_DIR" + # Create a subdirectory. + sudo mkdir -p "$MOUNT_DIR/SUBDIR" + # Create big file in this image. # Note that we work only on the start 1MB, couple MBs in the 2GB range # and the last 1 MB of the huge 2.5GB file. @@ -453,16 +460,19 @@ function check_results() { FAIL=0 # Check if the ls is showing correct results for 2.5 gb file - grep -A6 "Test Case 1 " "$1" | egrep -iq "2621440000 *$4" + grep -A7 "Test Case 1 " "$1" | egrep -iq "2621440000 *$4" pass_fail "TC1: ls of $4" # Check if the ls is showing correct results for 1 mb file - grep -A6 "Test Case 1 " "$1" | egrep -iq "1048576 *$3" + grep -A7 "Test Case 1 " "$1" | egrep -iq "1048576 *$3" pass_fail "TC1: ls of $3" # Check size command on 1MB.file - egrep -A3 "Test Case 2 " "$1" | grep -q "filesize=100000" + egrep -A3 "Test Case 2a " "$1" | grep -q "filesize=100000" pass_fail "TC2: size of $3" + # Check size command on 1MB.file via a path using '..' + egrep -A3 "Test Case 2b " "$1" | grep -q "filesize=100000" + pass_fail "TC2: size of $3 via a path using '..'" # Check size command on 2.5GB.file egrep -A3 "Test Case 3 " "$1" | grep -q "filesize=9c400000"