-
Notifications
You must be signed in to change notification settings - Fork 561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
File::Find: account for WSL; tidy assignment to dont_use_nlink #15748
Comments
From @jkeenanCreated by @jkeenanThis RT incorporates and builds upon discussion initiated by Thorsten Thorsten wrote: "As per discussion here "File::Find sees that $^O is 'linux' and uses nlink, which doesn't work. Discussion on the mailing list included feedback on the code from Uri Please review. (As we gain experience with WSL, we should in the future consider Thank you very much. Jim Keenan Perl Info
|
From @jkeenan0001-Account-for-WSL-in-assignment-to-dont_use_nlink.patchFrom 02bf7330deeaa5dbc41d5c6d89a80d2c31e08c6b Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Sun, 4 Dec 2016 08:47:26 -0500
Subject: [PATCH] Account for WSL in assignment to dont_use_nlink.
File::Find sees that $^O is 'linux' and uses nlink, which doesn't work.
Identify and account for Windows Subsystem on Linux (WSL).
Problem reported and revisions submitted by Thorsten Behrens on p5p list.
Incorporate suggestions by Uri Guttman.
---
AUTHORS | 1 +
ext/File-Find/lib/File/Find.pm | 34 +++++++++++++++++++++++-----------
2 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/AUTHORS b/AUTHORS
index b341532..a72cbc2 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1187,6 +1187,7 @@ Thomas König
Thomas Pfau <pfau@nbpfaus.net>
Thomas Sibley <tsibley@cpan.org>
Thomas Wegner <wegner_thomas@yahoo.com>
+Thorsten Behrens <tbehrens@outlook.com>
Thorsten Glaser <tg@mirbsd.org>
Tim Adye <T.J.Adye@rl.ac.uk>
Tim Ayers <tayers@bridge.com>
diff --git a/ext/File-Find/lib/File/Find.pm b/ext/File-Find/lib/File/Find.pm
index 03dac9f..67668e8 100644
--- a/ext/File-Find/lib/File/Find.pm
+++ b/ext/File-Find/lib/File/Find.pm
@@ -3,7 +3,7 @@ use 5.006;
use strict;
use warnings;
use warnings::register;
-our $VERSION = '1.34';
+our $VERSION = '1.35';
require Exporter;
require Cwd;
@@ -14,6 +14,7 @@ our @EXPORT = qw(find finddepth);
use strict;
my $Is_VMS;
my $Is_Win32;
+my $Is_Microsoft_WSL;
require File::Basename;
require File::Spec;
@@ -770,21 +771,32 @@ sub finddepth {
$File::Find::skip_pattern = qr/^\.{1,2}\z/;
$File::Find::untaint_pattern = qr|^([-+@\w./]+)$|;
-# These are hard-coded for now, but may move to hint files.
-if ($^O eq 'VMS') {
- $Is_VMS = 1;
- $File::Find::dont_use_nlink = 1;
-}
-elsif ($^O eq 'MSWin32') {
- $Is_Win32 = 1;
-}
-
# this _should_ work properly on all platforms
# where File::Find can be expected to work
$File::Find::current_dir = File::Spec->curdir || '.';
+sub _microsoft_wsl_check {
+ return 0 unless $^O eq 'linux';
+ open my $pv, '<', '/proc/version' or die "Can't open < /proc/version: $!";
+ # Expecting /proc/version to look like this:
+ # Linux version 3.4.0-Microsoft (Microsoft@Microsoft.com) (gcc version 4.7 (GCC) ) #1 SMP PREEMPT Wed Dec 31 14:42:53 PST 2014
+ my $lv = <$pv>;
+
+ # If we locate either 'Microsoft' or 'WSL' (Windows Subsystem for Linux)
+ # in the string, we infer that we are on WSL. See:
+ # https://msdn.microsoft.com/en-us/commandline/wsl/about
+
+ return 1 if (index($lv,'Microsoft') != -1 || index($lv,'WSL') != -1);
+ return 0;
+}
+
+$Is_VMS = 1 if ($^O eq 'VMS');
+$Is_Win32 = 1 if ($^O eq 'MSWin32');
+$Is_Microsoft_WSL = 1 if _microsoft_wsl_check();
+
$File::Find::dont_use_nlink = 1
- if $^O eq 'os2' || $^O eq 'dos' || $^O eq 'amigaos' || $Is_Win32 ||
+ if $^O eq 'os2' || $^O eq 'dos' || $^O eq 'amigaos' ||
+ $Is_Win32 || $Is_VMS || $Is_Microsoft_WSL ||
$^O eq 'interix' || $^O eq 'cygwin' || $^O eq 'qnx' || $^O eq 'nto';
# Set dont_use_nlink in your hint file if your system's stat doesn't
--
2.7.4
|
From @jkeenanOn Sun, 04 Dec 2016 14:01:55 GMT, jkeen@verizon.net wrote:
Available for smoke-testing in this branch: smoke-me/jkeenan/130258-file-find-wls Reports from VMS, Win32 and WLS would be appreciated. Thank you very much. -- |
The RT System itself - Status changed from 'new' to 'open' |
From tbehrens@outlook.comCreated by @jkeenanThis RT incorporates and builds upon discussion initiated by Thorsten Thorsten wrote: "As per discussion here "File::Find sees that $^O is 'linux' and uses nlink, which doesn't work. Discussion on the mailing list included feedback on the code from Uri Please review. (As we gain experience with WSL, we should in the future consider Thank you very much. Jim Keenan Perl Info
|
From @jkeenanOn Sun, 04 Dec 2016 16:52:16 GMT, tbehrens@outlook.com wrote:
Yes, I didn't see this morning's discussion on list until after I had created this ticket. I will review the discussion and your revised subroutine.
-- |
From @jkeenanOn Sun, 04 Dec 2016 21:12:10 GMT, jkeenan wrote:
Supplementary patch file attached and committed to the branch mentioned earlier. -- |
From @jkeenan0002-Don-t-die-if-unable-to-open-proc-version.patchFrom b5d3735edaf1ce4d6df342a84098adf26cb828ec Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Sun, 4 Dec 2016 16:52:25 -0500
Subject: [PATCH 2/2] Don't die if unable to open /proc/version.
As some Linuxes may not have that file.
---
ext/File-Find/lib/File/Find.pm | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/ext/File-Find/lib/File/Find.pm b/ext/File-Find/lib/File/Find.pm
index 67668e8..822868d 100644
--- a/ext/File-Find/lib/File/Find.pm
+++ b/ext/File-Find/lib/File/Find.pm
@@ -777,16 +777,17 @@ $File::Find::current_dir = File::Spec->curdir || '.';
sub _microsoft_wsl_check {
return 0 unless $^O eq 'linux';
- open my $pv, '<', '/proc/version' or die "Can't open < /proc/version: $!";
- # Expecting /proc/version to look like this:
- # Linux version 3.4.0-Microsoft (Microsoft@Microsoft.com) (gcc version 4.7 (GCC) ) #1 SMP PREEMPT Wed Dec 31 14:42:53 PST 2014
- my $lv = <$pv>;
+ if (open my $pv, '<', '/proc/version') {
+ # Expecting /proc/version to look like this:
+ # Linux version 3.4.0-Microsoft (Microsoft@Microsoft.com) (gcc version 4.7 (GCC) ) #1 SMP PREEMPT Wed Dec 31 14:42:53 PST 2014
+ my $lv = <$pv>;
- # If we locate either 'Microsoft' or 'WSL' (Windows Subsystem for Linux)
- # in the string, we infer that we are on WSL. See:
- # https://msdn.microsoft.com/en-us/commandline/wsl/about
+ # If we locate either 'Microsoft' or 'WSL' (Windows Subsystem for Linux)
+ # in the string, we infer that we are on WSL. See:
+ # https://msdn.microsoft.com/en-us/commandline/wsl/about
- return 1 if (index($lv,'Microsoft') != -1 || index($lv,'WSL') != -1);
+ return 1 if (index($lv,'Microsoft') != -1 || index($lv,'WSL') != -1);
+ }
return 0;
}
--
2.7.4
|
From tbehrens@outlook.comPlease put this work on hold. Microsoft may fix it on their end in the WSL layer. WSL bug 910 (microsoft/WSL#910), which is directly related to this, is marked as "fixinbound". This means MS believes they have a fix and it will become available in a future test build, called "Insider" builds, at which point it will be marked "fixed". Yours Thorsten Behrens |
@jkeenan - Status changed from 'open' to 'stalled' |
From tbehrens@outlook.comThis issue has been resolved by Microsoft by changing the links count returned from “always 2” to “always 0”. See microsoft/WSL#910 . This patch can be shelved. GA of the fixed Windows/WSL code is expected in Q1, likely sometime February 2017. |
The RT System itself - Status changed from 'stalled' to 'open' |
@jkeenan - Status changed from 'open' to 'stalled' |
From @xsawyerxThis can be resolved as already fixed without applying the patch. Please http://nntp.perl.org/group/perl.perl5.porters/241446 On 12/04/2016 11:03 PM, James E Keenan via RT wrote:
|
The RT System itself - Status changed from 'stalled' to 'open' |
@jkeenan - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#130258 (status was 'resolved')
Searchable as RT130258$
The text was updated successfully, but these errors were encountered: