mirror of
https://github.com/systemd/systemd.git
synced 2026-08-05 07:30:30 +00:00
efivars: add helper that reads an fs path from an efi var
This commit is contained in:
@@ -145,8 +145,10 @@ int efi_get_variable(
|
||||
int efi_get_variable_string(const char *variable, char **ret) {
|
||||
_cleanup_free_ void *s = NULL;
|
||||
size_t ss = 0;
|
||||
int r;
|
||||
char *x;
|
||||
int r;
|
||||
|
||||
assert(variable);
|
||||
|
||||
r = efi_get_variable(variable, NULL, &s, &ss);
|
||||
if (r < 0)
|
||||
@@ -156,10 +158,27 @@ int efi_get_variable_string(const char *variable, char **ret) {
|
||||
if (!x)
|
||||
return -ENOMEM;
|
||||
|
||||
*ret = x;
|
||||
if (ret)
|
||||
*ret = x;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int efi_get_variable_path(const char *variable, char **ret) {
|
||||
int r;
|
||||
|
||||
assert(variable);
|
||||
|
||||
r = efi_get_variable_string(variable, ret);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (ret)
|
||||
efi_tilt_backslashes(*ret);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static int efi_verify_variable(const char *variable, uint32_t attr, const void *value, size_t size) {
|
||||
_cleanup_free_ void *buf = NULL;
|
||||
size_t n;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "sd-id128.h"
|
||||
|
||||
#include "efivars-fundamental.h"
|
||||
#include "string-util.h"
|
||||
#include "time-util.h"
|
||||
|
||||
#define EFI_VENDOR_LOADER SD_ID128_MAKE(4a,67,b0,82,0a,4c,41,cf,b6,c7,44,0b,29,bb,8c,4f)
|
||||
@@ -47,6 +48,7 @@
|
||||
|
||||
int efi_get_variable(const char *variable, uint32_t *attribute, void **ret_value, size_t *ret_size);
|
||||
int efi_get_variable_string(const char *variable, char **ret);
|
||||
int efi_get_variable_path(const char *variable, char **ret);
|
||||
int efi_set_variable(const char *variable, const void *value, size_t size);
|
||||
int efi_set_variable_string(const char *variable, const char *p);
|
||||
|
||||
@@ -68,6 +70,10 @@ static inline int efi_get_variable_string(const char *variable, char **ret) {
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
static inline int efi_get_variable_path(const char *variable, char **ret) {
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
static inline int efi_set_variable(const char *variable, const void *value, size_t size) {
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
@@ -100,3 +106,7 @@ static inline int systemd_efi_options_efivarfs_if_newer(char **line) {
|
||||
return -ENODATA;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline char *efi_tilt_backslashes(char *s) {
|
||||
return string_replace_char(s, '\\', '/');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user