From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: linux-fsdevel@vger.kernel.org, linux-efi@vger.kernel.org,
linux-pm@vger.kernel.org
Cc: Ard Biesheuvel <ardb@kernel.org>, Jeremy Kerr <jk@ozlabs.org>,
Christian Brauner <brauner@kernel.org>,
Al Viro <viro@zeniv.linux.org.uk>,
Lennart Poettering <mzxreary@0pointer.de>
Subject: [PATCH 1/2] efivarfs: abstract initial variable creation routine
Date: Tue, 7 Jan 2025 13:31:28 -0800 [thread overview]
Message-ID: <20250107213129.28454-2-James.Bottomley@HansenPartnership.com> (raw)
In-Reply-To: <20250107213129.28454-1-James.Bottomley@HansenPartnership.com>
Reuse later for variable creation after hibernation
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
---
fs/efivarfs/super.c | 36 ++++++++++++++++++++++--------------
1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c
index 2523e74dbcfd..2523030caeda 100644
--- a/fs/efivarfs/super.c
+++ b/fs/efivarfs/super.c
@@ -213,32 +213,24 @@ bool efivarfs_variable_is_present(efi_char16_t *variable_name,
return dentry != NULL;
}
-static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
- unsigned long name_size, void *data)
+static int efivarfs_create_dentry(struct super_block *sb, efi_char16_t *name16,
+ unsigned long name_size, efi_guid_t *vendor,
+ char *name)
{
- struct super_block *sb = (struct super_block *)data;
struct efivar_entry *entry;
- struct inode *inode = NULL;
+ struct inode *inode;
struct dentry *dentry, *root = sb->s_root;
unsigned long size = 0;
- char *name;
int len;
int err = -ENOMEM;
bool is_removable = false;
- if (guid_equal(&vendor, &LINUX_EFI_RANDOM_SEED_TABLE_GUID))
- return 0;
-
entry = kzalloc(sizeof(*entry), GFP_KERNEL);
if (!entry)
return err;
memcpy(entry->var.VariableName, name16, name_size);
- memcpy(&(entry->var.VendorGuid), &vendor, sizeof(efi_guid_t));
-
- name = efivar_get_utf8name(name16, &vendor);
- if (!name)
- goto fail;
+ memcpy(&(entry->var.VendorGuid), vendor, sizeof(efi_guid_t));
/* length of the variable name itself: remove GUID and separator */
len = strlen(name) - EFI_VARIABLE_GUID_LEN - 1;
@@ -274,11 +266,27 @@ static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
iput(inode);
fail_name:
kfree(name);
-fail:
kfree(entry);
+
return err;
}
+static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
+ unsigned long name_size, void *data)
+{
+ struct super_block *sb = (struct super_block *)data;
+ char *name;
+
+ if (guid_equal(&vendor, &LINUX_EFI_RANDOM_SEED_TABLE_GUID))
+ return 0;
+
+ name = efivar_get_utf8name(name16, &vendor);
+ if (!name)
+ return -ENOMEM;
+
+ return efivarfs_create_dentry(sb, name16, name_size, &vendor, name);
+}
+
enum {
Opt_uid, Opt_gid,
};
--
2.35.3
next prev parent reply other threads:[~2025-01-07 21:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-07 21:31 [PATCH 0/2] efivarfs: fix hibernation problem with EFI variables James Bottomley
2025-01-07 21:31 ` James Bottomley [this message]
2025-01-07 21:31 ` [PATCH 2/2] efivarfs: add variable resync after hibernation James Bottomley
2025-02-28 16:44 ` Jon Hunter
2025-02-28 16:49 ` James Bottomley
2025-02-28 17:53 ` Jon Hunter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250107213129.28454-2-James.Bottomley@HansenPartnership.com \
--to=james.bottomley@hansenpartnership.com \
--cc=ardb@kernel.org \
--cc=brauner@kernel.org \
--cc=jk@ozlabs.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mzxreary@0pointer.de \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox