mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-26 07:17:10 +00:00
efi_loader: file: support creating a directory
In efi world, there is no obvious "mkdir" interface, instead, Open() with EFI_FILE_MODE_CREATE in mode parameter and EFI_FILE_DIRECTORY in attributes parameter creates a directory. In this patch, efi_file_open() is extended so as to accept such a combination of parameters and call u-boot's mkdir interface for expected action. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
parent
0349da5100
commit
5bc84a1303
1 changed files with 10 additions and 4 deletions
|
@ -131,7 +131,8 @@ static int sanitize_path(char *path)
|
||||||
* With windoze style backlashes, ofc.
|
* With windoze style backlashes, ofc.
|
||||||
*/
|
*/
|
||||||
static struct efi_file_handle *file_open(struct file_system *fs,
|
static struct efi_file_handle *file_open(struct file_system *fs,
|
||||||
struct file_handle *parent, s16 *file_name, u64 mode)
|
struct file_handle *parent, s16 *file_name, u64 mode,
|
||||||
|
u64 attributes)
|
||||||
{
|
{
|
||||||
struct file_handle *fh;
|
struct file_handle *fh;
|
||||||
char f0[MAX_UTF8_PER_UTF16] = {0};
|
char f0[MAX_UTF8_PER_UTF16] = {0};
|
||||||
|
@ -174,7 +175,12 @@ static struct efi_file_handle *file_open(struct file_system *fs,
|
||||||
if (set_blk_dev(fh))
|
if (set_blk_dev(fh))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (!((mode & EFI_FILE_MODE_CREATE) || fs_exists(fh->path)))
|
if ((mode & EFI_FILE_MODE_CREATE) &&
|
||||||
|
(attributes & EFI_FILE_DIRECTORY)) {
|
||||||
|
if (fs_mkdir(fh->path))
|
||||||
|
goto error;
|
||||||
|
} else if (!((mode & EFI_FILE_MODE_CREATE) ||
|
||||||
|
fs_exists(fh->path)))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* figure out if file is a directory: */
|
/* figure out if file is a directory: */
|
||||||
|
@ -200,7 +206,7 @@ static efi_status_t EFIAPI efi_file_open(struct efi_file_handle *file,
|
||||||
EFI_ENTRY("%p, %p, \"%ls\", %llx, %llu", file, new_handle, file_name,
|
EFI_ENTRY("%p, %p, \"%ls\", %llx, %llu", file, new_handle, file_name,
|
||||||
open_mode, attributes);
|
open_mode, attributes);
|
||||||
|
|
||||||
*new_handle = file_open(fh->fs, fh, file_name, open_mode);
|
*new_handle = file_open(fh->fs, fh, file_name, open_mode, attributes);
|
||||||
if (!*new_handle)
|
if (!*new_handle)
|
||||||
return EFI_EXIT(EFI_NOT_FOUND);
|
return EFI_EXIT(EFI_NOT_FOUND);
|
||||||
|
|
||||||
|
@ -601,7 +607,7 @@ efi_open_volume(struct efi_simple_file_system_protocol *this,
|
||||||
|
|
||||||
EFI_ENTRY("%p, %p", this, root);
|
EFI_ENTRY("%p, %p", this, root);
|
||||||
|
|
||||||
*root = file_open(fs, NULL, NULL, 0);
|
*root = file_open(fs, NULL, NULL, 0, 0);
|
||||||
|
|
||||||
return EFI_EXIT(EFI_SUCCESS);
|
return EFI_EXIT(EFI_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue