[U-Boot] [PATCH] fs: make it possible to read the filesystem UUID

Stephen Warren swarren at wwwdotorg.org
Mon Nov 3 22:00:40 CET 2014


On 10/31/2014 09:08 AM, Christian Gmeiner wrote:
> Some filesystems have a UUID stored in its superblock. To
> allow using root=UUID=... for the kernel command line we
> need a way to read-out the filesystem UUID.
>
> Hit any key to stop autoboot:  0
> => fsuuid
> fsuuid - Look up a filesystem UUID
>
> Usage:
> fsuuid <interface> <dev>:<part>
>      - print filesystem UUID
> fsuuid <interface> <dev>:<part> <varname>
>      - set environment variable to filesystem UUID
>
> => fsuuid mmc 0:1
> d9f9fc05-45ae-4a36-a616-fccce0e4f887
> => fsuuid mmc 0:2
> eb3db83c-7b28-499f-95ce-9e0bb21cda81
> => fsuuid mmc 0:1 uuid1
> => fsuuid mmc 0:2 uuid2
> => printenv uuid1
> uuid1=d9f9fc05-45ae-4a36-a616-fccce0e4f887
> => printenv uuid2
> uuid2=eb3db83c-7b28-499f-95ce-9e0bb21cda81
> =>

Acked-by: Stephen Warren <swarren at nvidia.com>

It'd be nice if you could implement fat_uuid() too, and plumb that in. 
That could be a separate commit though I suppose.

IIRC, the kernel accepts the format NNNNNNNN-MM where NNNNNNNN is the 
32-bit FAT disk ID (I don't recall the exact correct term) in 0-filled 
hex and MM is the partition number in 0-filled decimal.

> diff --git a/fs/fs.c b/fs/fs.c

> +int fs_uuid(char *uuid_str)
> +{
> +	struct fstype_info *info = fs_get_info(fs_type);
> +	int ret = -ENOSYS;
> +
> +	if (info->uuid)
> +		ret = info->uuid(uuid_str);
> +
> +	return ret;
> +}

Actually, that might be better as:

return info->uuid(uuid_str);

To make that work, you'd need to implement a fs_uuid_unsuported() 
function and fill it in for all the fs types in fstypes[]. That would be 
more consistent with the way other optional functionality works in this 
file.


More information about the U-Boot mailing list