[PATCH u-boot-marvell 11/14] tools: kwboot: Handle EINTR in kwboot_write()

Stefan Roese sr at denx.de
Wed Jan 26 16:41:40 CET 2022


On 1/25/22 18:13, Marek Behún wrote:
> From: Pali Rohár <pali at kernel.org>
> 
> The write() syscall may be interrupted. Handle EINTR and retry it.
> 
> Signed-off-by: Pali Rohár <pali at kernel.org>
> Signed-off-by: Marek Behún <marek.behun at nic.cz>

Reviewed-by: Stefan Roese <sr at denx.de>

Thanks,
Stefan


> ---
>   tools/kwboot.c | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/kwboot.c b/tools/kwboot.c
> index de433c1b04..8b748f0fdd 100644
> --- a/tools/kwboot.c
> +++ b/tools/kwboot.c
> @@ -292,13 +292,15 @@ static int blk_rsp_timeo = KWBOOT_BLK_RSP_TIMEO;
>   static ssize_t
>   kwboot_write(int fd, const char *buf, size_t len)
>   {
> -	size_t tot = 0;
> +	ssize_t tot = 0;
>   
>   	while (tot < len) {
>   		ssize_t wr = write(fd, buf + tot, len - tot);
>   
> -		if (wr < 0)
> -			return -1;
> +		if (wr < 0 && errno == EINTR)
> +			continue;
> +		else if (wr < 0)
> +			return wr;
>   
>   		tot += wr;
>   	}

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de


More information about the U-Boot mailing list