206 lines
6.3 KiB
Diff
206 lines
6.3 KiB
Diff
From 767cc7f3b63233577767e60fe4bc911f6595c121 Mon Sep 17 00:00:00 2001
|
|
From: W_Y_CPP <383152993@qq.com>
|
|
Date: Wed, 22 Feb 2023 22:58:07 +0900
|
|
Subject: [PATCH] export efivarfs function
|
|
|
|
---
|
|
fs/efivarfs/internal.h | 39 ---------------------------------------
|
|
include/linux/efi.h | 39 +++++++++++++++++++++++++++++++++++++++
|
|
2 files changed, 39 insertions(+), 39 deletions(-)
|
|
fs/efivarfs/vars.c | 20 +++++++++++---------
|
|
1 file changed, 11 insertions(+), 9 deletions(-)
|
|
|
|
--- a/fs/efivarfs/internal.h
|
|
+++ b/fs/efivarfs/internal.h
|
|
@@ -9,45 +9,6 @@
|
|
#include <linux/list.h>
|
|
#include <linux/efi.h>
|
|
|
|
-struct efi_variable {
|
|
- efi_char16_t VariableName[EFI_VAR_NAME_LEN/sizeof(efi_char16_t)];
|
|
- efi_guid_t VendorGuid;
|
|
- unsigned long DataSize;
|
|
- __u8 Data[1024];
|
|
- efi_status_t Status;
|
|
- __u32 Attributes;
|
|
-} __attribute__((packed));
|
|
-
|
|
-struct efivar_entry {
|
|
- struct efi_variable var;
|
|
- struct list_head list;
|
|
- struct kobject kobj;
|
|
-};
|
|
-
|
|
-int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *),
|
|
- void *data, bool duplicates, struct list_head *head);
|
|
-
|
|
-int efivar_entry_add(struct efivar_entry *entry, struct list_head *head);
|
|
-void __efivar_entry_add(struct efivar_entry *entry, struct list_head *head);
|
|
-void efivar_entry_remove(struct efivar_entry *entry);
|
|
-int efivar_entry_delete(struct efivar_entry *entry);
|
|
-
|
|
-int efivar_entry_size(struct efivar_entry *entry, unsigned long *size);
|
|
-int __efivar_entry_get(struct efivar_entry *entry, u32 *attributes,
|
|
- unsigned long *size, void *data);
|
|
-int efivar_entry_get(struct efivar_entry *entry, u32 *attributes,
|
|
- unsigned long *size, void *data);
|
|
-int efivar_entry_set_get_size(struct efivar_entry *entry, u32 attributes,
|
|
- unsigned long *size, void *data, bool *set);
|
|
-
|
|
-int efivar_entry_iter(int (*func)(struct efivar_entry *, void *),
|
|
- struct list_head *head, void *data);
|
|
-
|
|
-bool efivar_validate(efi_guid_t vendor, efi_char16_t *var_name, u8 *data,
|
|
- unsigned long data_size);
|
|
-bool efivar_variable_is_removable(efi_guid_t vendor, const char *name,
|
|
- size_t len);
|
|
-
|
|
extern const struct file_operations efivarfs_file_operations;
|
|
extern const struct inode_operations efivarfs_dir_inode_operations;
|
|
extern bool efivarfs_valid_name(const char *str, int len);
|
|
--- a/include/linux/efi.h
|
|
+++ b/include/linux/efi.h
|
|
@@ -1062,6 +1062,45 @@ struct efivars {
|
|
|
|
#define EFI_VAR_NAME_LEN 1024
|
|
|
|
+struct efi_variable {
|
|
+ efi_char16_t VariableName[EFI_VAR_NAME_LEN/sizeof(efi_char16_t)];
|
|
+ efi_guid_t VendorGuid;
|
|
+ unsigned long DataSize;
|
|
+ __u8 Data[1024];
|
|
+ efi_status_t Status;
|
|
+ __u32 Attributes;
|
|
+} __attribute__((packed));
|
|
+
|
|
+struct efivar_entry {
|
|
+ struct efi_variable var;
|
|
+ struct list_head list;
|
|
+ struct kobject kobj;
|
|
+};
|
|
+
|
|
+int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *),
|
|
+ void *data, bool duplicates, struct list_head *head);
|
|
+
|
|
+int efivar_entry_add(struct efivar_entry *entry, struct list_head *head);
|
|
+void __efivar_entry_add(struct efivar_entry *entry, struct list_head *head);
|
|
+void efivar_entry_remove(struct efivar_entry *entry);
|
|
+int efivar_entry_delete(struct efivar_entry *entry);
|
|
+
|
|
+int efivar_entry_size(struct efivar_entry *entry, unsigned long *size);
|
|
+int __efivar_entry_get(struct efivar_entry *entry, u32 *attributes,
|
|
+ unsigned long *size, void *data);
|
|
+int efivar_entry_get(struct efivar_entry *entry, u32 *attributes,
|
|
+ unsigned long *size, void *data);
|
|
+int efivar_entry_set_get_size(struct efivar_entry *entry, u32 attributes,
|
|
+ unsigned long *size, void *data, bool *set);
|
|
+
|
|
+int efivar_entry_iter(int (*func)(struct efivar_entry *, void *),
|
|
+ struct list_head *head, void *data);
|
|
+
|
|
+bool efivar_validate(efi_guid_t vendor, efi_char16_t *var_name, u8 *data,
|
|
+ unsigned long data_size);
|
|
+bool efivar_variable_is_removable(efi_guid_t vendor, const char *name,
|
|
+ size_t len);
|
|
+
|
|
int efivars_register(struct efivars *efivars,
|
|
const struct efivar_operations *ops,
|
|
struct kobject *kobject);
|
|
--- a/fs/efivarfs/vars.c
|
|
+++ b/fs/efivarfs/vars.c
|
|
@@ -259,6 +259,7 @@ efivar_validate(efi_guid_t vendor, efi_c
|
|
kfree(utf8_name);
|
|
return true;
|
|
}
|
|
+EXPORT_SYMBOL_GPL(efivar_validate);
|
|
|
|
bool
|
|
efivar_variable_is_removable(efi_guid_t vendor, const char *var_name,
|
|
@@ -287,7 +288,7 @@ efivar_variable_is_removable(efi_guid_t
|
|
*/
|
|
return found;
|
|
}
|
|
-
|
|
+EXPORT_SYMBOL_GPL(efivar_variable_is_removable);
|
|
static bool variable_is_present(efi_char16_t *variable_name, efi_guid_t *vendor,
|
|
struct list_head *head)
|
|
{
|
|
@@ -446,7 +447,7 @@ free:
|
|
|
|
return err;
|
|
}
|
|
-
|
|
+EXPORT_SYMBOL_GPL(efivar_init);
|
|
/**
|
|
* efivar_entry_add - add entry to variable list
|
|
* @entry: entry to add to list
|
|
@@ -466,7 +467,7 @@ int efivar_entry_add(struct efivar_entry
|
|
|
|
return 0;
|
|
}
|
|
-
|
|
+EXPORT_SYMBOL_GPL(efivar_entry_add);
|
|
/**
|
|
* __efivar_entry_add - add entry to variable list
|
|
* @entry: entry to add to list
|
|
@@ -487,7 +488,7 @@ void efivar_entry_remove(struct efivar_e
|
|
{
|
|
list_del(&entry->list);
|
|
}
|
|
-
|
|
+EXPORT_SYMBOL_GPL(efivar_entry_remove);
|
|
/*
|
|
* efivar_entry_list_del_unlock - remove entry from variable list
|
|
* @entry: entry to remove
|
|
@@ -536,7 +537,7 @@ int efivar_entry_delete(struct efivar_en
|
|
efivar_entry_list_del_unlock(entry);
|
|
return 0;
|
|
}
|
|
-
|
|
+EXPORT_SYMBOL_GPL(efivar_entry_delete);
|
|
/**
|
|
* efivar_entry_size - obtain the size of a variable
|
|
* @entry: entry for this variable
|
|
@@ -562,7 +563,7 @@ int efivar_entry_size(struct efivar_entr
|
|
|
|
return 0;
|
|
}
|
|
-
|
|
+EXPORT_SYMBOL_GPL(efivar_entry_size);
|
|
/**
|
|
* __efivar_entry_get - call get_variable()
|
|
* @entry: read data for this variable
|
|
@@ -585,7 +586,7 @@ int __efivar_entry_get(struct efivar_ent
|
|
|
|
return efi_status_to_err(status);
|
|
}
|
|
-
|
|
+EXPORT_SYMBOL_GPL(__efivar_entry_get);
|
|
/**
|
|
* efivar_entry_get - call get_variable()
|
|
* @entry: read data for this variable
|
|
@@ -606,7 +607,7 @@ int efivar_entry_get(struct efivar_entry
|
|
|
|
return 0;
|
|
}
|
|
-
|
|
+EXPORT_SYMBOL_GPL(efivar_entry_get);
|
|
/**
|
|
* efivar_entry_set_get_size - call set_variable() and get new size (atomic)
|
|
* @entry: entry containing variable to set and get
|
|
@@ -686,7 +687,7 @@ out:
|
|
return err;
|
|
|
|
}
|
|
-
|
|
+EXPORT_SYMBOL_GPL(efivar_entry_set_get_size);
|
|
/**
|
|
* efivar_entry_iter - iterate over variable list
|
|
* @func: callback function
|
|
@@ -720,3 +721,4 @@ int efivar_entry_iter(int (*func)(struct
|
|
|
|
return err;
|
|
}
|
|
+EXPORT_SYMBOL_GPL(efivar_entry_iter);
|
|
\ No newline at end of file
|