develooper Front page | perl.perl5.changes | Postings from October 2020

[Perl/perl5] 0197a0: add lstat(), fetch st_dev and st_ino and fetchst_...

From:
Tony Cook via perl5-changes
Date:
October 15, 2020 04:14
Subject:
[Perl/perl5] 0197a0: add lstat(), fetch st_dev and st_ino and fetchst_...
Message ID:
Perl/perl5/push/refs/heads/smoke-me/tonyc/win32-symlink/000000-75e135@github.com
  Branch: refs/heads/smoke-me/tonyc/win32-symlink
  Home:   https://github.com/Perl/perl5
  Commit: 0197a0bd37919c8edcb5f7be1857db05a8639ea2
      https://github.com/Perl/perl5/commit/0197a0bd37919c8edcb5f7be1857db05a8639ea2
  Author: Tony Cook <tony@develop-help.com>
  Date:   2020-10-15 (Thu, 15 Oct 2020)

  Changed paths:
    M MANIFEST
    M dosish.h
    M t/op/stat.t
    A t/win32/stat.t
    M win32/config.gc
    M win32/config.vc
    M win32/config_H.gc
    M win32/config_H.vc
    M win32/perlhost.h
    M win32/win32.c
    M win32/win32.h
    M win32/win32iop.h

  Log Message:
  -----------
  add lstat(), fetch st_dev and st_ino and fetch st_nlink for fstat

We need lstat() for various modules to work well with symlinks,
and the same modules often want to check for matches on the device
and inode number.

The values we're using for st_ino match those that the Python and Rust
libraries use, and Go uses the same volume and file index values for
testing if two stat objects refer to the same file.

They aren't entirely unique, given ReFS uses 128-bit file ids, but
the API used to check for this (GetFileInformationByHandleEx() for
FileIdInfo) is only available on server operating systems, so I can't
directly test it anyway.


  Commit: 61515b0acf1a011d725089604f0bd6b1d9cae000
      https://github.com/Perl/perl5/commit/61515b0acf1a011d725089604f0bd6b1d9cae000
  Author: Tony Cook <tony@develop-help.com>
  Date:   2020-10-15 (Thu, 15 Oct 2020)

  Changed paths:
    M MANIFEST
    M iperlsys.h
    M pod/perlport.pod
    M pp_sys.c
    M t/op/stat.t
    A t/win32/symlink.t
    M win32/Makefile
    M win32/config.gc
    M win32/config.vc
    M win32/config_H.gc
    M win32/config_H.vc
    M win32/config_h.PL
    M win32/perlhost.h
    M win32/win32.c
    M win32/win32iop.h

  Log Message:
  -----------
  implement symlink() and readlink() on Win32

The API used requires Windows Vista or later, but is called in such
a way that perl can still be used on older Windows.

The API itself requires either elevated privileges or a sufficiently
recent version of Windows 10 running in "Developer Mode", so some
tests require updates.

# Conflicts:
#	win32/win32.c


  Commit: 236104e10bdcd20182fd24ffbc11e7c2af383d92
      https://github.com/Perl/perl5/commit/236104e10bdcd20182fd24ffbc11e7c2af383d92
  Author: Tony Cook <tony@develop-help.com>
  Date:   2020-10-15 (Thu, 15 Oct 2020)

  Changed paths:
    M dist/PathTools/t/cwd.t

  Log Message:
  -----------
  Win32 behaviour with chdir() to a symlink isn't POSIX-like

So we skip it.


  Commit: 6d2eaf48d19247c781a3f8b6310cd11fd9f4b5e2
      https://github.com/Perl/perl5/commit/6d2eaf48d19247c781a3f8b6310cd11fd9f4b5e2
  Author: Tony Cook <tony@develop-help.com>
  Date:   2020-10-15 (Thu, 15 Oct 2020)

  Changed paths:
    M ext/File-Find/t/find.t

  Log Message:
  -----------
  File::Find find.t: switch to done_testing()


  Commit: e56006800aa5c636774b3395e50bb41548b991fc
      https://github.com/Perl/perl5/commit/e56006800aa5c636774b3395e50bb41548b991fc
  Author: Tony Cook <tony@develop-help.com>
  Date:   2020-10-15 (Thu, 15 Oct 2020)

  Changed paths:
    M ext/File-Find/lib/File/Find.pm
    M ext/File-Find/t/find.t
    M ext/File-Find/t/taint.t

  Log Message:
  -----------
  support Win32 symlinks for File::Find

find.t, taint.t: check that symlink() works under the current
permissions/filesystem rather than assuming it will work

find.t: since symlinks are now available, an earlier test block
set $FileFileTests_OK, and the tests in this Win32 block don't use
either of the follow options, which is required for fast file tests.

