diff mbox series

[U-Boot,v3,4/4] efi_loader: disk: install file system protocol to a whole disk

Message ID 20191004030523.21579-5-takahiro.akashi@linaro.org
State Changes Requested
Delegated to: Heinrich Schuchardt
Headers show
Series efi_loader: disk: install FILE_SYSTEM_PROTOCOL to whole disk | expand

Commit Message

AKASHI Takahiro Oct. 4, 2019, 3:05 a.m. UTC
Currently, a whole disk without any partitions is not associated
with EFI_SIMPLE_FILE_SYSTEM_PROTOCOL. So even if it houses some
file system, there is a chance that we may not be able to access
it, particularly, when accesses are to be attempted after searching
that protocol against a device handle.

With this patch, EFI_SIMPLE_FILE_SYSTEM_PROTOCOL is installed
to such a disk if part_get_info() shows there is no partition
table installed on it.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
---
 lib/efi_loader/efi_disk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Heinrich Schuchardt Oct. 4, 2019, 7:15 p.m. UTC | #1
On 10/4/19 5:05 AM, AKASHI Takahiro wrote:
> Currently, a whole disk without any partitions is not associated
> with EFI_SIMPLE_FILE_SYSTEM_PROTOCOL. So even if it houses some
> file system, there is a chance that we may not be able to access
> it, particularly, when accesses are to be attempted after searching
> that protocol against a device handle.
>
> With this patch, EFI_SIMPLE_FILE_SYSTEM_PROTOCOL is installed
> to such a disk if part_get_info() shows there is no partition
> table installed on it.
>
> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> ---
>  lib/efi_loader/efi_disk.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
> index 27329cadb6f1..4e1a1efed7ec 100644
> --- a/lib/efi_loader/efi_disk.c
> +++ b/lib/efi_loader/efi_disk.c
> @@ -329,7 +329,8 @@ static efi_status_t efi_disk_add_dev(
>  			       diskobj->dp);
>  	if (ret != EFI_SUCCESS)
>  		return ret;
> -	if (part >= 1 && efi_fs_exists(desc, part)) {
> +	/* partitions or whole disk without partitions */
> +	if (efi_fs_exists(desc, part)) {

As described in response to an earlier version of the patch series we
should only install the EFI protocols if no partition table exits.

Best regards

Heinrich Schuchardt

>  		diskobj->volume = efi_simple_file_system(desc, part,
>  							 diskobj->dp);
>  		ret = efi_add_protocol(&diskobj->header,
>
AKASHI Takahiro Oct. 7, 2019, 2:27 a.m. UTC | #2
On Fri, Oct 04, 2019 at 09:15:19PM +0200, Heinrich Schuchardt wrote:
> On 10/4/19 5:05 AM, AKASHI Takahiro wrote:
> > Currently, a whole disk without any partitions is not associated
> > with EFI_SIMPLE_FILE_SYSTEM_PROTOCOL. So even if it houses some
> > file system, there is a chance that we may not be able to access
> > it, particularly, when accesses are to be attempted after searching
> > that protocol against a device handle.
> >
> > With this patch, EFI_SIMPLE_FILE_SYSTEM_PROTOCOL is installed
> > to such a disk if part_get_info() shows there is no partition
> > table installed on it.
> >
> > Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> > ---
> >  lib/efi_loader/efi_disk.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
> > index 27329cadb6f1..4e1a1efed7ec 100644
> > --- a/lib/efi_loader/efi_disk.c
> > +++ b/lib/efi_loader/efi_disk.c
> > @@ -329,7 +329,8 @@ static efi_status_t efi_disk_add_dev(
> >  			       diskobj->dp);
> >  	if (ret != EFI_SUCCESS)
> >  		return ret;
> > -	if (part >= 1 && efi_fs_exists(desc, part)) {
> > +	/* partitions or whole disk without partitions */
> > +	if (efi_fs_exists(desc, part)) {
> 
> As described in response to an earlier version of the patch series we
> should only install the EFI protocols if no partition table exits.

That is why I removed "part >= 1" check here.
efi_fs_exists() should work both for a whole disk (part == 0)
or any partitions on a disk.

Thanks,
-Takahiro Akashi

> Best regards
> 
> Heinrich Schuchardt
> 
> >  		diskobj->volume = efi_simple_file_system(desc, part,
> >  							 diskobj->dp);
> >  		ret = efi_add_protocol(&diskobj->header,
> >
>
diff mbox series

Patch

diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index 27329cadb6f1..4e1a1efed7ec 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -329,7 +329,8 @@  static efi_status_t efi_disk_add_dev(
 			       diskobj->dp);
 	if (ret != EFI_SUCCESS)
 		return ret;
-	if (part >= 1 && efi_fs_exists(desc, part)) {
+	/* partitions or whole disk without partitions */
+	if (efi_fs_exists(desc, part)) {
 		diskobj->volume = efi_simple_file_system(desc, part,
 							 diskobj->dp);
 		ret = efi_add_protocol(&diskobj->header,