Skip to content

Commit

Permalink
efivarfs: abstract initial variable creation routine
Browse files Browse the repository at this point in the history
Reuse later for variable creation after hibernation

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
  • Loading branch information
James Bottomley authored and Ard Biesheuvel committed Jan 22, 2025
1 parent 8ba14d9 commit 0e2f98d
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions fs/efivarfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,26 +226,18 @@ 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;

name = efivar_get_utf8name(name16, &vendor);
if (!name)
return err;

/* length of the variable name itself: remove GUID and separator */
len = strlen(name) - EFI_VARIABLE_GUID_LEN - 1;

Expand Down Expand Up @@ -289,6 +281,22 @@ static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
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,
};
Expand Down

0 comments on commit 0e2f98d

Please sign in to comment.