taint.t: ensure we get / separated names to match File::Find's output


  Commit: 490bfc403a6aea2e7922b10f90cebc745456ad1b
      https://github.com/Perl/perl5/commit/490bfc403a6aea2e7922b10f90cebc745456ad1b
  Author: Tony Cook <tony@develop-help.com>
  Date:   2020-10-15 (Thu, 15 Oct 2020)

  Changed paths:
    M lib/File/Copy.pm
    M lib/File/Copy.t

  Log Message:
  -----------
  File::Copy: support symlinks on Win32


  Commit: 791037b0eff14558bf67a69986f61ffd37dbdd01
      https://github.com/Perl/perl5/commit/791037b0eff14558bf67a69986f61ffd37dbdd01
  Author: Tony Cook <tony@develop-help.com>
  Date:   2020-10-15 (Thu, 15 Oct 2020)

  Changed paths:
    M dist/PathTools/Cwd.pm
    M dist/PathTools/Cwd.xs

  Log Message:
  -----------
  update to use PerlLIO_*


  Commit: 7c5ccb8d3cfe2de968ffd1218299eac43faaaa87
      https://github.com/Perl/perl5/commit/7c5ccb8d3cfe2de968ffd1218299eac43faaaa87
  Author: Tony Cook <tony@develop-help.com>
  Date:   2020-10-15 (Thu, 15 Oct 2020)

  Changed paths:
    M pod/perlport.pod
    M t/win32/stat.t
    M win32/win32.c

  Log Message:
  -----------
  implement our own stat(), and hence our own utime

This fixes at least two problems:

- unlike UCRT, the MSVCRT used for gcc builds has a bug converting
  a FILETIME in an unlike current DST state, returning a time
  offset by an hour.  Fixes GH #6080

- the MSVCRT apparently uses FindFirstFile() to fetch file
  information, but this doesn't follow symlinks(), so stat()
  ends up returning information about the symlink(), not the
  underlying file.  This isn't an issue with the UCRT which
  opens the file as this implementation does.

Currently this code calculates the time_t for st_*time, and the
other way for utime() using a simple multiplication and offset
between time_t and FILETIME values, but this may be incorrect
if leap seconds are enabled.

This code also requires Vista or later.

Some of this is based on code by Tomasz Konojacki (xenu).


  Commit: c30f21f9b458d173762cab47d20a135d8acc52c0
      https://github.com/Perl/perl5/commit/c30f21f9b458d173762cab47d20a135d8acc52c0
  Author: Tony Cook <tony@develop-help.com>
  Date:   2020-10-15 (Thu, 15 Oct 2020)

  Changed paths:
    M win32/win32.c

  Log Message:
  -----------
  re-work FILETIME <=> time_t conversions

Current versions of Windows claim to support leap seconds, but the
time conversion I was using ignores that possibility.

Switch to using APIs (FileTimeToSystemTime() and SystemTimeToFileTime())
that are documented to support leap seconds that might be included
in a FILETIME.


  Commit: ca1602d3b70786c3761af7bb949c4b82e88f6ea8
      https://github.com/Perl/perl5/commit/ca1602d3b70786c3761af7bb949c4b82e88f6ea8
  Author: Tony Cook <tony@develop-help.com>
  Date:   2020-10-15 (Thu, 15 Oct 2020)

  Changed paths:
    M win32/win32.c

  Log Message:
  -----------
  win32 symlink: only use the unprivileged flag if windows is new enough


  Commit: 73eaf95b765cfc6d71f7a014da0e3c93fe3a7e03
      https://github.com/Perl/perl5/commit/73eaf95b765cfc6d71f7a014da0e3c93fe3a7e03
  Author: Tony Cook <tony@develop-help.com>
  Date:   2020-10-15 (Thu, 15 Oct 2020)

  Changed paths:
    M mg.c
    M pod/perlvar.pod
    M win32/win32.c
    M win32/win32.h

  Log Message:
  -----------
  remove ${^WIN32_SLOPPY_STAT}

The new implementation, like the UCRT implementation, always
opens the specified file.


  Commit: 75e135f2bff95e21bef1e1671c152442093fe65a
      https://github.com/Perl/perl5/commit/75e135f2bff95e21bef1e1671c152442093fe65a
  Author: Tony Cook <tony@develop-help.com>
  Date:   2020-10-15 (Thu, 15 Oct 2020)

  Changed paths:
    M pod/perlport.pod
    M t/win32/stat.t
    M t/win32/symlink.t
    M win32/win32.c

  Log Message:
  -----------
  lstat(), readlink() and unlink() treat directory junctions as symlinks


Compare: https://github.com/Perl/perl5/compare/0197a0bd3791%5E...75e135f2bff9



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About