#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
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
};
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 -$!;
}