From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Warren Date: Mon, 03 Nov 2014 14:00:40 -0700 Subject: [U-Boot] [PATCH] fs: make it possible to read the filesystem UUID In-Reply-To: <1414768103-31231-1-git-send-email-christian.gmeiner@gmail.com> References: <1414768103-31231-1-git-send-email-christian.gmeiner@gmail.com> Message-ID: <5457ECF8.9090603@wwwdotorg.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 : > - print filesystem UUID > fsuuid : > - 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 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.