1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-10 05:18:17 +03:00

Merge pull request #34228 from poettering/uki-with-many-prep1

Two preparatory EFI library additions
This commit is contained in:
Lennart Poettering 2024-09-03 09:50:37 +02:00 committed by GitHub
commit fc676d4ab1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 35 additions and 18 deletions

View File

@ -41,12 +41,13 @@ DEFINE_STRNLEN(char16_t, strnlen16);
(_c >= 'A' && _c <= 'Z') ? _c + ('a' - 'A') : _c; \
})
#define DEFINE_STRTOLOWER(type, name) \
void name(type *s) { \
if (!s) \
return; \
for (; *s; s++) \
*s = TOLOWER(*s); \
#define DEFINE_STRTOLOWER(type, name) \
type* name(type *s) { \
if (!s) \
return NULL; \
for (type *p = s; *p; p++) \
*p = TOLOWER(*p); \
return s; \
}
DEFINE_STRTOLOWER(char, strtolower8);

View File

@ -23,8 +23,8 @@ static inline size_t strsize16(const char16_t *s) {
return s ? (strlen16(s) + 1) * sizeof(*s) : 0;
}
void strtolower8(char *s);
void strtolower16(char16_t *s);
char* strtolower8(char *s);
char16_t* strtolower16(char16_t *s);
int strncmp8(const char *s1, const char *s2, size_t n);
int strncmp16(const char16_t *s1, const char16_t *s2, size_t n);

View File

@ -105,26 +105,19 @@ EFI_STATUS chunked_read(EFI_FILE *file, size_t *size, void *buf) {
return EFI_SUCCESS;
}
EFI_STATUS file_read(
EFI_FILE *dir,
const char16_t *name,
EFI_STATUS file_handle_read(
EFI_FILE *handle,
uint64_t offset,
size_t size,
char **ret,
size_t *ret_size) {
_cleanup_(file_closep) EFI_FILE *handle = NULL;
_cleanup_free_ char *buf = NULL;
EFI_STATUS err;
assert(dir);
assert(name);
assert(handle);
assert(ret);
err = dir->Open(dir, &handle, (char16_t*) name, EFI_FILE_MODE_READ, 0ULL);
if (err != EFI_SUCCESS)
return err;
if (size == 0) {
_cleanup_free_ EFI_FILE_INFO *info = NULL;
@ -165,6 +158,28 @@ EFI_STATUS file_read(
return err;
}
EFI_STATUS file_read(
EFI_FILE *dir,
const char16_t *name,
uint64_t offset,
size_t size,
char **ret,
size_t *ret_size) {
EFI_STATUS err;
assert(dir);
assert(name);
assert(ret);
_cleanup_(file_closep) EFI_FILE *handle = NULL;
err = dir->Open(dir, &handle, (char16_t*) name, EFI_FILE_MODE_READ, 0ULL);
if (err != EFI_SUCCESS)
return err;
return file_handle_read(handle, offset, size, ret, ret_size);
}
void print_at(size_t x, size_t y, size_t attr, const char16_t *str) {
assert(str);
ST->ConOut->SetCursorPosition(ST->ConOut, x, y);

View File

@ -87,6 +87,7 @@ char16_t *mangle_stub_cmdline(char16_t *cmdline);
EFI_STATUS chunked_read(EFI_FILE *file, size_t *size, void *buf);
EFI_STATUS file_read(EFI_FILE *dir, const char16_t *name, uint64_t offset, size_t size, char **content, size_t *content_size);
EFI_STATUS file_handle_read(EFI_FILE *handle, uint64_t offset, size_t size, char **ret, size_t *ret_size);
static inline void file_closep(EFI_FILE **handle) {
if (!*handle)