Merge remote-tracking branch 'dpavlin/master'
authorBojan Petrovic <bojan_petrovic@fastmail.fm>
Sat, 21 May 2011 18:31:40 +0000 (20:31 +0200)
committerBojan Petrovic <bojan_petrovic@fastmail.fm>
Sat, 21 May 2011 18:31:40 +0000 (20:31 +0200)
Conflicts:
Fuse.xs

Fuse.xs
examples/loopback_t.pl

diff --git a/Fuse.xs b/Fuse.xs
index 01fcafb..f86995d 100755 (executable)
--- a/Fuse.xs
+++ b/Fuse.xs
@@ -3,18 +3,14 @@
 #include "perl.h"
 #include "XSUB.h"
 
-/*
- * XXX: Fuse on FreeBSD does not support extended attributes (see
- * /usr/local/share/doc/fusefs/kmod/doc.text). Also, 'extattr_set_file' syscall
- * declared in 'sys/extattr.h' does not accept any flags. We could either skip
- * defining XATTR_CREATE and XATTR_REPLACE constants (as further below, and
- * which breaks their usage if Perl module exports them), set them to some
- * dummy values, or not allow them to be exported at all on FreeBSD.
- */
-#ifndef __FreeBSD__
+#include <fuse.h>
+
+#if defined(__FreeBSD__) || defined(__NetBSD__)
+# define XATTR_CREATE 1
+# define XATTR_REPLACE 2
+#else
 # include <sys/xattr.h>
 #endif
-#include <fuse.h>
 
 /* Determine if threads support should be included */
 #ifdef USE_ITHREADS
index 8302aa8..1d8fb46 100755 (executable)
@@ -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);
+use Fcntl qw(S_ISBLK S_ISCHR S_ISFIFO SEEK_SET S_ISREG);
 my $can_syscall = eval {
        require 'syscall.ph'; # for SYS_mknod and SYS_lchown
 };
@@ -122,6 +122,12 @@ sub x_mknod {
        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;
+       }
        syscall(&SYS_mknod,$file,$modes,$dev);
        return -$!;
 }