Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fw_printenv does not work with /dev/disk/by-path/platform-11270000.ufshci-scsi-0:0:0:1 #27

Open
AristoChen opened this issue Sep 6, 2023 · 0 comments

Comments

@AristoChen
Copy link

Hi,

I have /dev/disk/by-path/platform-11270000.ufshci-scsi-0:0:0:1 on my device and I found that fw_printenv will separate the path by checking : then only check if /dev/disk/by-path/platform-11270000.ufshci-scsi-0 exists.

so I am wondering if it makes sense to check the original path first, if it does not exitst, then fallback to the original mechanism that check the splitted path?

I have draft a diff and it works fine on my device

diff --git a/src/uboot_env.c b/src/uboot_env.c
index b924c49..a5dc598 100644
--- a/src/uboot_env.c
+++ b/src/uboot_env.c
@@ -342,21 +342,26 @@ static int normalize_device_path(char *path, struct uboot_flash_env *dev)
        char *sep = NULL, *normalized = NULL;
        size_t normalized_len = 0, volume_len = 0, output_len = 0;
 
-       /*
-        * if volume name is present, split into device path and volume
-        * since only the device path needs normalized
-        */
-       sep = strchr(path, DEVNAME_SEPARATOR);
-       if (sep)
-       {
-               volume_len = strlen(sep);
-               *sep = '\0';
-       }
 
+       /* Check the original path first, then fallback to splitted path */
        if ((normalized = realpath(path, NULL)) == NULL)
        {
-               /* device file didn't exist */
-               return -EINVAL;
+               /*
+                * if volume name is present, split into device path and volume
+                * since only the device path needs normalized
+                */
+               sep = strchr(path, DEVNAME_SEPARATOR);
+               if (sep)
+               {
+                       volume_len = strlen(sep);
+                       *sep = '\0';
+               }
+
+               if ((normalized = realpath(path, NULL)) == NULL)
+               {
+                       /* device file didn't exist */
+                       return -EINVAL;
+               }
        }
 
        normalized_len = strlen(normalized);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant