From: | Magnus Hagander <magnus(at)hagander(dot)net> |
---|---|
To: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
Cc: | Juan José Santamaría Flecha <juanjo(dot)santamaria(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: A micro-optimisation for walkdir() |
Date: | 2020-09-07 09:42:04 |
Message-ID: | CABUevEzURN=wC95JHvTKFJtEy0eY9rWO42yU=59-q8xSwm-Dug@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Mon, Sep 7, 2020 at 12:27 AM Thomas Munro <thomas(dot)munro(at)gmail(dot)com> wrote:
> On Sun, Sep 6, 2020 at 5:23 AM Juan José Santamaría Flecha
> <juanjo(dot)santamaria(at)gmail(dot)com> wrote:
> > On Sat, Sep 5, 2020 at 2:13 AM Andres Freund <andres(at)anarazel(dot)de> wrote:
> >> > However, it looks like we might be missing a further opportunity
> >> > here... Doesn't Windows already give us the flags we need in the
> >> > dwFileAttributes member of the WIN32_FIND_DATA object that the
> >> > Find{First,Next}File() functions populate?
> >>
> >> That'd be better...
> >
> >
> > At first I did not see how to get DT_LNK directly, but it is possible
> without additional calls, so please find attached a version with that logic.
> >
> > This version also drops the enum, defining just the macros.
>
> Excellent. I'd like to commit these soon, unless someone has a better
> idea for how to name file_utils_febe.c.
>
> I think the following is a little mysterious, but it does seem to be
> what people do for this in other projects. It is the documented way
> to detect mount points, and I guess IO_REPARSE_TAG_MOUNT_POINT is
> either overloaded also for junctions, or junctions are the same thing
> as mount points. It would be nice to see a Win32 documentation page
> that explicitly said that.
>
The wikipedia page on it is actually fairly decent:
https://en.wikipedia.org/wiki/NTFS_reparse_point. It's not the
documentation of course, but it's easier to read :) The core difference is
whether you mount a whole filesystem (mount point) or just a directory off
something mounted elsehwere (junction).
And yes, the wikipedia page confirms that junctions also use
IO_REPARSE_TAG_MOUNT_POINT.
+ /* For reparse points dwReserved0 field will contain the ReparseTag */
> + else if ((fd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0
> + && (fd.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT))
> + d->ret.d_type = DT_LNK;
>
> Hmm, it's interesting that our existing test for a junction in
> pgwin32_is_junction() only looks for FILE_ATTRIBUTE_REPARSE_POINT and
> doesn't care what kind of reparse point it is.
>
I think that's mostly historical. When that code was written, the only two
types of reparse points that existed were junctions and mount points --
which are as already noted, the same. Symbolic links, unix sockets and such
things came later.
--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/>
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/>
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2020-09-07 09:47:16 | Re: Yet another fast GiST build |
Previous Message | Noah Misch | 2020-09-07 09:32:55 | Re: v13: CLUSTER segv with wal_level=minimal and parallel index creation |