]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
fs/fat: implement fsuuid command
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Wed, 30 Dec 2020 23:38:13 +0000 (00:38 +0100)
committerHeinrich Schuchardt <xypron.glpk@gmx.de>
Thu, 31 Dec 2020 13:32:27 +0000 (14:32 +0100)
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 <xypron.glpk@gmx.de>
fs/fat/fat.c
fs/fs.c
include/fat.h

index c9742d534bbc4deb944b219040e6eab79e9cedaa..157dad60a48910910ab3b29a53bfa04169f274cd 100644 (file)
@@ -1377,3 +1377,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 7a4020607a3950e76ca46f53dbc4aa6296f2b55d..5e80648b5b56ce9b4f3f144f5959cb59e4296ec7 100644 (file)
--- 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,
index 8cae283030f8b33e01ca00c1a2c118e0616b80a8..b9f273f381f10b6cb5f680c3d771842a268cdfad 100644 (file)
@@ -212,4 +212,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_ */