efivarfs: rework the filesystem to make it human readable
cover efivarfs: rework the filesystem to make it human readable
Hi,
efivarfs: rework the filesystem to make it human readable
today we use <varname>-<guid as %pUl>
such as Boot0000-8be4df61-93ca-11d2-aa0d-00e098032b8c
now we will use a different approach where will represent first the vendor as a directory and then inside the associates variable.
But also create symlink on the vendor with readable name.
so it will look like this:
barebox@barebox EFI payload:/ ls -l /efivars/
drwxrwxrwx 36 04b37fe8-f6ae-480b-bdd5-37d98c5e89aa drwxrwxrwx 36 4a67b082-0a4c-41cf-b6c7-440b29bb8c4f drwxrwxrwx 36 4c19049f-4137-4dd3-9c10-8b97a83ffdfa drwxrwxrwx 36 5b446ed1-e30b-4faa-871a-3654eca36080 drwxrwxrwx 36 5b91f69c-8b88-4a2b-9269-5f1d802b5175 drwxrwxrwx 36 8be4df61-93ca-11d2-aa0d-00e098032b8c
lrwxrwxrwx 3 Efi -> 8be4df61-93ca-11d2-aa0d-00e098032b8c
lrwxrwxrwx 7 barebox -> 5b91f69c-8b88-4a2b-9269-5f1d802b5175
drwxrwxrwx 36 eb704011-1402-11d3-8e77-00a0c969723b
lrwxrwxrwx 7 systemd -> 4a67b082-0a4c-41cf-b6c7-440b29bb8c4f
barebox@barebox EFI payload:/ ls -l /efivars/Efi/
-rw-rw-rw- 62 Boot0000 -rw-rw-rw- 80 Boot0001 -rw-rw-rw- 84 Boot0002 -rw-rw-rw- 106 Boot0003 -rw-rw-rw- 108 Boot0004 -rw-rw-rw- 141 Boot0005
-rw-rw-rw- 88 Boot0006
-rw-rw-rw- 2 BootCurrent
-rw-rw-rw- 4 BootOptionSupport
-rw-rw-rw- 14 BootOrder
-rw-rw-rw- 107 ConIn
-rw-rw-rw- 1567 ConInDev
-rw-rw-rw- 103 ConOut
-rw-rw-rw- 1855 ConOutDev
-rw-rw-rw- 73 ErrOut
-rw-rw-rw- 1563 ErrOutDev
-rw-rw-rw- 14 Key0000
-rw-rw-rw- 14 Key0001
-rw-rw-rw- 4 Lang
-rw-rw-rw- 13 LangCodes
-rw-rw-rw- 8 OsIndicationsSupported
-rw-rw-rw- 3 PlatformLang
-rw-rw-rw- 18 PlatformLangCodes
-rw-rw-rw- 108 PlatformRecovery0000
-rw-rw-rw- 2 Timeout
barebox@barebox EFI payload:/ ls -l /efivars/barebox/ barebox@barebox EFI payload:/ ls -l /efivars/systemd/
-rw-rw-rw- 14 LoaderTimeInitUSec
please pull
The following changes since commit f14af7444ad9d8ce674382f222119f5fcd3f2576:
efi: add veriable to report secure boot support and status (2017-02-28 23:05:31 +0800)
are available in the git repository at:
git://git.jcrosoft.org/barebox.git delivery/efivarfs
for you to fetch changes up to a757520bfccf17064181ebc15646efdb83ee581b:
efivarfs: rework the filesystem to make it human readable (2017-03-01 00:15:38 +0800)
----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (2):
ls: allow to list a symlink ending with '/' as a dir
efivarfs: rework the filesystem to make it human readable
commands/ls.c | 41 +++++++++++++++++---- common/efi-guid.c | 17 +++++++-- common/efi/efi.c | 2 +- fs/efivarfs.c | 379 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------- include/efi.h | 1 + 5 files changed, 347 insertions(+), 93 deletions(-)
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/2 ls: allow to list a symlink ending with '/' as a dir
--- commands/ls.c | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-)
commands/ls.c +35 -6
@@ -64,6 +64,16 @@ int ls(const char *path, ulong flags)if (flags &LS_SHOWARG && s.st_mode &S_IFDIR )printf ("%s:\n" , path); +if (S_ISLNK (s.st_mode)) { +int len =strlen (path); + +if (path[len -1 ] !='/' ) { +ls_one (path, path, &s); +return 0 ; + } + s.st_mode |=S_IFDIR ; + } +if (!(s.st_mode &S_IFDIR )) {ls_one (path, path, &s);return 0 ;
@@ -171,13 +181,25 @@ static int do_ls(int argc, char *argv[])continue ; } -if (!(s.st_mode &S_IFDIR )) { -if (flags &LS_COLUMN ) -string_list_add_sorted (&sl, argv[o]); -else -ls_one (argv[o], argv[o], &s); +if (s.st_mode &S_IFDIR ) { + o++; +continue ; } +if (s.st_mode &S_IFLNK ) { +int len =strlen (argv[o]); + +if (argv[o][len -1 ] =='/' ) { + o++; +continue ; + } + } + +if (flags &LS_COLUMN ) +string_list_add_sorted (&sl, argv[o]); +else +ls_one (argv[o], argv[o], &s); + o++; }
@@ -197,7 +219,14 @@ static int do_ls(int argc, char *argv[])continue ; } -if (s.st_mode &S_IFDIR ) { +if (s.st_mode &S_IFDIR || s.st_mode &S_IFLNK ) { +int len =strlen (argv[o]); + +if (s.st_mode &S_IFLNK && argv[o][len -1 ] !='/' ) { + o++; +continue ; + } + ret =ls (argv[o], flags);if (ret) {perror ("ls" );
Signature · 7 lines
2.11.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/2 efivarfs: rework the filesystem to make it human readable
today we use <varname>-<guid as %pUl>
such as Boot0000-8be4df61-93ca-11d2-aa0d-00e098032b8c
now we will use a different approach where will represent first the vendor as a directory and then inside the associates variable.
But also create symlink on the vendor with readable name.
so it will look like this:
barebox@barebox EFI payload:/ ls -l /efivars/
drwxrwxrwx 36 04b37fe8-f6ae-480b-bdd5-37d98c5e89aa drwxrwxrwx 36 4a67b082-0a4c-41cf-b6c7-440b29bb8c4f drwxrwxrwx 36 4c19049f-4137-4dd3-9c10-8b97a83ffdfa drwxrwxrwx 36 5b446ed1-e30b-4faa-871a-3654eca36080 drwxrwxrwx 36 5b91f69c-8b88-4a2b-9269-5f1d802b5175 drwxrwxrwx 36 8be4df61-93ca-11d2-aa0d-00e098032b8c
lrwxrwxrwx 3 Efi -> 8be4df61-93ca-11d2-aa0d-00e098032b8c
lrwxrwxrwx 7 barebox -> 5b91f69c-8b88-4a2b-9269-5f1d802b5175
drwxrwxrwx 36 eb704011-1402-11d3-8e77-00a0c969723b
lrwxrwxrwx 7 systemd -> 4a67b082-0a4c-41cf-b6c7-440b29bb8c4f
barebox@barebox EFI payload:/ ls -l /efivars/Efi/
-rw-rw-rw- 62 Boot0000 -rw-rw-rw- 80 Boot0001 -rw-rw-rw- 84 Boot0002 -rw-rw-rw- 106 Boot0003 -rw-rw-rw- 108 Boot0004 -rw-rw-rw- 141 Boot0005
-rw-rw-rw- 88 Boot0006
-rw-rw-rw- 2 BootCurrent
-rw-rw-rw- 4 BootOptionSupport
-rw-rw-rw- 14 BootOrder
-rw-rw-rw- 107 ConIn
-rw-rw-rw- 1567 ConInDev
-rw-rw-rw- 103 ConOut
-rw-rw-rw- 1855 ConOutDev
-rw-rw-rw- 73 ErrOut
-rw-rw-rw- 1563 ErrOutDev
-rw-rw-rw- 14 Key0000
-rw-rw-rw- 14 Key0001
-rw-rw-rw- 4 Lang
-rw-rw-rw- 13 LangCodes
-rw-rw-rw- 8 OsIndicationsSupported
-rw-rw-rw- 3 PlatformLang
-rw-rw-rw- 18 PlatformLangCodes
-rw-rw-rw- 108 PlatformRecovery0000
-rw-rw-rw- 2 Timeout
barebox@barebox EFI payload:/ ls -l /efivars/barebox/ barebox@barebox EFI payload:/ ls -l /efivars/systemd/
-rw-rw-rw- 14 LoaderTimeInitUSec
--- common/efi-guid.c | 17 ++- common/efi/efi.c | 2 +- fs/efivarfs.c | 379 ++++++++++++++++++++++++++++++++++++++++++------------ include/efi.h | 1 + 4 files changed, 312 insertions(+), 87 deletions(-)
common/efi-guid.c +15 -2
@@ -14,11 +14,21 @@ efi_guid_t efi_systemd_vendor_guid = EFI_SYSTEMD_VENDOR_GUID;#define EFI_GUID_STRING (guid, short, long) do { \ if (!efi_guidcmp(guid, *g)) \ - return long; \ + return is_long ? long : short; \ } while(0) +const char *efi_guid_string (efi_guid_t *g) { +const char *name; + + name =efi_guid_string_type (g,1 ); + +return name ? name :"Unknown" ; +} + +const char *efi_guid_string_type (efi_guid_t *g,int is_long) +{EFI_GUID_STRING (EFI_NULL_GUID ,"NULL" ,"NULL GUID" );EFI_GUID_STRING (EFI_MPS_TABLE_GUID ,"MPS Table" ,"MPS Table GUID in EFI System Table" );EFI_GUID_STRING (EFI_ACPI_TABLE_GUID ,"ACPI Table" ,"ACPI 1.0 Table GUID in EFI System Table" );
@@ -88,5 +98,8 @@ const char *efi_guid_string(efi_guid_t *g)EFI_GUID_STRING (EFI_ISCSIDXE_INF_GUID ,"IScsiDxe.inf" ,"EFI IScsiDxe.inf File GUID" );EFI_GUID_STRING (EFI_VLANCONFIGDXE_INF_GUID ,"VlanConfigDxe.inf" ,"EFI VlanConfigDxe.inf File GUID" ); -return "unknown" ; +EFI_GUID_STRING (EFI_BAREBOX_VENDOR_GUID ,"barebox" ,"Barebox Bootloader" ); +EFI_GUID_STRING (EFI_SYSTEMD_VENDOR_GUID ,"systemd" ,"Linux systemd" ); + +return NULL ; }
common/efi/efi.c +1 -1
@@ -299,7 +299,7 @@ static int efi_init(void)defaultenv_append_directory (env_efi); - env =xasprintf ("/efivars/barebox-env-%pUl" , &efi_barebox_vendor_guid); + env =xasprintf ("/efivars/%pUl/barebox-env" , &efi_barebox_vendor_guid);default_environment_path_set (env);return 0 ;
fs/efivarfs.c +295 -84
547 lines not on this page · raw message
include/efi.h +1 -0
@@ -668,6 +668,7 @@ char *device_path_to_str(struct efi_device_path *dev_path);u8 device_path_to_type (struct efi_device_path *dev_path);char *device_path_to_partuuid (struct efi_device_path *dev_path); +const char *efi_guid_string_type (efi_guid_t *g,int is_long);const char *efi_guid_string (efi_guid_t *g);#endif /* _LINUX_EFI_H */
Signature · 7 lines
2.11.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi,
Sascha is this one ok?
Best Regards,
J.
Quoted 82 lines · Jean-Christophe PLAGNIOL-VILLARD
Hi,
efivarfs: rework the filesystem to make it human readable
today we use <varname>-<guid as %pUl>
such as Boot0000-8be4df61-93ca-11d2-aa0d-00e098032b8c
now we will use a different approach where will represent first the vendor as a directory and then inside the associates variable.
But also create symlink on the vendor with readable name.
so it will look like this:
barebox@barebox EFI payload:/ ls -l /efivars/
drwxrwxrwx 36 04b37fe8-f6ae-480b-bdd5-37d98c5e89aa drwxrwxrwx 36 4a67b082-0a4c-41cf-b6c7-440b29bb8c4f drwxrwxrwx 36 4c19049f-4137-4dd3-9c10-8b97a83ffdfa drwxrwxrwx 36 5b446ed1-e30b-4faa-871a-3654eca36080 drwxrwxrwx 36 5b91f69c-8b88-4a2b-9269-5f1d802b5175 drwxrwxrwx 36 8be4df61-93ca-11d2-aa0d-00e098032b8clrwxrwxrwx 3 Efi -> 8be4df61-93ca-11d2-aa0d-00e098032b8c
lrwxrwxrwx 7 barebox -> 5b91f69c-8b88-4a2b-9269-5f1d802b5175
drwxrwxrwx 36 eb704011-1402-11d3-8e77-00a0c969723b
lrwxrwxrwx 7 systemd -> 4a67b082-0a4c-41cf-b6c7-440b29bb8c4f
barebox@barebox EFI payload:/ ls -l /efivars/Efi/(quoted diff) +0
-25-rw-rw-rw- 62 Boot0000 -rw-rw-rw- 80 Boot0001 -rw-rw-rw- 84 Boot0002 -rw-rw-rw- 106 Boot0003 -rw-rw-rw- 108 Boot0004 -rw-rw-rw- 141 Boot0005 -rw-rw-rw- 88 Boot0006 -rw-rw-rw- 2 BootCurrent -rw-rw-rw- 4 BootOptionSupport -rw-rw-rw- 14 BootOrder -rw-rw-rw- 107 ConIn -rw-rw-rw- 1567 ConInDev -rw-rw-rw- 103 ConOut -rw-rw-rw- 1855 ConOutDev -rw-rw-rw- 73 ErrOut -rw-rw-rw- 1563 ErrOutDev -rw-rw-rw- 14 Key0000 -rw-rw-rw- 14 Key0001 -rw-rw-rw- 4 Lang -rw-rw-rw- 13 LangCodes -rw-rw-rw- 8 OsIndicationsSupported -rw-rw-rw- 3 PlatformLang -rw-rw-rw- 18 PlatformLangCodes -rw-rw-rw- 108 PlatformRecovery0000 -rw-rw-rw- 2 Timeoutbarebox@barebox EFI payload:/ ls -l /efivars/barebox/ barebox@barebox EFI payload:/ ls -l /efivars/systemd/
-rw-rw-rw- 14 LoaderTimeInitUSecplease pull
The following changes since commit
f14af7444ad9d8ce674382f222119f5fcd3f2576:efi: add veriable to report secure boot support and status (2017-02-28 23:05:31 +0800)
are available in the git repository at:
git://git.jcrosoft.org/barebox.gitdelivery/efivarfsfor you to fetch changes up to
a757520bfccf17064181ebc15646efdb83ee581b:efivarfs: rework the filesystem to make it human readable (2017-03-01 00:15:38 +0800)
----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (2):
ls: allow to list a symlink ending with '/' as a dir
efivarfs: rework the filesystem to make it human readablecommands/ls.c | 41 +++++++++++++++++---- common/efi-guid.c | 17 +++++++-- common/efi/efi.c | 2 +- fs/efivarfs.c | 379 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------- include/efi.h | 1 + 5 files changed, 347 insertions(+), 93 deletions(-)
Quoted 7 lines
Best Regards,
J._______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 3 lines · Jean-Christophe PLAGNIOL-VILLARD
Hi,
Sascha is this one ok?
I asked Michael to have a look at this series, so far he didn't find time.
Sascha
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Hi,
Quoted 5 lines · Sascha Hauer
Quoted 1 line · Jean-Christophe PLAGNIOL-VILLARD
Sascha is this one ok?
I asked Michael to have a look at this series, so far he didn't find time.
I'm not sure I like it this way. The old way matches what the Linux kernel does so it's familiar. And the mix of guids and 'names' is rather cluttered because they are not grouped separately.
Maybe keep the old version and add something like the by-name etc. symlinks used in udev:
<guid-for-foo>-bar
<something>
EFI
[...]
foo
bar -> ../../<guid-for-foo>-barMichael
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 7 lines · Michael Olbrich
Hi,
Quoted 1 line · Sascha Hauer
On Thu, Mar 09, 2017 at 03:38:40PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Sascha is this one ok?
I asked Michael to have a look at this series, so far he didn't find time.
I'm not sure I like it this way. The old way matches what the Linux kernel does so it's familiar. And the mix of guids and 'names' is rather cluttered because they are not grouped separately.
we can split them in sub dirs
/efivars/by-guid/<guid>/var
and keep the known one in
/efivars/Efi/…
/efivars/barebox/…
/efivars/systemd/…
as we will use known guid for most of the time
as does linux too most of the time
Quoted 9 lines
Maybe keep the old version and add something like the by-name etc. symlinks used in udev:
<guid-for-foo>-bar
<something>
EFI
[...]
foo
bar -> ../../<guid-for-foo>-bar
<guid-for-foo>-bar is un readable
and we need to parse a filename which is a prone to error even when creating new variable and today we only allow to create var for barebox guid in the "user space” So this is easier to handle
and when you ls it at the end is hard to read
The efivarfs is for user not C Code
That’s why I prefer to have a design that is easy to read
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox