Re: [PATCH 2/3] libfile: open_and_lseek: enlarge small files enough to make lseek possible

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 09, 2018 at 10:33:12AM +0200, Uwe Kleine-König wrote:
> This makes the following do the expected thing:
> 
> 	barebox@barebox sandbox:/ ls -l lala
> 	-rwxrwxrwx              4 lala
> 	barebox@barebox sandbox:/ mw -d lala 72 0
> 
> Without this patch mw dies with
> 
> 	lseek: Invalid argument
> 
> memset, memcpy and probably others benefit in the same way.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>
> ---
>  lib/libfile.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/lib/libfile.c b/lib/libfile.c
> index 83c6399a5b39..01c59cdb80fe 100644
> --- a/lib/libfile.c
> +++ b/lib/libfile.c
> @@ -510,6 +510,24 @@ int open_and_lseek(const char *filename, int mode, loff_t pos)
>  	if (!pos)
>  		return fd;
>  
> +	if (mode & (O_WRONLY | O_RDWR)) {
> +		struct stat s;
> +
> +		ret = fstat(fd, &s);
> +		if (ret) {
> +			perror("ftruncate");

I assume this "ftruncate" did not happen on purpose, right? Replaced
with "fstat" and applied.

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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux