[PATCH 16/18] cdev: use cdev::dos_partition_type only if cdev_is_mbr_partitioned

Marco Felsch m.felsch at pengutronix.de
Wed May 31 11:54:42 PDT 2023


On 23-05-31, Ahmad Fatoum wrote:
> dos_partition_type == 0 can mean that either a partition is not
> a MBR partition or that it indeed has a partition type of 0x00.
> 
> In preparation for using that field in a union, explicitly check if we
> have a MBR partition.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
> ---
>  common/blspec.c | 2 +-
>  fs/fs.c         | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/common/blspec.c b/common/blspec.c
> index e95a8dba8d76..8c7970da8915 100644
> --- a/common/blspec.c
> +++ b/common/blspec.c
> @@ -729,7 +729,7 @@ int blspec_scan_device(struct bootentries *bootentries, struct device *dev)
>  		 * partition with the MBR type id of 0xEA already exists it
>  		 * should be used as $BOOT
>  		 */
> -		if (cdev->dos_partition_type == 0xea) {
> +		if (cdev_is_mbr_partitioned(cdev->master) && cdev->dos_partition_type == 0xea) {

Since you already various helpers to drop priv direct access, what
about:

		if (cdev_dos_partition_type(cdev) == 0xea)

Within the helper you can check for the cdev_is_mbr_partitioned().

?

Regards,
  Marco

>  			ret = blspec_scan_cdev(bootentries, cdev);
>  			if (ret == 0)
>  				ret = -ENOENT;
> diff --git a/fs/fs.c b/fs/fs.c
> index 2d2d327c5fbc..9a92e6e251e5 100644
> --- a/fs/fs.c
> +++ b/fs/fs.c
> @@ -108,7 +108,7 @@ void cdev_print(const struct cdev *cdev)
>  
>  	if (cdev->filetype)
>  		nbytes += printf("Filetype: %s\t", file_type_to_string(cdev->filetype));
> -	if (cdev->dos_partition_type)
> +	if (cdev_is_mbr_partitioned(cdev->master))
>  		nbytes += printf("DOS parttype: 0x%02x\t", cdev->dos_partition_type);
>  	if (*cdev->partuuid || *cdev->diskuuid)
>  		nbytes += printf("%sUUID: %s", cdev_is_partition(cdev) ? "PART" : "DISK",
> -- 
> 2.39.2
> 
> 
> 



More information about the barebox mailing list