From c0029e4e25c10d627f4bff62cdb4074bb2c7eaf7 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 31 Dec 2020 00:38:13 +0100 Subject: fs/fat: implement fsuuid command 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 --- fs/fat/fat.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'fs/fat/fat.c') diff --git a/fs/fat/fat.c b/fs/fat/fat.c index c9742d534bb..157dad60a48 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -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; +} -- cgit v1.2.3