From 1f842c996e46788115d6b5ca142fad949712c8e9 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Wed, 15 May 2019 14:35:57 -0600 Subject: 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. --- example/passthrough.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'example/passthrough.c') 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 #include #include +#ifdef __FreeBSD__ +#include +#include +#endif #include #ifdef HAVE_SETXATTR #include #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; -- cgit v1.2.3