diff mbox series

[v2,1/1] diskpart: fix computed partname when device is a symlink

Message ID 20210826072500.47187-1-james.hilliard1@gmail.com
State Accepted
Headers show
Series [v2,1/1] diskpart: fix computed partname when device is a symlink | expand

Commit Message

James Hilliard Aug. 26, 2021, 7:25 a.m. UTC
Fixes:
ERROR : Device /dev/internal1 cannot be opened: No such file or directory
ERROR : creating vfat file system on /dev/internal1 failed. -1

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
Changes v1 -> v2:
  - fix realpath fallback path assignment
---
 handlers/diskpart_handler.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Stefano Babic Aug. 26, 2021, 8:11 a.m. UTC | #1
Hi James,

On 26.08.21 09:25, James Hilliard wrote:
> Fixes:
> ERROR : Device /dev/internal1 cannot be opened: No such file or directory
> ERROR : creating vfat file system on /dev/internal1 failed. -1
> 
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> ---
> Changes v1 -> v2:
>    - fix realpath fallback path assignment
> ---
>   handlers/diskpart_handler.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/handlers/diskpart_handler.c b/handlers/diskpart_handler.c
> index 3e3da15..45ee97c 100644
> --- a/handlers/diskpart_handler.c
> +++ b/handlers/diskpart_handler.c
> @@ -954,9 +954,14 @@ handler_release:
>   			if (!strlen(part->fstype))
>   				continue;  /* Don't touch partitions without fstype */
>   
> +			char *path = NULL;
>   			char *device = NULL;
>   
> -			device = fdisk_partname(img->device, partno);
> +			path = realpath(img->device, NULL);
> +			if (!path)
> +				path = strdup(img->device);
> +			device = fdisk_partname(path, partno);
> +			free(path);
>   			ret = diskformat_mkfs(device, part->fstype);
>   			free(device);
>   			if (ret)
> 

Yep, correct !

Acked-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic
Stefano Babic Aug. 26, 2021, 11:39 a.m. UTC | #2
On 26.08.21 09:25, James Hilliard wrote:
> Fixes:
> ERROR : Device /dev/internal1 cannot be opened: No such file or directory
> ERROR : creating vfat file system on /dev/internal1 failed. -1
> 
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> ---
> Changes v1 -> v2:
>    - fix realpath fallback path assignment
> ---
>   handlers/diskpart_handler.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/handlers/diskpart_handler.c b/handlers/diskpart_handler.c
> index 3e3da15..45ee97c 100644
> --- a/handlers/diskpart_handler.c
> +++ b/handlers/diskpart_handler.c
> @@ -954,9 +954,14 @@ handler_release:
>   			if (!strlen(part->fstype))
>   				continue;  /* Don't touch partitions without fstype */
>   
> +			char *path = NULL;
>   			char *device = NULL;
>   
> -			device = fdisk_partname(img->device, partno);
> +			path = realpath(img->device, NULL);
> +			if (!path)
> +				path = strdup(img->device);
> +			device = fdisk_partname(path, partno);
> +			free(path);
>   			ret = diskformat_mkfs(device, part->fstype);
>   			free(device);
>   			if (ret)
> 

Applied to -master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/handlers/diskpart_handler.c b/handlers/diskpart_handler.c
index 3e3da15..45ee97c 100644
--- a/handlers/diskpart_handler.c
+++ b/handlers/diskpart_handler.c
@@ -954,9 +954,14 @@  handler_release:
 			if (!strlen(part->fstype))
 				continue;  /* Don't touch partitions without fstype */
 
+			char *path = NULL;
 			char *device = NULL;
 
-			device = fdisk_partname(img->device, partno);
+			path = realpath(img->device, NULL);
+			if (!path)
+				path = strdup(img->device);
+			device = fdisk_partname(path, partno);
+			free(path);
 			ret = diskformat_mkfs(device, part->fstype);
 			free(device);
 			if (ret)