Skip to content

Commit 0e2f98d

Browse files
James Bottomleyardbiesheuvel
authored andcommitted
efivarfs: abstract initial variable creation routine
Reuse later for variable creation after hibernation Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent 8ba14d9 commit 0e2f98d

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

fs/efivarfs/super.c

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -226,26 +226,18 @@ bool efivarfs_variable_is_present(efi_char16_t *variable_name,
226226
return dentry != NULL;
227227
}
228228

229-
static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
230-
unsigned long name_size, void *data)
229+
static int efivarfs_create_dentry(struct super_block *sb, efi_char16_t *name16,
230+
unsigned long name_size, efi_guid_t vendor,
231+
char *name)
231232
{
232-
struct super_block *sb = (struct super_block *)data;
233233
struct efivar_entry *entry;
234-
struct inode *inode = NULL;
234+
struct inode *inode;
235235
struct dentry *dentry, *root = sb->s_root;
236236
unsigned long size = 0;
237-
char *name;
238237
int len;
239238
int err = -ENOMEM;
240239
bool is_removable = false;
241240

242-
if (guid_equal(&vendor, &LINUX_EFI_RANDOM_SEED_TABLE_GUID))
243-
return 0;
244-
245-
name = efivar_get_utf8name(name16, &vendor);
246-
if (!name)
247-
return err;
248-
249241
/* length of the variable name itself: remove GUID and separator */
250242
len = strlen(name) - EFI_VARIABLE_GUID_LEN - 1;
251243

@@ -289,6 +281,22 @@ static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
289281
return err;
290282
}
291283

284+
static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
285+
unsigned long name_size, void *data)
286+
{
287+
struct super_block *sb = (struct super_block *)data;
288+
char *name;
289+
290+
if (guid_equal(&vendor, &LINUX_EFI_RANDOM_SEED_TABLE_GUID))
291+
return 0;
292+
293+
name = efivar_get_utf8name(name16, &vendor);
294+
if (!name)
295+
return -ENOMEM;
296+
297+
return efivarfs_create_dentry(sb, name16, name_size, vendor, name);
298+
}
299+
292300
enum {
293301
Opt_uid, Opt_gid,
294302
};

0 commit comments

Comments
 (0)