Circumvent buggy negation of assigned $!.
authorBojan Petrovic <bojan_petrovic@fastmail.fm>
Tue, 24 May 2011 21:00:43 +0000 (05:00 +0800)
committerDerrik Pates <demon@now.ai>
Thu, 26 May 2011 18:36:09 +0000 (02:36 +0800)
Loopback fs fails to create a new file every other time on FreeBSD.
This happens because of a Perl bug which occurs when $! is set from Perl
(as in x_mknod()), and then negated after a failed syscall (as in
x_getattr()). See http://www.perlmonks.org/?node_id=906466.

examples/loopback_t.pl

index 0e72261..db03fb9 100755 (executable)
@@ -121,7 +121,7 @@ sub x_mknod {
        # and possibly run the real mknod command.
        my ($file, $modes, $dev) = @_;
        $file = fixup($file);
-       $! = 0;
+       undef $!;
        if ($^O eq 'freebsd') {
                if (S_ISREG($modes)) {
                        open(FILE, '>', $file) || return -$!;