X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=examples%2Floopback_t.pl;h=db03fb9fce65e4e81109013c53b461936b66b389;hb=3bdd22cf0cf94b4feb0646a45f64bc8c7abfc792;hp=1d8fb4622bf6073d29f0b9674eb4348bb941642b;hpb=a78f9d71bb9c991872a435936d468b10ff6259c2;p=perl-fuse.git diff --git a/examples/loopback_t.pl b/examples/loopback_t.pl index 1d8fb46..db03fb9 100755 --- a/examples/loopback_t.pl +++ b/examples/loopback_t.pl @@ -7,7 +7,7 @@ use blib; use Fuse; use IO::File; use POSIX qw(ENOENT ENOSYS EEXIST EPERM O_RDONLY O_RDWR O_APPEND O_CREAT); -use Fcntl qw(S_ISBLK S_ISCHR S_ISFIFO SEEK_SET S_ISREG); +use Fcntl qw(S_ISBLK S_ISCHR S_ISFIFO SEEK_SET S_ISREG S_ISFIFO S_IMODE); my $can_syscall = eval { require 'syscall.ph'; # for SYS_mknod and SYS_lchown }; @@ -121,12 +121,17 @@ sub x_mknod { # and possibly run the real mknod command. my ($file, $modes, $dev) = @_; $file = fixup($file); - $! = 0; - if ($^O eq 'freebsd' && S_ISREG($modes)) { - open(FILE, '>', $file) || return -$!; - print FILE ""; - close(FILE); - return 0; + undef $!; + if ($^O eq 'freebsd') { + if (S_ISREG($modes)) { + open(FILE, '>', $file) || return -$!; + print FILE ""; + close(FILE); + return 0; + } elsif (S_ISFIFO($modes)) { + my ($rv) = POSIX::mkfifo($file, S_IMODE($modes)); + return $rv ? 0 : -POSIX::errno(); + } } syscall(&SYS_mknod,$file,$modes,$dev); return -$!;