From patchwork Wed Dec 30 23:52:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1421468 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=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmx.de 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=iqZSk/kn; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 4D5p5Z14W5z9sRR for ; Thu, 31 Dec 2020 10:53:29 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9B9DD8257D; Thu, 31 Dec 2020 00:53:14 +0100 (CET) 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="iqZSk/kn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 21D80825AA; Thu, 31 Dec 2020 00:53:13 +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.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (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 1259582496 for ; Thu, 31 Dec 2020 00:53:10 +0100 (CET) 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=1609372384; bh=RlYlGpGxOvrcr4AV0x7GJJwaznHaxN0liqSJj8fFsaM=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=iqZSk/knN16BUAOHCKEQ/pvO38xOFVzrXbLX7rdQj/N+rboHpITTCilHDhSIaG8MN srDToZ0HKR8wArnU9QR+GNNFsrp7T3oJqoBfTlxOxeoSyK5PcEFYJELTqGM6/LF5ws 5ECXY0y2TZChA55V6InbdxHAfBRdpby8JrBFJ39k= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from LT02.fritz.box ([62.143.246.89]) by mail.gmx.com (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1N2V4J-1jsONT0cYR-013sTx; Thu, 31 Dec 2020 00:53:04 +0100 From: Heinrich Schuchardt To: Tom Rini Cc: Simon Glass , Christian Gmeiner , Jason Wessel , u-boot@lists.denx.de, Heinrich Schuchardt Subject: [PATCH 1/1] fs/fat: implement fsuuid command Date: Thu, 31 Dec 2020 00:52:58 +0100 Message-Id: <20201230235258.52621-1-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-Provags-ID: V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LJLpUeaqlJcSKYvUTWG 7S+AevaqmRmWst/zlQP5U/mIiF4am/LBSO9zGyYlAfE6djCstD0wDcybGcPqfIIgVh/GAm5yt 5REpR9iHeJd12BevsKFA== 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.102.3 at phobos.denx.de X-Virus-Status: Clean The FAT file system does not have a UUID but a 4 byte volume ID. Let the fsuuid command show it in XXXX-XXXX format. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- fs/fat/fat.c | 18 ++++++++++++++++++ fs/fs.c | 2 +- include/fat.h | 12 ++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) -- 2.29.2 diff --git a/fs/fat/fat.c b/fs/fat/fat.c index 47344bb57e..c7a700442e 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -1378,3 +1378,21 @@ void fat_closedir(struct fs_dir_stream *dirs) void fat_close(void) { } + +int fat_uuid(char *uuid_str) +{ + boot_sector bs; + volume_info volinfo; + int fatsize; + int ret; + u8 *id; + + ret = read_bootsectandvi(&bs, &volinfo, &fatsize); + if (ret) + return ret; + + id = volinfo.volume_id; + sprintf(uuid_str, "%02X%02X-%02X%02X", id[3], id[2], id[1], id[0]); + + return 0; +} diff --git a/fs/fs.c b/fs/fs.c index 7a4020607a..5e80648b5b 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -194,7 +194,7 @@ static struct fstype_info fstypes[] = { .unlink = fs_unlink_unsupported, .mkdir = fs_mkdir_unsupported, #endif - .uuid = fs_uuid_unsupported, + .uuid = fat_uuid, .opendir = fat_opendir, .readdir = fat_readdir, .closedir = fat_closedir, diff --git a/include/fat.h b/include/fat.h index 3c29a4484d..8f44009d1a 100644 --- a/include/fat.h +++ b/include/fat.h @@ -213,4 +213,16 @@ int fat_unlink(const char *filename); int fat_mkdir(const char *dirname); void fat_close(void); void *fat_next_cluster(fat_itr *itr, unsigned int *nbytes); + +/** + * fat_uuid() - get FAT volume ID + * + * The FAT volume ID returned in @uuid_str as hexadecimal number in XXXX-XXXX + * format. + * + * @uuid_str: caller allocated buffer of at least 10 bytes for the volume ID + * Return: 0 on success + */ +int fat_uuid(char *uuid_str); + #endif /* _FAT_H_ */