Message ID | 20241026064048.370062-5-heinrich.schuchardt@canonical.com |
---|---|
State | Accepted |
Delegated to: | Tom Rini |
Headers | show |
Series | fs: ext4: implement opendir, readdir, closedir | expand |
On Sat, 26 Oct 2024 at 08:41, Heinrich Schuchardt <heinrich.schuchardt@canonical.com> wrote: > > * Some of our file system drivers cannot report a file size for > directories. Use a dummy value in this case. > * For SetInfo the UEFI spec requires to ignore the file size field. > > Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> > --- > lib/efi_loader/efi_file.c | 30 ++++++++++++++++++++---------- > 1 file changed, 20 insertions(+), 10 deletions(-) > Reviewed-by: Simon Glass <sjg@chromium.org>
On Sat, 26 Oct 2024 at 09:41, Heinrich Schuchardt <heinrich.schuchardt@canonical.com> wrote: > > * Some of our file system drivers cannot report a file size for > directories. Use a dummy value in this case. > * For SetInfo the UEFI spec requires to ignore the file size field. > > Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> > --- > lib/efi_loader/efi_file.c | 30 ++++++++++++++++++++---------- > 1 file changed, 20 insertions(+), 10 deletions(-) > > diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c > index c92d8ccf004..95b3c890ee9 100644 > --- a/lib/efi_loader/efi_file.c > +++ b/lib/efi_loader/efi_file.c > @@ -864,8 +864,16 @@ static efi_status_t EFIAPI efi_file_getinfo(struct efi_file_handle *file, > } > > ret = efi_get_file_size(fh, &file_size); > - if (ret != EFI_SUCCESS) > - goto error; > + if (ret != EFI_SUCCESS) { > + if (!fh->isdir) > + goto error; > + /* > + * Some file drivers don't implement fs_size() for > + * directories. Use a dummy non-zero value. > + */ > + file_size = 4096; > + ret = EFI_SUCCESS; > + } > > memset(info, 0, required_size); > > @@ -976,14 +984,16 @@ static efi_status_t EFIAPI efi_file_setinfo(struct efi_file_handle *file, > } > free(new_file_name); > /* Check for truncation */ > - ret = efi_get_file_size(fh, &file_size); > - if (ret != EFI_SUCCESS) > - goto out; > - if (file_size != info->file_size) { > - /* TODO: we do not support truncation */ > - EFI_PRINT("Truncation not supported\n"); > - ret = EFI_ACCESS_DENIED; > - goto out; > + if (!fh->isdir) { > + ret = efi_get_file_size(fh, &file_size); > + if (ret != EFI_SUCCESS) > + goto out; > + if (file_size != info->file_size) { > + /* TODO: we do not support truncation */ > + EFI_PRINT("Truncation not supported\n"); > + ret = EFI_ACCESS_DENIED; > + goto out; > + } > } > /* > * We do not care for the other attributes > -- > 2.45.2 > Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c index c92d8ccf004..95b3c890ee9 100644 --- a/lib/efi_loader/efi_file.c +++ b/lib/efi_loader/efi_file.c @@ -864,8 +864,16 @@ static efi_status_t EFIAPI efi_file_getinfo(struct efi_file_handle *file, } ret = efi_get_file_size(fh, &file_size); - if (ret != EFI_SUCCESS) - goto error; + if (ret != EFI_SUCCESS) { + if (!fh->isdir) + goto error; + /* + * Some file drivers don't implement fs_size() for + * directories. Use a dummy non-zero value. + */ + file_size = 4096; + ret = EFI_SUCCESS; + } memset(info, 0, required_size); @@ -976,14 +984,16 @@ static efi_status_t EFIAPI efi_file_setinfo(struct efi_file_handle *file, } free(new_file_name); /* Check for truncation */ - ret = efi_get_file_size(fh, &file_size); - if (ret != EFI_SUCCESS) - goto out; - if (file_size != info->file_size) { - /* TODO: we do not support truncation */ - EFI_PRINT("Truncation not supported\n"); - ret = EFI_ACCESS_DENIED; - goto out; + if (!fh->isdir) { + ret = efi_get_file_size(fh, &file_size); + if (ret != EFI_SUCCESS) + goto out; + if (file_size != info->file_size) { + /* TODO: we do not support truncation */ + EFI_PRINT("Truncation not supported\n"); + ret = EFI_ACCESS_DENIED; + goto out; + } } /* * We do not care for the other attributes
* Some of our file system drivers cannot report a file size for directories. Use a dummy value in this case. * For SetInfo the UEFI spec requires to ignore the file size field. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> --- lib/efi_loader/efi_file.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-)