Skip to content
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

Issues on Windows Drives (fatal error: System Volume Information: Invalid argument) #36

Open
LeeThompson opened this issue May 29, 2019 · 6 comments

Comments

@LeeThompson
Copy link

Using File::Next in a script to catalog files on USB mounted drives and I'm getting this fatal error:

M:\System Volume Information: Invalid argument at C:/Perl/site/lib/File/Next.pm line 250.

(M is the external drive map).

The code is fairly simple:

$iteration = File::Next::files( { descend_filter => sub{1}, sort_files => 1}, $source_folder );
...
while ( defined ( $source_file = $iteration->() ) ) {

@petdance
Copy link
Owner

What's line 250?

I'm going to have to rely on someone on Windows to figure this out.

(Also, as an aside, you can leave out the descend_filter => sub{1} because that's its default.)

@petdance
Copy link
Owner

Can you please post a simplified version of the code that reproduces the error, and post the entire program, and then also include use Carp::Always; and then paste an entire failing set of output? Maybe we can figure this out, even though I'm not on Windows.

@LeeThompson
Copy link
Author

LeeThompson commented May 29, 2019

@petdance done -- see next comment.

C:/Perl/site/lib/File/Next.pm line 250:
error_handler => sub { CORE::die $_[0] },

More information though:

I was able to work around the issue, for now, with this change to the descend filter:

my $descend_filter = sub { $_ ne "\$RECYCLE.BIN" && $_ ne "System Volume Information" };
...
$iteration = File::Next::files( { descend_filter => $descend_filter, sort_files => 1}, $source_folder );

What's throwing the error with File::Next is the user (even administrator) does not have permission to look inside the "System Volume Information" folder (which is hidden).

The permissions set on the folder is "SYSTEM" and nothing else so when Next.pm tries to do anything with it, it will croak.

However, this will occur on any Windows NTFS formatted drive when traversing the root folder.

It might be easiest in File::Next to simply have descend_filter default to filter out "System Volume Information" folders by default on Windows.

@LeeThompson
Copy link
Author

Test Script:

(M: in this case is a USB WD Passport drive formatted as NTFS on a Windows 7 system)

use Carp::Always;
use File::Next;					
use File::Basename;				
use strict;

my $source_folder = "M:\\";       # Root of any Windows NTFS Drive
my $iteration;
my $source_file;


$iteration = File::Next::files( { sort_files => 1}, $source_folder );

while ( defined ( $source_file = $iteration->() ) ) {
	print "$source_file\n";
}

stderr:

M:\System Volume Information: Invalid argument at C:/Perl/site/lib/File/Next.pm line 250.
	File::Next::__ANON__("M:\\System Volume Information: Invalid argument", 22) called at C:/Perl/site/lib/File/Next.pm line 476
	File::Next::_candidate_files(HASH(0x2ccf9c), "M:\\System Volume Information") called at C:/Perl/site/lib/File/Next.pm line 278
	File::Next::__ANON__() called at filenext.pl line 14

@petdance
Copy link
Owner

It might be easiest in File::Next to simply have descend_filter default to filter out "System Volume Information" folders by default on Windows.

I don't want to go down that road of making changes to behavior based on install. However, I do think that this is important info and would be good to have in the documentation somewhere.

I will write it up at some point to put in the docs, or if you can that would be great, too. I think that most of what we'd want to have in the docs is in this ticket.

Do you know if this problem you ran into is only on certain versions of Windows?

@LeeThompson
Copy link
Author

LeeThompson commented May 30, 2019

This will likely occur on any NTFS formatted drive (although a mounted NTFS drive on *nix will probably ignore the Windows permissions). (I think the folder's been in use since at least Windows XP, possibly earlier.)

For some more info on it: MSDN Devblog article from 2003

(It will also likely occur on *nix if any directory or file doesn't allow the script to open/look at it but I haven't tested for that specifically.)

(I renamed the issue with the error message to help with searching.)

@LeeThompson LeeThompson changed the title Issues on Windows Drives Issues on Windows Drives (fatal error: System Volume Information: Invalid argument) May 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants