Hi,
On 11/28/25 3:08 PM, Maud Spierings via B4 Relay wrote:
> From: Maud Spierings <[email protected]>
>
> pread() is not available for windows, convert to lseek() + read()
>
> Signed-off-by: Maud Spierings <[email protected]>
>
> ---
>
> I think this modifies the state of fd, I am not sure if pread() did this
> too. May be necessary to point the file pointer where it was before? On
> the other hand this reads the whole file so why.
I would prefer to ship a pread implementation for windows instead that
takes care to lseek to wherever we need to read from and then lseek back
to the original offset as not to induce subtle breakage into other host
tools.
Cheers,
Ahmad
> ---
> scripts/common.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/common.c b/scripts/common.c
> index a6eee968b7..544d295b7f 100644
> --- a/scripts/common.c
> +++ b/scripts/common.c
> @@ -202,8 +202,12 @@ int pread_full(int fd, void *buf, size_t size, loff_t
> offset)
> size_t insize = size;
> int now;
>
> + now = lseek(fd, offset, SEEK_SET);
> + if (now < 0)
> + return now;
> +
> while (size) {
> - now = pread(fd, buf, size, offset);
> + now = read(fd, buf, size);
> if (now == 0)
> break;
> if (now < 0)
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |