From patchwork Sat Jun 12 05:48:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1491241 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=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=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=KuVeXb5d; dkim-atps=neutral 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4G26GB5yBzz9sj5 for ; Sat, 12 Jun 2021 15:48:50 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C6BF281107; Sat, 12 Jun 2021 07:48:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de 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; secure) header.d=gmx.net header.i=@gmx.net header.b="KuVeXb5d"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4631580C85; Sat, 12 Jun 2021 07:48:23 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8D6C480808 for ; Sat, 12 Jun 2021 07:48:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1623476893; bh=0j5dENfG4RbgaAh7tUVJN5Po13+trCClTCKHYgdbI4g=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=KuVeXb5dmCWH5gtMhBLhHcdH3MoYsDqkbCNYl+2x92yTAuEYD4n497VwoKn1s8Vtx i4exBOFJayg2OfoQ/z+B+aGtyTqh0QW9YBtXkZugIpxRh0K4qyKlo5l/ntrP2SXLM7 psMImeQbLife6ViWLds+G5Ztab9CCzWRaOW7b+/s= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from LT02.fritz.box ([62.143.247.63]) by mail.gmx.net (mrgmx004 [212.227.17.184]) with ESMTPSA (Nemesis) id 1N3se2-1lA33t0hg8-00zml2; Sat, 12 Jun 2021 07:48:13 +0200 From: Heinrich Schuchardt To: Alexander Graf Cc: Simon Glass , Jason Wessel , Christian Gmeiner , Masami Hiramatsu , =?utf-8?q?Vincent_Stehl?= =?utf-8?q?=C3=A9?= , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH 1/2] fs: fat: add file attributes to struct fs_dirent Date: Sat, 12 Jun 2021 07:48:05 +0200 Message-Id: <20210612054806.17784-2-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210612054806.17784-1-xypron.glpk@gmx.de> References: <20210612054806.17784-1-xypron.glpk@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:JpSA/BRDTl1UOaVds1OJr9A7BKmPX5e56E8aPUmkVP0Mw8WYmph e2EigXh+m3adw3OTByKxf5QhMoNeuUaiovNvOdW27Tybyl5rU+wT5p6K3ZM+lt5ogXdB/tJ eYdY9Xdhhz6F9qZHGeamPLA7OvJer/81okDmaq1dNZgRw73g02n6GA9AgxEx7qaVEEy+NJD c6xoBMwGGEJ38hk6dVEkA== X-UI-Out-Filterresults: notjunk:1;V03:K0:v/C1c550EsU=:67e9Yx0mxaz2SNiSfSe6AW qMYodvghS8PDtv6oErGVkyP+7fyp7ppVfBuF7kly+TdgZG3DitWbgelN1FOSrmX4TV8kI/2Uh Tvo1E6COc2ujWB1lOwO1eoSRmhBTf1Onxkrtr/FzGNHEnXyK1cOaWGm+yz7ndFe+eeviH8ydV GQyNGzkL7izJk68hOdOHiZvf5UL1Ctv/hd38ENP8usLa5VBQaCstPIfUOqJ1IQ+I5IECMBcJM GKNs9Godx9ir/SCu+IXXRfD78gHo4g3rLxFSxLq99V494IUyHA7PqgnoPJ1an4GYeOwXjvWLQ q1Lj94P7mrXnf+68RsS954AtE6eN9g0JES4MQ6W3C5zdd/uoIU3z0qFIQ2WrecplHNl3ks1/p /zBUOpBcb6D0KUxsdpJte3PWBOqHQpXgPSR1LglsIuPDmFJQ0kH8hbYbGbqwipa58NhAzH7t8 ePONChgjZTLAq+zBrvpKQ9sqUFY4PohR7hYF7vVoBFLdpGPNUQuAQPr3CigbLwVpILozGTOe1 wsSdKAmF/IYzgI2m/DLWlyZXnHiYk0m/RwkqnY82ebAef3uU01S5dgTgF4JbMgewGBKvFXcN2 BvKg/bvlR8ZKdWRYfd7JS+hKYr1GR63G34l+MtFIGU0x1fLcn5+WdjtdmE/1WDqUpS9zImu6t ClXVnYk8ZKLiARMMrHXzKwQbYGt/7ddA1nJe8/1tOw7KD2+SwWAc05ZSucNyLCj28LBF4JjQ7 8ogCQUEFY9RmIPEONSnpc/Ks+3+RQyfoL4RKpY1J+1bkXMO+u9qV7udQBIkvRdZn3/O4Da4OM 6UM6EVuPuCb9mMesUi8cSgTW4Eea1Q87fJTHyOUHxNEBn1PN3UNvSIsJwg7dhbjgsPOULyNm4 m3++wGIb4Y+BYk4ZaXogQBqIuySYymwvJRxQPefESov/x1hoP3mwXfGdQuqSHJQ/AQz44sY47 M7sDbdBczT/szqVmXaGDwm/Yonn+GPheb+mpvXchS3tv7f7R2vwazowyauMTn6udz6jThRpa3 n/xKjsT3+hbRa4SousJSH74sMzfagxdZIb7NBNmq2MVCJyVUJYyRzczlsWJ1tm2oqyMk61uu6 RHAqosajykWmMFUHJWmrd/FGupoK6BClFC3 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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 When reading a directory in the UEFI file system we have to return file attributes and timestamps. Copy this data to the directory entry structure. Signed-off-by: Heinrich Schuchardt --- fs/fat/fat.c | 32 +++++++++++++++++++++++++++++++- include/fs.h | 22 ++++++++++++++++++---- 2 files changed, 49 insertions(+), 5 deletions(-) -- 2.30.2 diff --git a/fs/fat/fat.c b/fs/fat/fat.c index c561d82b35..7021138b98 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -1187,6 +1187,28 @@ out: return ret == 0; } +/** + * fat2rtc() - convert FAT time stamp to RTC file stamp + * + * @date: FAT date + * @time: FAT time + * @tm: RTC time stamp + */ +static void __maybe_unused fat2rtc(u16 date, u16 time, struct rtc_time *tm) +{ + tm->tm_mday = date & 0x1f; + tm->tm_mon = (date & 0x1e0) >> 4; + tm->tm_year = (date >> 9) + 1980; + + tm->tm_sec = (time & 0x1f) << 1; + tm->tm_min = (time & 0x7e0) >> 5; + tm->tm_hour = time >> 11; + + rtc_calc_weekday(tm); + tm->tm_yday = 0; + tm->tm_isdst = 0; +} + int fat_size(const char *filename, loff_t *size) { fsdata fsdata; @@ -1325,7 +1347,15 @@ int fat_readdir(struct fs_dir_stream *dirs, struct fs_dirent **dentp) memset(dent, 0, sizeof(*dent)); strcpy(dent->name, dir->itr.name); - + if (CONFIG_IS_ENABLED(EFI_LOADER)) { + dent->attr = dir->itr.dent->attr; + fat2rtc(le16_to_cpu(dir->itr.dent->cdate), + le16_to_cpu(dir->itr.dent->ctime), &dent->create_time); + fat2rtc(le16_to_cpu(dir->itr.dent->date), + le16_to_cpu(dir->itr.dent->time), &dent->change_time); + fat2rtc(le16_to_cpu(dir->itr.dent->adate), + 0, &dent->access_time); + } if (fat_itr_isdir(&dir->itr)) { dent->type = FS_DT_DIR; } else { diff --git a/include/fs.h b/include/fs.h index 0794b50d10..1c79e299fd 100644 --- a/include/fs.h +++ b/include/fs.h @@ -6,6 +6,7 @@ #define _FS_H #include +#include struct cmd_tbl; @@ -160,13 +161,26 @@ int fs_write(const char *filename, ulong addr, loff_t offset, loff_t len, #define FS_DT_REG 8 /* regular file */ #define FS_DT_LNK 10 /* symbolic link */ -/* - * A directory entry, returned by fs_readdir(). Returns information +/** + * struct fs_dirent - directory entry + * + * A directory entry, returned by fs_readdir(). Returns information * about the file/directory at the current directory entry position. */ struct fs_dirent { - unsigned type; /* one of FS_DT_x (not a mask) */ - loff_t size; /* size in bytes */ + /** @type: one of FS_DT_x (not a mask) */ + unsigned int type; + /** @size: file size */ + loff_t size; + /** @flags: attribute flags (FS_ATTR_*) */ + u32 attr; + /** create_time: time of creation */ + struct rtc_time create_time; + /** access_time: time of last access */ + struct rtc_time access_time; + /** change_time: time of last modification */ + struct rtc_time change_time; + /** name: file name */ char name[256]; };