From: Ahmad Fatoum <a.fat...@barebox.org> The DPS_TYPE_FLAG_NO_AUTO flag indicates that a partition should not be automatically discovered by type UUID if not directly referenced.
We do auto discovery for barebox env and sate using cdev_find_child_by_gpt_typeuuid, so teach it to respect that flag. Signed-off-by: Ahmad Fatoum <a.fat...@pengutronix.de> --- common/blspec.c | 4 ++-- common/bootscan.c | 11 +++++++++-- fs/devfs-core.c | 11 +++++++++-- include/bootscan.h | 5 ++++- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/common/blspec.c b/common/blspec.c index 5223ac30f8a5..59fa40c9ff50 100644 --- a/common/blspec.c +++ b/common/blspec.c @@ -511,7 +511,7 @@ static int blspec_scan_disk(struct bootscanner *scanner, * should be used as $BOOT */ if (cdev_is_mbr_partitioned(cdev) && partcdev->dos_partition_type == 0xea) { - ret = boot_scan_cdev(scanner, bootentries, partcdev); + ret = boot_scan_cdev(scanner, bootentries, partcdev, true); if (ret == 0) ret = -ENOENT; @@ -560,7 +560,7 @@ static int blspec_scan_device(struct bootscanner *scanner, * by the bootblspec spec). */ list_for_each_entry(cdev, &dev->cdevs, devices_list) { - ret = boot_scan_cdev(scanner, bootentries, cdev); + ret = boot_scan_cdev(scanner, bootentries, cdev, true); if (ret > 0) found += ret; } diff --git a/common/bootscan.c b/common/bootscan.c index 222498c609a4..813d6d242a08 100644 --- a/common/bootscan.c +++ b/common/bootscan.c @@ -8,6 +8,7 @@ #include <linux/stat.h> #include <linux/err.h> #include <mtd/ubi-user.h> +#include <uapi/spec/dps.h> #include <bootscan.h> @@ -80,7 +81,8 @@ static int boot_scan_ubi(struct bootscanner *scanner, * error occurred. */ int boot_scan_cdev(struct bootscanner *scanner, - struct bootentries *bootentries, struct cdev *cdev) + struct bootentries *bootentries, struct cdev *cdev, + bool autodiscover) { int ret, found = 0; void *buf = xzalloc(512); @@ -89,6 +91,11 @@ int boot_scan_cdev(struct bootscanner *scanner, pr_debug("%s(%s): %s\n", __func__, scanner->name, cdev->name); + if (autodiscover && (cdev->typeflags & DPS_TYPE_FLAG_NO_AUTO)) { + pr_debug("auto discovery skipped\n"); + return 0; + } + ret = cdev_read(cdev, buf, 512, 0, 0); if (ret < 0) { free(buf); @@ -144,7 +151,7 @@ static int boot_scan_devicename(struct bootscanner *scanner, cdev = cdev_by_name(devname); if (cdev) { - int ret = boot_scan_cdev(scanner, bootentries, cdev); + int ret = boot_scan_cdev(scanner, bootentries, cdev, false); if (ret > 0) return ret; } diff --git a/fs/devfs-core.c b/fs/devfs-core.c index f84b34ea53ab..c69c38d6506e 100644 --- a/fs/devfs-core.c +++ b/fs/devfs-core.c @@ -27,6 +27,7 @@ #include <unistd.h> #include <range.h> #include <fs.h> +#include <spec/dps.h> LIST_HEAD(cdev_list); @@ -135,8 +136,14 @@ cdev_find_child_by_gpt_typeuuid(struct cdev *cdev, const guid_t *typeuuid) return ERR_PTR(-EINVAL); for_each_cdev_partition(partcdev, cdev) { - if (guid_equal(&partcdev->typeuuid, typeuuid)) - return partcdev; + if (!guid_equal(&partcdev->typeuuid, typeuuid)) + continue; + if (cdev->typeflags & DPS_TYPE_FLAG_NO_AUTO) { + dev_dbg(cdev->dev, "auto discovery skipped\n"); + continue; + } + + return partcdev; } return ERR_PTR(-ENOENT); diff --git a/include/bootscan.h b/include/bootscan.h index 99094dc09320..ffc67c4a90ab 100644 --- a/include/bootscan.h +++ b/include/bootscan.h @@ -2,6 +2,8 @@ #ifndef __BOOTSCAN_H #define __BOOTSCAN_H +#include <linux/types.h> + struct bootentries; struct device; struct cdev; @@ -25,7 +27,8 @@ struct bootscanner { }; int boot_scan_cdev(struct bootscanner *scanner, - struct bootentries *bootentries, struct cdev *cdev); + struct bootentries *bootentries, struct cdev *cdev, + bool autodiscover); int bootentry_scan_generate(struct bootscanner *scanner, struct bootentries *bootentries, -- 2.39.5