Now that we can have a link pointing from the parent, follow it to make
cdev_find_child_by_gpt_typeuuid resolves to the correct partition.

This doesn't affect state-by-alias, because __of_cdev_find already calls
cdev_readlink, but that's an implementation detail that we shouldn't
depend on in cdev_find_child_by_gpt_typeuuid.

Signed-off-by: Ahmad Fatoum <a.fat...@pengutronix.de>
---
 fs/devfs-core.c | 3 +++
 include/block.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/fs/devfs-core.c b/fs/devfs-core.c
index d1e4e1f0f6b5..8f504abdfd8d 100644
--- a/fs/devfs-core.c
+++ b/fs/devfs-core.c
@@ -133,6 +133,9 @@ cdev_find_child_by_gpt_typeuuid(struct cdev *cdev, const 
guid_t *typeuuid)
 {
        struct cdev *partcdev;
 
+        /* Follow links to support storage-by-alias */
+        cdev = cdev_readlink(cdev);
+
        if (!cdev_is_gpt_partitioned(cdev))
                return ERR_PTR(-EINVAL);
 
diff --git a/include/block.h b/include/block.h
index 0ca6c6aff6e9..5ce3eb7d7838 100644
--- a/include/block.h
+++ b/include/block.h
@@ -112,6 +112,7 @@ static inline bool cdev_is_block_partition(const struct 
cdev *cdev)
 
 static inline bool cdev_is_block_disk(const struct cdev *cdev)
 {
+       cdev = cdev_readlink(cdev);
        return cdev_is_block_device(cdev) && !cdev_is_partition(cdev);
 }
 
-- 
2.39.5


Reply via email to