summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2021-11-22 09:47:16 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2021-11-25 08:43:59 +0100
commit92fe157a8b5eeeb1baa7204a3245770df6131f02 (patch)
treeb6a4f6eca2ba5553c05ea975d18f7510a789f803 /fs
parent09e48b3d17468d15e89f023c5086f0d9425a3003 (diff)
downloadbarebox-92fe157a8b5eeeb1baa7204a3245770df6131f02.tar.gz
barebox-92fe157a8b5eeeb1baa7204a3245770df6131f02.tar.xz
efi: centralize efivarfs_parse_filename
Turning an EFI varfs filename into its components will be useful for the EFI loader as well, so factor that out. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211122084732.2597109-15-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/efivarfs.c76
1 files changed, 0 insertions, 76 deletions
diff --git a/fs/efivarfs.c b/fs/efivarfs.c
index 01947439ff..2e72bb8852 100644
--- a/fs/efivarfs.c
+++ b/fs/efivarfs.c
@@ -47,82 +47,6 @@ struct efivarfs_priv {
struct list_head inodes;
};
-static int char_to_nibble(char c)
-{
- int ret = tolower(c);
-
- return ret <= '9' ? ret - '0' : ret - 'a' + 10;
-}
-
-static int read_byte_str(const char *str, u8 *out)
-{
- if (!isxdigit(*str) || !isxdigit(*(str + 1)))
- return -EINVAL;
-
- *out = (char_to_nibble(*str) << 4) | char_to_nibble(*(str + 1));
-
- return 0;
-}
-
-static int efi_guid_parse(const char *str, efi_guid_t *guid)
-{
- int i, ret;
- u8 idx[] = { 3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15 };
-
- for (i = 0; i < 16; i++) {
- ret = read_byte_str(str, &guid->b[idx[i]]);
- if (ret)
- return ret;
- str += 2;
-
- switch (i) {
- case 3:
- case 5:
- case 7:
- case 9:
- if (*str != '-')
- return -EINVAL;
- str++;
- break;
- }
- }
-
- return 0;
-}
-
-static int efivarfs_parse_filename(const char *filename, efi_guid_t *vendor, s16 **name)
-{
- int len, ret;
- const char *guidstr;
- s16 *varname;
- int i;
-
- if (*filename == '/')
- filename++;
-
- len = strlen(filename);
-
- if (len < sizeof("-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"))
- return -EINVAL;
-
- guidstr = filename + len - sizeof("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx");
- if (*guidstr != '-')
- return -EINVAL;
-
- guidstr++;
-
- ret = efi_guid_parse(guidstr, vendor);
-
- varname = xzalloc((guidstr - filename) * sizeof(s16));
-
- for (i = 0; i < guidstr - filename - 1; i++)
- varname[i] = filename[i];
-
- *name = varname;
-
- return 0;
-}
-
static int efivars_create(struct device_d *dev, const char *pathname, mode_t mode)
{
struct efivarfs_priv *priv = dev->priv;