mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] fs: Fix can_lseek_backward()
@ 2017-11-15 22:27 Andrey Smirnov
  2017-11-16 11:07 ` Michael Grzeschik
  2017-11-17  8:57 ` Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Andrey Smirnov @ 2017-11-15 22:27 UTC (permalink / raw)
  To: barebox; +Cc: Andrey Smirnov

To quote corresponding man page:

"... Upon successful completion, lseek() returns the resulting offset
location as measured in bytes from the beginning of the file."

Which for lseek(fd, 0, SEEK_SET) would be 0, so returning 'ret' as
final step of the function would mean it'd never return anything but 0
as well. Change the code to explicitly return '1' to fix the problem.

Fixes: 7c3f8d366 ("uimage: fix: add can_lseek_backward and use in uimage_open")
Cc: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---

Sascha:

This change should probably also go to master, since without enabling
TFTP would break 'bootm' for uImages (at least it does on my setup)

Thanks,
Andrey Smirnov

 include/fs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/fs.h b/include/fs.h
index f8a3b8bda..5c5fff870 100644
--- a/include/fs.h
+++ b/include/fs.h
@@ -117,7 +117,7 @@ static inline int can_lseek_backward(int fd)
 	if (ret < 0)
 		return 0;
 
-	return ret;
+	return 1;
 }
 
 #define drv_to_fs_driver(d) container_of(d, struct fs_driver_d, drv)
-- 
2.13.6


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fs: Fix can_lseek_backward()
  2017-11-15 22:27 [PATCH] fs: Fix can_lseek_backward() Andrey Smirnov
@ 2017-11-16 11:07 ` Michael Grzeschik
  2017-11-17  8:57 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Grzeschik @ 2017-11-16 11:07 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox


[-- Attachment #1.1: Type: text/plain, Size: 1805 bytes --]

Hi Andrey,

On Wed, Nov 15, 2017 at 02:27:53PM -0800, Andrey Smirnov wrote:
> To quote corresponding man page:
> 
> "... Upon successful completion, lseek() returns the resulting offset
> location as measured in bytes from the beginning of the file."

Ack! I was reading that chapter beforehand but somehow did oversee it
and thought we receive the offset to the last position instead.

Thanks,
Michael

> Which for lseek(fd, 0, SEEK_SET) would be 0, so returning 'ret' as
> final step of the function would mean it'd never return anything but 0
> as well. Change the code to explicitly return '1' to fix the problem.
> 
> Fixes: 7c3f8d366 ("uimage: fix: add can_lseek_backward and use in uimage_open")
> Cc: Michael Grzeschik <m.grzeschik@pengutronix.de>
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
> 
> Sascha:
> 
> This change should probably also go to master, since without enabling
> TFTP would break 'bootm' for uImages (at least it does on my setup)
> 
> Thanks,
> Andrey Smirnov
> 
>  include/fs.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/fs.h b/include/fs.h
> index f8a3b8bda..5c5fff870 100644
> --- a/include/fs.h
> +++ b/include/fs.h
> @@ -117,7 +117,7 @@ static inline int can_lseek_backward(int fd)
>  	if (ret < 0)
>  		return 0;
>  
> -	return ret;
> +	return 1;
>  }
>  
>  #define drv_to_fs_driver(d) container_of(d, struct fs_driver_d, drv)
> -- 
> 2.13.6
> 
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 149 bytes --]

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fs: Fix can_lseek_backward()
  2017-11-15 22:27 [PATCH] fs: Fix can_lseek_backward() Andrey Smirnov
  2017-11-16 11:07 ` Michael Grzeschik
@ 2017-11-17  8:57 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2017-11-17  8:57 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox

On Wed, Nov 15, 2017 at 02:27:53PM -0800, Andrey Smirnov wrote:
> To quote corresponding man page:
> 
> "... Upon successful completion, lseek() returns the resulting offset
> location as measured in bytes from the beginning of the file."
> 
> Which for lseek(fd, 0, SEEK_SET) would be 0, so returning 'ret' as
> final step of the function would mean it'd never return anything but 0
> as well. Change the code to explicitly return '1' to fix the problem.
> 
> Fixes: 7c3f8d366 ("uimage: fix: add can_lseek_backward and use in uimage_open")
> Cc: Michael Grzeschik <m.grzeschik@pengutronix.de>
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
> 
> Sascha:
> 
> This change should probably also go to master, since without enabling
> TFTP would break 'bootm' for uImages (at least it does on my setup)

Yes, applied to master. I also created a stable/v2017.11 branch.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-11-17  8:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-15 22:27 [PATCH] fs: Fix can_lseek_backward() Andrey Smirnov
2017-11-16 11:07 ` Michael Grzeschik
2017-11-17  8:57 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox