From: Gabriel Dalimonte <gabriel.dalimonte@gmail.com>
To: u-boot@lists.denx.de
Cc: Gabriel Dalimonte <gabriel.dalimonte@gmail.com>,
Heinrich Schuchardt <xypron.glpk@gmx.de>,
Ilias Apalodimas <ilias.apalodimas@linaro.org>,
Simon Glass <sjg@chromium.org>, Tom Rini <trini@konsulko.com>
Subject: [PATCH v2 5/6] efi_loader: move path out of file_handle
Date: Mon, 17 Feb 2025 13:26:46 -0500 [thread overview]
Message-ID: <20250217182648.31294-6-gabriel.dalimonte@gmail.com> (raw)
In-Reply-To: <20250217182648.31294-1-gabriel.dalimonte@gmail.com>
In order to support renaming via SetInfo(), path must allow for longer
values than what was originally present when file_handle was allocated.
Signed-off-by: Gabriel Dalimonte <gabriel.dalimonte@gmail.com>
---
(no changes since v1)
lib/efi_loader/efi_file.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c
index 201fa5f8f3c..6b15c1f3d27 100644
--- a/lib/efi_loader/efi_file.c
+++ b/lib/efi_loader/efi_file.c
@@ -40,7 +40,7 @@ struct file_handle {
struct fs_dir_stream *dirs;
struct fs_dirent *dent;
- char path[0];
+ char *path;
};
#define to_fh(x) container_of(x, struct file_handle, base)
@@ -178,6 +178,7 @@ static struct efi_file_handle *file_open(struct file_system *fs,
u64 attributes)
{
struct file_handle *fh;
+ char *path;
char f0[MAX_UTF8_PER_UTF16] = {0};
int plen = 0;
int flen = 0;
@@ -194,11 +195,13 @@ static struct efi_file_handle *file_open(struct file_system *fs,
plen = strlen(parent->path) + 1;
}
+ fh = calloc(1, sizeof(*fh));
/* +2 is for null and '/' */
- fh = calloc(1, sizeof(*fh) + plen + (flen * MAX_UTF8_PER_UTF16) + 2);
- if (!fh)
- return NULL;
+ path = calloc(1, plen + (flen * MAX_UTF8_PER_UTF16) + 2);
+ if (!fh || !path)
+ goto error;
+ fh->path = path;
fh->open_mode = open_mode;
fh->base = efi_file_handle_protocol;
fh->fs = fs;
@@ -245,6 +248,7 @@ static struct efi_file_handle *file_open(struct file_system *fs,
return &fh->base;
error:
+ free(fh->path);
free(fh);
return NULL;
}
@@ -368,6 +372,7 @@ out:
static efi_status_t file_close(struct file_handle *fh)
{
fs_closedir(fh->dirs);
+ free(fh->path);
free(fh);
return EFI_SUCCESS;
}
--
2.34.1
next prev parent reply other threads:[~2025-02-18 5:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-17 18:26 [PATCH v2 0/6] This series adds support for file renaming to EFI_FILE_PROTOCOL.SetInfo() Gabriel Dalimonte
2025-02-17 18:26 ` [PATCH v2 1/6] fs: fat: factor out dentry link create/delete Gabriel Dalimonte
2025-02-17 18:26 ` [PATCH v2 2/6] fs: add rename infrastructure Gabriel Dalimonte
2025-02-20 7:33 ` Ilias Apalodimas
2025-02-17 18:26 ` [PATCH v2 3/6] fs: fat: add rename Gabriel Dalimonte
2025-02-17 18:26 ` [PATCH v2 4/6] fs: fat: update parent dirs metadata on dentry create/delete Gabriel Dalimonte
2025-02-17 18:26 ` Gabriel Dalimonte [this message]
2025-02-20 7:55 ` [PATCH v2 5/6] efi_loader: move path out of file_handle Ilias Apalodimas
2025-03-04 2:30 ` Gabriel D'Alimonte
2025-02-17 18:26 ` [PATCH v2 6/6] efi_loader: support file rename in SetInfo() Gabriel Dalimonte
2025-02-20 8:21 ` Ilias Apalodimas
2025-02-20 8:30 ` Ilias Apalodimas
2025-03-08 14:04 ` [PATCH v2 0/6] This series adds support for file renaming to EFI_FILE_PROTOCOL.SetInfo() Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250217182648.31294-6-gabriel.dalimonte@gmail.com \
--to=gabriel.dalimonte@gmail.com \
--cc=ilias.apalodimas@linaro.org \
--cc=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox