[U-Boot] [PATCH v2 18/23] efi_loader: implement a pseudo "file delete"

AKASHI Takahiro takahiro.akashi at linaro.org
Wed Sep 5 02:51:12 UTC 2018


On Tue, Sep 04, 2018 at 11:16:38AM +0200, Alexander Graf wrote:
> 
> 
> On 04.09.18 09:49, AKASHI Takahiro wrote:
> > This patch is necessary to run SCT.efi (UEFI Self-Certification Test).
> > Returning EFI_SUCCESS can cheat SCT execution.
> > 
> > Signed-off-by: AKASHI Takahiro <takahiro.akashi at linaro.org>
> 
> How hard would it be to implement a real delete instead?

Good question.
The hardest part of implementation, I believe, is about handling
nasty long file names in a directory, in particular, when
directory entries which comprise a single LFN extend across two clusters.
In this case, all the entries must be deleted first, and then go back
to the first one and modify it. Due to a current simple buffering of
cluster (only one cluster buffer a time), some tweak is necessary.
In addition, if there is an already-deleted entry ahead of the given file,
we need further rewind directory entries and update the "new" last valid
one to mark it as so.
Those kind of things would make the implementation a bit complicated
rather than simple as expected.

So unless 'real' delete is a must for anything, I'm lukewarm to
work on it.

# I admit that we don't have to have this patch just if *delete* returns
successfully without doing anything.

Thanks,
-Takahiro AKASHI

> 
> Alex
> 
> > ---
> >  lib/efi_loader/efi_file.c | 10 +++++++++-
> >  1 file changed, 9 insertions(+), 1 deletion(-)
> > 
> > diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c
> > index 6ec98c80227e..12044a0c7196 100644
> > --- a/lib/efi_loader/efi_file.c
> > +++ b/lib/efi_loader/efi_file.c
> > @@ -226,12 +226,20 @@ static efi_status_t EFIAPI efi_file_close(struct efi_file_handle *file)
> >  	return EFI_EXIT(file_close(fh));
> >  }
> >  
> > +static efi_status_t EFIAPI efi_file_write(struct efi_file_handle *file,
> > +					  efi_uintn_t *buffer_size,
> > +					  void *buffer);
> > +
> >  static efi_status_t EFIAPI efi_file_delete(struct efi_file_handle *file)
> >  {
> >  	struct file_handle *fh = to_fh(file);
> > +	efi_uintn_t size = 0;
> >  	EFI_ENTRY("%p", file);
> > +
> > +	/* TODO: implement real 'delete' */
> > +	efi_file_write(file, &size, NULL);
> >  	file_close(fh);
> > -	return EFI_EXIT(EFI_WARN_DELETE_FAILURE);
> > +	return EFI_SUCCESS;
> >  }
> >  
> >  static efi_status_t file_read(struct file_handle *fh, u64 *buffer_size,
> > 


More information about the U-Boot mailing list