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

Christian Gmeiner christian.gmeiner at gmail.com
Tue Nov 11 13:20:18 CET 2014


Hi

2014-11-04 7:31 GMT+01:00 Simon Glass <sjg at chromium.org>:
> Hi Christian,
>
> On 31 October 2014 09:08, Christian Gmeiner <christian.gmeiner at gmail.com> 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
>> =>
>>
>> Signed-off-by: Christian Gmeiner <christian.gmeiner at gmail.com>
>> ---
>>  README           |  1 +
>>  common/Makefile  |  1 +
>>  fs/ext4/ext4fs.c | 15 +++++++++++++++
>>  fs/fs.c          | 39 +++++++++++++++++++++++++++++++++++++++
>>  include/ext4fs.h |  1 +
>>  include/fs.h     |  2 ++
>>  6 files changed, 59 insertions(+)
>>
>> diff --git a/README b/README
>> index 7b5538e..53b84a6 100644
>> --- a/README
>> +++ b/README
>> @@ -989,6 +989,7 @@ The following options need to be configured:
>>                 CONFIG_CMD_EXT4         * ext4 command support
>>                 CONFIG_CMD_FS_GENERIC   * filesystem commands (e.g. load, ls)
>>                                           that work for multiple fs types
>> +               CONFIG_CMD_FS_UUID      * Look up a filesystem UUID
>>                 CONFIG_CMD_SAVEENV        saveenv
>>                 CONFIG_CMD_FDC          * Floppy Disk Support
>>                 CONFIG_CMD_FAT          * FAT command support
>> diff --git a/common/Makefile b/common/Makefile
>> index 6cc4de8..508a0b2 100644
>> --- a/common/Makefile
>> +++ b/common/Makefile
>> @@ -188,6 +188,7 @@ obj-y += usb.o usb_hub.o
>>  obj-$(CONFIG_USB_STORAGE) += usb_storage.o
>>  endif
>>  obj-$(CONFIG_CMD_FASTBOOT) += cmd_fastboot.o
>> +obj-$(CONFIG_CMD_FS_UUID) += cmd_fs_uuid.o
>>
>>  obj-$(CONFIG_CMD_USB_MASS_STORAGE) += cmd_usb_mass_storage.o
>>  obj-$(CONFIG_CMD_THOR_DOWNLOAD) += cmd_thordown.o
>> diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c
>> index cbdc220..61b6dc2 100644
>> --- a/fs/ext4/ext4fs.c
>> +++ b/fs/ext4/ext4fs.c
>> @@ -187,6 +187,21 @@ int ext4fs_size(const char *filename)
>>         return ext4fs_open(filename);
>>  }
>>
>> +int ext4fs_uuid(char *uuid_str)
>> +{
>> +       if (ext4fs_root == NULL)
>> +               return -1;
>
> One other tiny note - should that be -ENOENT or some other error perhaps?
>

I used the other functions as inspiration. I think that needs to be in
a follow up commit
as it affects more functions.

greets
--
Christian Gmeiner, MSc

https://soundcloud.com/christian-gmeiner


More information about the U-Boot mailing list