GithubHelp home page GithubHelp logo

Comments (12)

toddr avatar toddr commented on May 27, 2024

1 would be EPERM instead of EISDIR.

I'm getting this on centos. What do you get?

$>perl -MFile::Temp=tempdir -e'my $t = tempdir( CLEANUP => 1 ); unlink $t; print "Got: " . ($! +0) . " - $!\n"' 
Got: 21 - Is a directory

Is it possible your /tmp is setup wrong or that $TMP is set to something funny?

from test-mockfile.

eserte avatar eserte commented on May 27, 2024

I have now a truss log of a failed run. The interesting lines:

71712: 0.356629683 0.000124038 mkdir("/tmp/7EjVXM5y2G",0700) = 0 (0x0)
71712: 0.356824121 0.000006146 stat("/tmp/7EjVXM5y2G",{ mode=drwx------ ,inode=81848,size=512,blksize=32768 }) = 0 (0x0)
71712: 0.367991462 0.000013130 unlink("/tmp/7EjVXM5y2G") ERR#1 'Operation not permitted'

That's correct, unlink on directories is forbidden. From the unlink(2) manpage:

     [EPERM]            The named file is a directory.

from test-mockfile.

toddr avatar toddr commented on May 27, 2024

I'm trying to decide how big of a problem this is going to be. If it's going to be a frequent problem, then I have to determine what these values will be at Makfile.PL time and then bake it into the module.

My other option would be to do a one off exception for $^X eq 'freebsd' but it sounds like you're saying only very specific versions of freebsd behave this way?

from test-mockfile.

toddr avatar toddr commented on May 27, 2024

Let's try 1e18f8a for a fix in 0.012

from test-mockfile.

eserte avatar eserte commented on May 27, 2024

Hmmm, I still get the same errors in 0.012.

And it seems that this problem is not freebsd-specific --- the same failure happens also on other BSD systems (NetBSD), and even Debian with FreeBSD kernel (see http://matrix.cpantesters.org/?dist=Test-MockFile%200.011 ). Also, there are no reports at all for recent Test-MockFile versions on darwin --- I guess it could happen there, too.

from test-mockfile.

eserte avatar eserte commented on May 27, 2024

BTW, the oneliner above prints also errno 21 on a FreeBSD 13 system with perl 5.26.2:

$ perl -MFile::Temp=tempdir -e'my $t = tempdir( CLEANUP => 1 ); warn "about to unlink\n"; unlink $t; warn "Got: " . ($! +0) . " - $!\n"' 
about to unlink
Got: 21 - Is a directory

But the truss log is interesting:

59591: 0.215535940 0.000123740 write(2,"about to unlink\n",16) = 16 (0x10)
59591: 0.215628960 0.000020820 fstatat(AT_FDCWD,"/tmp/rpFZl9wT6c",{ mode=drwx------ ,inode=212,size=2,blksize=131072 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
59591: 0.215732180 0.000035070 fstatat(AT_FDCWD,"/usr/share/nls/C/libc.cat",0x7fffffffe340,0x0) ERR#2 'No such file or directory'
59591: 0.215795310 0.000018940 fstatat(AT_FDCWD,"/usr/share/nls/libc/C",0x7fffffffe340,0x0) ERR#2 'No such file or directory'
59591: 0.215857350 0.000020320 fstatat(AT_FDCWD,"/usr/local/share/nls/C/libc.cat",0x7fffffffe340,0x0) ERR#2 'No such file or directory'
59591: 0.215917220 0.000018780 fstatat(AT_FDCWD,"/usr/local/share/nls/libc/C",0x7fffffffe340,0x0) ERR#2 'No such file or directory'
59591: 0.216081980 0.000097270 write(2,"Got: 21 - Is a directory\n",25) = 25 (0x19)

So it looks like unlink() isn't called at all, but only a stat call instead; maybe the result of this call is inspected and turned into an "artificial" errno 21.

from test-mockfile.

eserte avatar eserte commented on May 27, 2024

The behavior changed between perl 5.18 and 5.20. On a freebsd 9 system:

for i in /usr/perl*/bin/perl; do env LC_ALL=C $i -MFile::Temp=tempdir -e'my $t = tempdir( CLEANUP => 1 ); unlink $t; warn "$]: Got: " . ($! +0) . " - $!\n"'; done
5.010001: Got: 1 - Operation not permitted
5.014004: Got: 1 - Operation not permitted
5.016003: Got: 1 - Operation not permitted
5.018002: Got: 1 - Operation not permitted
5.020000: Got: 21 - Is a directory
5.008009: Got: 1 - Operation not permitted

And on a freebsd 10 system:

for i in /usr/perl*/bin/perl; do env LC_ALL=C $i -MFile::Temp=tempdir -e'my $t = tempdir( CLEANUP => 1 ); unlink $t; warn "$]: Got: " . ($! +0) . " - $!\n"'; done
5.018004: Got: 1 - Operation not permitted
5.020001: Got: 21 - Is a directory
5.020001: Got: 21 - Is a directory
5.020002: Got: 21 - Is a directory
5.020003: Got: 21 - Is a directory
5.022000: Got: 21 - Is a directory
5.022001: Got: 21 - Is a directory
5.022002: Got: 21 - Is a directory
5.022002: Got: 21 - Is a directory
5.022003: Got: 21 - Is a directory
5.022004: Got: 21 - Is a directory
5.024000: Got: 21 - Is a directory
5.024001: Got: 21 - Is a directory
5.024002: Got: 21 - Is a directory
5.024003: Got: 21 - Is a directory
5.026000: Got: 21 - Is a directory
5.026001: Got: 21 - Is a directory
5.027010: Got: 21 - Is a directory
5.027011: Got: 21 - Is a directory
5.027006: Got: 21 - Is a directory
5.027007: Got: 21 - Is a directory
5.027008: Got: 21 - Is a directory
5.027009: Got: 21 - Is a directory
5.028000: Got: 21 - Is a directory

from test-mockfile.

eserte avatar eserte commented on May 27, 2024

Also, there are no reports at all for recent Test-MockFile versions on darwin --- I guess it could happen there, too.

Yes. EPERM is also returned on Mac systems with system perl (currently 5.18.2), see https://travis-ci.org/eserte/sandbox/jobs/456396139
Test script was: https://github.com/eserte/sandbox/blob/daea395b488369cc935392025ebc3f75927e2cfe/t/unlink-dir.t#L19

from test-mockfile.

toddr avatar toddr commented on May 27, 2024

Yeah this was just a test. I’ve already concluded that I’m going to have to template the module before install

from test-mockfile.

toddr avatar toddr commented on May 27, 2024

I think the final fix for this is 4ee9f77 It would have helped had I had access to BSD ¯_(ツ)_/¯

from test-mockfile.

toddr avatar toddr commented on May 27, 2024

There are test changes but the entirety of the fix is basically this conditional. https://github.com/CpanelInc/Test-MockFile/blob/master/lib/Test/MockFile.pm#L625

from test-mockfile.

eserte avatar eserte commented on May 27, 2024

0.016 looks good on (almost) all of my FreeBSD & darwin systems. The "almost" is a different issue.

I think this issue may be closed.

from test-mockfile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.