summaryrefslogtreecommitdiff
path: root/example/passthrough.c
diff options
context:
space:
mode:
authorAlan Somers <asomers@gmail.com>2019-05-15 14:35:57 -0600
committerNikolaus Rath <Nikolaus@rath.org>2019-05-15 21:35:57 +0100
commit1f842c996e46788115d6b5ca142fad949712c8e9 (patch)
tree2a070544cd76fad641913c2b9a489712fc99e012 /example/passthrough.c
parent7a5e1a9a9a61416c759ce02a48e600814fd13711 (diff)
downloadfuse-1f842c996e46788115d6b5ca142fad949712c8e9.tar.gz
passthrough: fix unix-domain sockets on FreeBSD (#413)
FreeBSD doesn't allow creating sockets using mknod(2). Instead, one has to use socket(2) and bind(2). Add appropriate logic to the examples and add a test case.
Diffstat (limited to 'example/passthrough.c')
-rw-r--r--example/passthrough.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/example/passthrough.c b/example/passthrough.c
index da91930..6de9fc1 100644
--- a/example/passthrough.c
+++ b/example/passthrough.c
@@ -44,11 +44,17 @@
#include <sys/stat.h>
#include <dirent.h>
#include <errno.h>
+#ifdef __FreeBSD__
+#include <sys/socket.h>
+#include <sys/un.h>
+#endif
#include <sys/time.h>
#ifdef HAVE_SETXATTR
#include <sys/xattr.h>
#endif
+#include "passthrough_helpers.h"
+
static void *xmp_init(struct fuse_conn_info *conn,
struct fuse_config *cfg)
{
@@ -138,16 +144,7 @@ static int xmp_mknod(const char *path, mode_t mode, dev_t rdev)
{
int res;
- /* On Linux this could just be 'mknod(path, mode, rdev)' but this
- is more portable */
- if (S_ISREG(mode)) {
- res = open(path, O_CREAT | O_EXCL | O_WRONLY, mode);
- if (res >= 0)
- res = close(res);
- } else if (S_ISFIFO(mode))
- res = mkfifo(path, mode);
- else
- res = mknod(path, mode, rdev);
+ res = mknod_wrapper(AT_FDCWD, path, NULL, mode, rdev);
if (res == -1)
return -errno;