From: | Juan José Santamaría Flecha <juanjo(dot)santamaria(at)gmail(dot)com> |
---|---|
To: | Michael Paquier <michael(at)paquier(dot)xyz> |
Cc: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Fix fseek() detection of unseekable files on WIN32 |
Date: | 2023-03-15 11:18:25 |
Message-ID: | CAC+AXB3BgqAQ4Fmj2h2DhUXyNL1TqH6mi_+nGh+aGun-grF-kQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Mar 15, 2023 at 5:57 AM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
> On Tue, Mar 14, 2023 at 01:26:27PM +0100, Juan José Santamaría Flecha
> wrote:
> > As highlighted in [1] fseek() might fail to error even when accessing
> > unseekable streams.
> >
> > PFA a patch that checks the file type before the actual fseek(), so only
> > supported calls are made.
>
> + * streams, so harden that funcion with our version.
> s/funcion/function/.
>
Done.
+extern int pgfseek64(FILE *stream, pgoff_t offset, int origin);
> +extern pgoff_t pgftell64(FILE *stream);
> +#define fseeko(stream, offset, origin) pgfseek64(stream, offset, origin)
> +#define ftello(stream) pgftell64(stream)
>
> What about naming the internal wrappers _pgfseeko64() and
> _pgftello64(), located in a new file named win32fseek.c? It may be
> possible that we would need a similar treatment for fseek(), in the
> future, though I don't see an issue why this would be needed now.
>
Done.
> + if (GetFileType((HANDLE) _get_osfhandle(_fileno(stream))) !=
> FILE_TYPE_DISK)
> + {
> + errno = ESPIPE;
> + return -1;
> + }
> Shouldn't there be cases where we should return EINVAL for some of the
> other types, like FILE_TYPE_REMOTE or FILE_TYPE_UNKNOWN? We should
> return ESPIPE only for FILE_TYPE_PIPE and FILE_TYPE_CHAR, then?
>
Done.
PFA a new version of the patch.
Regards,
Juan José Santamaría Flecha
Attachment | Content-Type | Size |
---|---|---|
v2-0001-fix-fseek-detection-of-unseekable-files-for-WIN32.patch | application/octet-stream | 4.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2023-03-15 11:28:36 | Re: Documentation for building with meson |
Previous Message | Daniel Gustafsson | 2023-03-15 10:58:33 | Re: postgres_fdw: Useless if-test in GetConnection() |