yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
ddf19c
From 9d3788b1c2fa5cb4f14e292232a05c6a5217802d Mon Sep 17 00:00:00 2001
ddf19c
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
ddf19c
Date: Mon, 27 Jan 2020 19:00:44 +0100
ddf19c
Subject: [PATCH 013/116] virtiofsd: Trim down imported files
ddf19c
MIME-Version: 1.0
ddf19c
Content-Type: text/plain; charset=UTF-8
ddf19c
Content-Transfer-Encoding: 8bit
ddf19c
ddf19c
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
ddf19c
Message-id: <20200127190227.40942-10-dgilbert@redhat.com>
ddf19c
Patchwork-id: 93463
ddf19c
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 009/112] virtiofsd: Trim down imported files
ddf19c
Bugzilla: 1694164
ddf19c
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
ddf19c
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ddf19c
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
ddf19c
ddf19c
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
ddf19c
ddf19c
There's a lot of the original fuse code we don't need; trim them down.
ddf19c
ddf19c
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
ddf19c
with additional trimming by:
ddf19c
Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
ddf19c
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
ddf19c
Reviewed-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
ddf19c
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
ddf19c
(cherry picked from commit a3e23f325439a290c504d6bbc48c2e742149ecab)
ddf19c
ddf19c
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ddf19c
---
ddf19c
 tools/virtiofsd/buffer.c              |  71 +---
ddf19c
 tools/virtiofsd/fuse.h                |  46 ---
ddf19c
 tools/virtiofsd/fuse_common.h         |  32 --
ddf19c
 tools/virtiofsd/fuse_i.h              |  41 ---
ddf19c
 tools/virtiofsd/fuse_log.h            |   8 -
ddf19c
 tools/virtiofsd/fuse_lowlevel.c       | 675 +---------------------------------
ddf19c
 tools/virtiofsd/fuse_lowlevel.h       |  28 --
ddf19c
 tools/virtiofsd/fuse_opt.h            |   8 -
ddf19c
 tools/virtiofsd/helper.c              | 143 -------
ddf19c
 tools/virtiofsd/passthrough_helpers.h |  26 --
ddf19c
 tools/virtiofsd/passthrough_ll.c      |   1 -
ddf19c
 11 files changed, 8 insertions(+), 1071 deletions(-)
ddf19c
ddf19c
diff --git a/tools/virtiofsd/buffer.c b/tools/virtiofsd/buffer.c
ddf19c
index 5ab9b87..aefb7db 100644
ddf19c
--- a/tools/virtiofsd/buffer.c
ddf19c
+++ b/tools/virtiofsd/buffer.c
ddf19c
@@ -157,73 +157,6 @@ static ssize_t fuse_buf_fd_to_fd(const struct fuse_buf *dst, size_t dst_off,
ddf19c
 	return copied;
ddf19c
 }
ddf19c
 
ddf19c
-#ifdef HAVE_SPLICE
ddf19c
-static ssize_t fuse_buf_splice(const struct fuse_buf *dst, size_t dst_off,
ddf19c
-			       const struct fuse_buf *src, size_t src_off,
ddf19c
-			       size_t len, enum fuse_buf_copy_flags flags)
ddf19c
-{
ddf19c
-	int splice_flags = 0;
ddf19c
-	off_t *srcpos = NULL;
ddf19c
-	off_t *dstpos = NULL;
ddf19c
-	off_t srcpos_val;
ddf19c
-	off_t dstpos_val;
ddf19c
-	ssize_t res;
ddf19c
-	size_t copied = 0;
ddf19c
-
ddf19c
-	if (flags & FUSE_BUF_SPLICE_MOVE)
ddf19c
-		splice_flags |= SPLICE_F_MOVE;
ddf19c
-	if (flags & FUSE_BUF_SPLICE_NONBLOCK)
ddf19c
-		splice_flags |= SPLICE_F_NONBLOCK;
ddf19c
-
ddf19c
-	if (src->flags & FUSE_BUF_FD_SEEK) {
ddf19c
-		srcpos_val = src->pos + src_off;
ddf19c
-		srcpos = &srcpos_val;
ddf19c
-	}
ddf19c
-	if (dst->flags & FUSE_BUF_FD_SEEK) {
ddf19c
-		dstpos_val = dst->pos + dst_off;
ddf19c
-		dstpos = &dstpos_val;
ddf19c
-	}
ddf19c
-
ddf19c
-	while (len) {
ddf19c
-		res = splice(src->fd, srcpos, dst->fd, dstpos, len,
ddf19c
-			     splice_flags);
ddf19c
-		if (res == -1) {
ddf19c
-			if (copied)
ddf19c
-				break;
ddf19c
-
ddf19c
-			if (errno != EINVAL || (flags & FUSE_BUF_FORCE_SPLICE))
ddf19c
-				return -errno;
ddf19c
-
ddf19c
-			/* Maybe splice is not supported for this combination */
ddf19c
-			return fuse_buf_fd_to_fd(dst, dst_off, src, src_off,
ddf19c
-						 len);
ddf19c
-		}
ddf19c
-		if (res == 0)
ddf19c
-			break;
ddf19c
-
ddf19c
-		copied += res;
ddf19c
-		if (!(src->flags & FUSE_BUF_FD_RETRY) &&
ddf19c
-		    !(dst->flags & FUSE_BUF_FD_RETRY)) {
ddf19c
-			break;
ddf19c
-		}
ddf19c
-
ddf19c
-		len -= res;
ddf19c
-	}
ddf19c
-
ddf19c
-	return copied;
ddf19c
-}
ddf19c
-#else
ddf19c
-static ssize_t fuse_buf_splice(const struct fuse_buf *dst, size_t dst_off,
ddf19c
-			       const struct fuse_buf *src, size_t src_off,
ddf19c
-			       size_t len, enum fuse_buf_copy_flags flags)
ddf19c
-{
ddf19c
-	(void) flags;
ddf19c
-
ddf19c
-	return fuse_buf_fd_to_fd(dst, dst_off, src, src_off, len);
ddf19c
-}
ddf19c
-#endif
ddf19c
-
ddf19c
-
ddf19c
 static ssize_t fuse_buf_copy_one(const struct fuse_buf *dst, size_t dst_off,
ddf19c
 				 const struct fuse_buf *src, size_t src_off,
ddf19c
 				 size_t len, enum fuse_buf_copy_flags flags)
ddf19c
@@ -247,10 +180,8 @@ static ssize_t fuse_buf_copy_one(const struct fuse_buf *dst, size_t dst_off,
ddf19c
 		return fuse_buf_write(dst, dst_off, src, src_off, len);
ddf19c
 	} else if (!dst_is_fd) {
ddf19c
 		return fuse_buf_read(dst, dst_off, src, src_off, len);
ddf19c
-	} else if (flags & FUSE_BUF_NO_SPLICE) {
ddf19c
-		return fuse_buf_fd_to_fd(dst, dst_off, src, src_off, len);
ddf19c
 	} else {
ddf19c
-		return fuse_buf_splice(dst, dst_off, src, src_off, len, flags);
ddf19c
+		return fuse_buf_fd_to_fd(dst, dst_off, src, src_off, len);
ddf19c
 	}
ddf19c
 }
ddf19c
 
ddf19c
diff --git a/tools/virtiofsd/fuse.h b/tools/virtiofsd/fuse.h
ddf19c
index 883f6e5..3202fba 100644
ddf19c
--- a/tools/virtiofsd/fuse.h
ddf19c
+++ b/tools/virtiofsd/fuse.h
ddf19c
@@ -25,10 +25,6 @@
ddf19c
 #include <sys/statvfs.h>
ddf19c
 #include <sys/uio.h>
ddf19c
 
ddf19c
-#ifdef __cplusplus
ddf19c
-extern "C" {
ddf19c
-#endif
ddf19c
-
ddf19c
 /* ----------------------------------------------------------- *
ddf19c
  * Basic FUSE API					       *
ddf19c
  * ----------------------------------------------------------- */
ddf19c
@@ -979,44 +975,6 @@ int fuse_loop(struct fuse *f);
ddf19c
 void fuse_exit(struct fuse *f);
ddf19c
 
ddf19c
 /**
ddf19c
- * FUSE event loop with multiple threads
ddf19c
- *
ddf19c
- * Requests from the kernel are processed, and the appropriate
ddf19c
- * operations are called.  Request are processed in parallel by
ddf19c
- * distributing them between multiple threads.
ddf19c
- *
ddf19c
- * For a description of the return value and the conditions when the
ddf19c
- * event loop exits, refer to the documentation of
ddf19c
- * fuse_session_loop().
ddf19c
- *
ddf19c
- * Note: using fuse_loop() instead of fuse_loop_mt() means you are running in
ddf19c
- * single-threaded mode, and that you will not have to worry about reentrancy,
ddf19c
- * though you will have to worry about recursive lookups. In single-threaded
ddf19c
- * mode, FUSE will wait for one callback to return before calling another.
ddf19c
- *
ddf19c
- * Enabling multiple threads, by using fuse_loop_mt(), will cause FUSE to make
ddf19c
- * multiple simultaneous calls into the various callback functions given by your
ddf19c
- * fuse_operations record.
ddf19c
- *
ddf19c
- * If you are using multiple threads, you can enjoy all the parallel execution
ddf19c
- * and interactive response benefits of threads, and you get to enjoy all the
ddf19c
- * benefits of race conditions and locking bugs, too. Ensure that any code used
ddf19c
- * in the callback function of fuse_operations is also thread-safe.
ddf19c
- *
ddf19c
- * @param f the FUSE handle
ddf19c
- * @param config loop configuration
ddf19c
- * @return see fuse_session_loop()
ddf19c
- *
ddf19c
- * See also: fuse_loop()
ddf19c
- */
ddf19c
-#if FUSE_USE_VERSION < 32
ddf19c
-int fuse_loop_mt_31(struct fuse *f, int clone_fd);
ddf19c
-#define fuse_loop_mt(f, clone_fd) fuse_loop_mt_31(f, clone_fd)
ddf19c
-#else
ddf19c
-int fuse_loop_mt(struct fuse *f, struct fuse_loop_config *config);
ddf19c
-#endif
ddf19c
-
ddf19c
-/**
ddf19c
  * Get the current context
ddf19c
  *
ddf19c
  * The context is only valid for the duration of a filesystem
ddf19c
@@ -1268,8 +1226,4 @@ struct fuse_session *fuse_get_session(struct fuse *f);
ddf19c
  */
ddf19c
 int fuse_open_channel(const char *mountpoint, const char *options);
ddf19c
 
ddf19c
-#ifdef __cplusplus
ddf19c
-}
ddf19c
-#endif
ddf19c
-
ddf19c
 #endif /* FUSE_H_ */
ddf19c
diff --git a/tools/virtiofsd/fuse_common.h b/tools/virtiofsd/fuse_common.h
ddf19c
index 2d686b2..bf8f8cc 100644
ddf19c
--- a/tools/virtiofsd/fuse_common.h
ddf19c
+++ b/tools/virtiofsd/fuse_common.h
ddf19c
@@ -28,10 +28,6 @@
ddf19c
 #define FUSE_MAKE_VERSION(maj, min)  ((maj) * 10 + (min))
ddf19c
 #define FUSE_VERSION FUSE_MAKE_VERSION(FUSE_MAJOR_VERSION, FUSE_MINOR_VERSION)
ddf19c
 
ddf19c
-#ifdef __cplusplus
ddf19c
-extern "C" {
ddf19c
-#endif
ddf19c
-
ddf19c
 /**
ddf19c
  * Information about an open file.
ddf19c
  *
ddf19c
@@ -100,30 +96,6 @@ struct fuse_file_info {
ddf19c
 	uint32_t poll_events;
ddf19c
 };
ddf19c
 
ddf19c
-/**
ddf19c
- * Configuration parameters passed to fuse_session_loop_mt() and
ddf19c
- * fuse_loop_mt().
ddf19c
- */
ddf19c
-struct fuse_loop_config {
ddf19c
-	/**
ddf19c
-	 * whether to use separate device fds for each thread
ddf19c
-	 * (may increase performance)
ddf19c
-	 */
ddf19c
-	int clone_fd;
ddf19c
-
ddf19c
-	/**
ddf19c
-	 * The maximum number of available worker threads before they
ddf19c
-	 * start to get deleted when they become idle. If not
ddf19c
-	 * specified, the default is 10.
ddf19c
-	 *
ddf19c
-	 * Adjusting this has performance implications; a very small number
ddf19c
-	 * of threads in the pool will cause a lot of thread creation and
ddf19c
-	 * deletion overhead and performance may suffer. When set to 0, a new
ddf19c
-	 * thread will be created to service every operation.
ddf19c
-	 */
ddf19c
-	unsigned int max_idle_threads;
ddf19c
-};
ddf19c
-
ddf19c
 /**************************************************************************
ddf19c
  * Capability bits for 'fuse_conn_info.capable' and 'fuse_conn_info.want' *
ddf19c
  **************************************************************************/
ddf19c
@@ -802,10 +774,6 @@ void fuse_remove_signal_handlers(struct fuse_session *se);
ddf19c
 #  error only API version 30 or greater is supported
ddf19c
 #endif
ddf19c
 
ddf19c
-#ifdef __cplusplus
ddf19c
-}
ddf19c
-#endif
ddf19c
-
ddf19c
 
ddf19c
 /*
ddf19c
  * This interface uses 64 bit off_t.
ddf19c
diff --git a/tools/virtiofsd/fuse_i.h b/tools/virtiofsd/fuse_i.h
ddf19c
index d38b630..b39522e 100644
ddf19c
--- a/tools/virtiofsd/fuse_i.h
ddf19c
+++ b/tools/virtiofsd/fuse_i.h
ddf19c
@@ -9,8 +9,6 @@
ddf19c
 #include "fuse.h"
ddf19c
 #include "fuse_lowlevel.h"
ddf19c
 
ddf19c
-struct mount_opts;
ddf19c
-
ddf19c
 struct fuse_req {
ddf19c
 	struct fuse_session *se;
ddf19c
 	uint64_t unique;
ddf19c
@@ -45,7 +43,6 @@ struct fuse_session {
ddf19c
 	char *mountpoint;
ddf19c
 	volatile int exited;
ddf19c
 	int fd;
ddf19c
-	struct mount_opts *mo;
ddf19c
 	int debug;
ddf19c
 	int deny_others;
ddf19c
 	struct fuse_lowlevel_ops op;
ddf19c
@@ -58,7 +55,6 @@ struct fuse_session {
ddf19c
 	struct fuse_req interrupts;
ddf19c
 	pthread_mutex_t lock;
ddf19c
 	int got_destroy;
ddf19c
-	pthread_key_t pipe_key;
ddf19c
 	int broken_splice_nonblock;
ddf19c
 	uint64_t notify_ctr;
ddf19c
 	struct fuse_notify_req notify_list;
ddf19c
@@ -87,53 +83,16 @@ struct fuse_module {
ddf19c
 	int ctr;
ddf19c
 };
ddf19c
 
ddf19c
-/* ----------------------------------------------------------- *
ddf19c
- * Channel interface (when using -o clone_fd)		       *
ddf19c
- * ----------------------------------------------------------- */
ddf19c
-
ddf19c
-/**
ddf19c
- * Obtain counted reference to the channel
ddf19c
- *
ddf19c
- * @param ch the channel
ddf19c
- * @return the channel
ddf19c
- */
ddf19c
-struct fuse_chan *fuse_chan_get(struct fuse_chan *ch);
ddf19c
-
ddf19c
-/**
ddf19c
- * Drop counted reference to a channel
ddf19c
- *
ddf19c
- * @param ch the channel
ddf19c
- */
ddf19c
-void fuse_chan_put(struct fuse_chan *ch);
ddf19c
-
ddf19c
-struct mount_opts *parse_mount_opts(struct fuse_args *args);
ddf19c
-void destroy_mount_opts(struct mount_opts *mo);
ddf19c
-void fuse_mount_version(void);
ddf19c
-unsigned get_max_read(struct mount_opts *o);
ddf19c
-void fuse_kern_unmount(const char *mountpoint, int fd);
ddf19c
-int fuse_kern_mount(const char *mountpoint, struct mount_opts *mo);
ddf19c
-
ddf19c
 int fuse_send_reply_iov_nofree(fuse_req_t req, int error, struct iovec *iov,
ddf19c
 			       int count);
ddf19c
 void fuse_free_req(fuse_req_t req);
ddf19c
 
ddf19c
-void cuse_lowlevel_init(fuse_req_t req, fuse_ino_t nodeide, const void *inarg);
ddf19c
-
ddf19c
-int fuse_start_thread(pthread_t *thread_id, void *(*func)(void *), void *arg);
ddf19c
-
ddf19c
-int fuse_session_receive_buf_int(struct fuse_session *se, struct fuse_buf *buf,
ddf19c
-				 struct fuse_chan *ch);
ddf19c
 void fuse_session_process_buf_int(struct fuse_session *se,
ddf19c
 				  const struct fuse_buf *buf, struct fuse_chan *ch);
ddf19c
 
ddf19c
-struct fuse *fuse_new_31(struct fuse_args *args, const struct fuse_operations *op,
ddf19c
-		      size_t op_size, void *private_data);
ddf19c
-int fuse_loop_mt_32(struct fuse *f, struct fuse_loop_config *config);
ddf19c
-int fuse_session_loop_mt_32(struct fuse_session *se, struct fuse_loop_config *config);
ddf19c
 
ddf19c
 #define FUSE_MAX_MAX_PAGES 256
ddf19c
 #define FUSE_DEFAULT_MAX_PAGES_PER_REQ 32
ddf19c
 
ddf19c
 /* room needed in buffer to accommodate header */
ddf19c
 #define FUSE_BUFFER_HEADER_SIZE 0x1000
ddf19c
-
ddf19c
diff --git a/tools/virtiofsd/fuse_log.h b/tools/virtiofsd/fuse_log.h
ddf19c
index 5e112e0..0af700d 100644
ddf19c
--- a/tools/virtiofsd/fuse_log.h
ddf19c
+++ b/tools/virtiofsd/fuse_log.h
ddf19c
@@ -16,10 +16,6 @@
ddf19c
 
ddf19c
 #include <stdarg.h>
ddf19c
 
ddf19c
-#ifdef __cplusplus
ddf19c
-extern "C" {
ddf19c
-#endif
ddf19c
-
ddf19c
 /**
ddf19c
  * Log severity level
ddf19c
  *
ddf19c
@@ -75,8 +71,4 @@ void fuse_set_log_func(fuse_log_func_t func);
ddf19c
  */
ddf19c
 void fuse_log(enum fuse_log_level level, const char *fmt, ...);
ddf19c
 
ddf19c
-#ifdef __cplusplus
ddf19c
-}
ddf19c
-#endif
ddf19c
-
ddf19c
 #endif /* FUSE_LOG_H_ */
ddf19c
diff --git a/tools/virtiofsd/fuse_lowlevel.c b/tools/virtiofsd/fuse_lowlevel.c
ddf19c
index f2d7038..e6fa247 100644
ddf19c
--- a/tools/virtiofsd/fuse_lowlevel.c
ddf19c
+++ b/tools/virtiofsd/fuse_lowlevel.c
ddf19c
@@ -16,7 +16,6 @@
ddf19c
 #include "fuse_kernel.h"
ddf19c
 #include "fuse_opt.h"
ddf19c
 #include "fuse_misc.h"
ddf19c
-#include "mount_util.h"
ddf19c
 
ddf19c
 #include <stdio.h>
ddf19c
 #include <stdlib.h>
ddf19c
@@ -28,12 +27,6 @@
ddf19c
 #include <assert.h>
ddf19c
 #include <sys/file.h>
ddf19c
 
ddf19c
-#ifndef F_LINUX_SPECIFIC_BASE
ddf19c
-#define F_LINUX_SPECIFIC_BASE       1024
ddf19c
-#endif
ddf19c
-#ifndef F_SETPIPE_SZ
ddf19c
-#define F_SETPIPE_SZ	(F_LINUX_SPECIFIC_BASE + 7)
ddf19c
-#endif
ddf19c
 
ddf19c
 
ddf19c
 #define PARAM(inarg) (((char *)(inarg)) + sizeof(*(inarg)))
ddf19c
@@ -137,7 +130,6 @@ void fuse_free_req(fuse_req_t req)
ddf19c
 	req->u.ni.data = NULL;
ddf19c
 	list_del_req(req);
ddf19c
 	ctr = --req->ctr;
ddf19c
-	fuse_chan_put(req->ch);
ddf19c
 	req->ch = NULL;
ddf19c
 	pthread_mutex_unlock(&se->lock);
ddf19c
 	if (!ctr)
ddf19c
@@ -184,19 +176,7 @@ static int fuse_send_msg(struct fuse_session *se, struct fuse_chan *ch,
ddf19c
 		}
ddf19c
 	}
ddf19c
 
ddf19c
-	ssize_t res = writev(ch ? ch->fd : se->fd,
ddf19c
-			     iov, count);
ddf19c
-	int err = errno;
ddf19c
-
ddf19c
-	if (res == -1) {
ddf19c
-		assert(se != NULL);
ddf19c
-
ddf19c
-		/* ENOENT means the operation was interrupted */
ddf19c
-		if (!fuse_session_exited(se) && err != ENOENT)
ddf19c
-			perror("fuse: writing device");
ddf19c
-		return -err;
ddf19c
-	}
ddf19c
-
ddf19c
+	abort(); /* virtio should have taken it before here */
ddf19c
 	return 0;
ddf19c
 }
ddf19c
 
ddf19c
@@ -480,10 +460,6 @@ static int fuse_send_data_iov_fallback(struct fuse_session *se,
ddf19c
 				       struct fuse_bufvec *buf,
ddf19c
 				       size_t len)
ddf19c
 {
ddf19c
-	struct fuse_bufvec mem_buf = FUSE_BUFVEC_INIT(len);
ddf19c
-	void *mbuf;
ddf19c
-	int res;
ddf19c
-
ddf19c
 	/* Optimize common case */
ddf19c
 	if (buf->count == 1 && buf->idx == 0 && buf->off == 0 &&
ddf19c
 	    !(buf->buf[0].flags & FUSE_BUF_IS_FD)) {
ddf19c
@@ -496,350 +472,10 @@ static int fuse_send_data_iov_fallback(struct fuse_session *se,
ddf19c
 		return fuse_send_msg(se, ch, iov, iov_count);
ddf19c
 	}
ddf19c
 
ddf19c
-	res = posix_memalign(&mbuf, pagesize, len);
ddf19c
-	if (res != 0)
ddf19c
-		return res;
ddf19c
-
ddf19c
-	mem_buf.buf[0].mem = mbuf;
ddf19c
-	res = fuse_buf_copy(&mem_buf, buf, 0);
ddf19c
-	if (res < 0) {
ddf19c
-		free(mbuf);
ddf19c
-		return -res;
ddf19c
-	}
ddf19c
-	len = res;
ddf19c
-
ddf19c
-	iov[iov_count].iov_base = mbuf;
ddf19c
-	iov[iov_count].iov_len = len;
ddf19c
-	iov_count++;
ddf19c
-	res = fuse_send_msg(se, ch, iov, iov_count);
ddf19c
-	free(mbuf);
ddf19c
-
ddf19c
-	return res;
ddf19c
-}
ddf19c
-
ddf19c
-struct fuse_ll_pipe {
ddf19c
-	size_t size;
ddf19c
-	int can_grow;
ddf19c
-	int pipe[2];
ddf19c
-};
ddf19c
-
ddf19c
-static void fuse_ll_pipe_free(struct fuse_ll_pipe *llp)
ddf19c
-{
ddf19c
-	close(llp->pipe[0]);
ddf19c
-	close(llp->pipe[1]);
ddf19c
-	free(llp);
ddf19c
-}
ddf19c
-
ddf19c
-#ifdef HAVE_SPLICE
ddf19c
-#if !defined(HAVE_PIPE2) || !defined(O_CLOEXEC)
ddf19c
-static int fuse_pipe(int fds[2])
ddf19c
-{
ddf19c
-	int rv = pipe(fds);
ddf19c
-
ddf19c
-	if (rv == -1)
ddf19c
-		return rv;
ddf19c
-
ddf19c
-	if (fcntl(fds[0], F_SETFL, O_NONBLOCK) == -1 ||
ddf19c
-	    fcntl(fds[1], F_SETFL, O_NONBLOCK) == -1 ||
ddf19c
-	    fcntl(fds[0], F_SETFD, FD_CLOEXEC) == -1 ||
ddf19c
-	    fcntl(fds[1], F_SETFD, FD_CLOEXEC) == -1) {
ddf19c
-		close(fds[0]);
ddf19c
-		close(fds[1]);
ddf19c
-		rv = -1;
ddf19c
-	}
ddf19c
-	return rv;
ddf19c
-}
ddf19c
-#else
ddf19c
-static int fuse_pipe(int fds[2])
ddf19c
-{
ddf19c
-	return pipe2(fds, O_CLOEXEC | O_NONBLOCK);
ddf19c
-}
ddf19c
-#endif
ddf19c
-
ddf19c
-static struct fuse_ll_pipe *fuse_ll_get_pipe(struct fuse_session *se)
ddf19c
-{
ddf19c
-	struct fuse_ll_pipe *llp = pthread_getspecific(se->pipe_key);
ddf19c
-	if (llp == NULL) {
ddf19c
-		int res;
ddf19c
-
ddf19c
-		llp = malloc(sizeof(struct fuse_ll_pipe));
ddf19c
-		if (llp == NULL)
ddf19c
-			return NULL;
ddf19c
-
ddf19c
-		res = fuse_pipe(llp->pipe);
ddf19c
-		if (res == -1) {
ddf19c
-			free(llp);
ddf19c
-			return NULL;
ddf19c
-		}
ddf19c
-
ddf19c
-		/*
ddf19c
-		 *the default size is 16 pages on linux
ddf19c
-		 */
ddf19c
-		llp->size = pagesize * 16;
ddf19c
-		llp->can_grow = 1;
ddf19c
-
ddf19c
-		pthread_setspecific(se->pipe_key, llp);
ddf19c
-	}
ddf19c
-
ddf19c
-	return llp;
ddf19c
-}
ddf19c
-#endif
ddf19c
-
ddf19c
-static void fuse_ll_clear_pipe(struct fuse_session *se)
ddf19c
-{
ddf19c
-	struct fuse_ll_pipe *llp = pthread_getspecific(se->pipe_key);
ddf19c
-	if (llp) {
ddf19c
-		pthread_setspecific(se->pipe_key, NULL);
ddf19c
-		fuse_ll_pipe_free(llp);
ddf19c
-	}
ddf19c
-}
ddf19c
-
ddf19c
-#if defined(HAVE_SPLICE) && defined(HAVE_VMSPLICE)
ddf19c
-static int read_back(int fd, char *buf, size_t len)
ddf19c
-{
ddf19c
-	int res;
ddf19c
-
ddf19c
-	res = read(fd, buf, len);
ddf19c
-	if (res == -1) {
ddf19c
-		fuse_log(FUSE_LOG_ERR, "fuse: internal error: failed to read back from pipe: %s\n", strerror(errno));
ddf19c
-		return -EIO;
ddf19c
-	}
ddf19c
-	if (res != len) {
ddf19c
-		fuse_log(FUSE_LOG_ERR, "fuse: internal error: short read back from pipe: %i from %zi\n", res, len);
ddf19c
-		return -EIO;
ddf19c
-	}
ddf19c
+	abort(); /* Will have taken vhost path */
ddf19c
 	return 0;
ddf19c
 }
ddf19c
 
ddf19c
-static int grow_pipe_to_max(int pipefd)
ddf19c
-{
ddf19c
-	int max;
ddf19c
-	int res;
ddf19c
-	int maxfd;
ddf19c
-	char buf[32];
ddf19c
-
ddf19c
-	maxfd = open("/proc/sys/fs/pipe-max-size", O_RDONLY);
ddf19c
-	if (maxfd < 0)
ddf19c
-		return -errno;
ddf19c
-
ddf19c
-	res = read(maxfd, buf, sizeof(buf) - 1);
ddf19c
-	if (res < 0) {
ddf19c
-		int saved_errno;
ddf19c
-
ddf19c
-		saved_errno = errno;
ddf19c
-		close(maxfd);
ddf19c
-		return -saved_errno;
ddf19c
-	}
ddf19c
-	close(maxfd);
ddf19c
-	buf[res] = '\0';
ddf19c
-
ddf19c
-	max = atoi(buf);
ddf19c
-	res = fcntl(pipefd, F_SETPIPE_SZ, max);
ddf19c
-	if (res < 0)
ddf19c
-		return -errno;
ddf19c
-	return max;
ddf19c
-}
ddf19c
-
ddf19c
-static int fuse_send_data_iov(struct fuse_session *se, struct fuse_chan *ch,
ddf19c
-			       struct iovec *iov, int iov_count,
ddf19c
-			       struct fuse_bufvec *buf, unsigned int flags)
ddf19c
-{
ddf19c
-	int res;
ddf19c
-	size_t len = fuse_buf_size(buf);
ddf19c
-	struct fuse_out_header *out = iov[0].iov_base;
ddf19c
-	struct fuse_ll_pipe *llp;
ddf19c
-	int splice_flags;
ddf19c
-	size_t pipesize;
ddf19c
-	size_t total_fd_size;
ddf19c
-	size_t idx;
ddf19c
-	size_t headerlen;
ddf19c
-	struct fuse_bufvec pipe_buf = FUSE_BUFVEC_INIT(len);
ddf19c
-
ddf19c
-	if (se->broken_splice_nonblock)
ddf19c
-		goto fallback;
ddf19c
-
ddf19c
-	if (flags & FUSE_BUF_NO_SPLICE)
ddf19c
-		goto fallback;
ddf19c
-
ddf19c
-	total_fd_size = 0;
ddf19c
-	for (idx = buf->idx; idx < buf->count; idx++) {
ddf19c
-		if (buf->buf[idx].flags & FUSE_BUF_IS_FD) {
ddf19c
-			total_fd_size = buf->buf[idx].size;
ddf19c
-			if (idx == buf->idx)
ddf19c
-				total_fd_size -= buf->off;
ddf19c
-		}
ddf19c
-	}
ddf19c
-	if (total_fd_size < 2 * pagesize)
ddf19c
-		goto fallback;
ddf19c
-
ddf19c
-	if (se->conn.proto_minor < 14 ||
ddf19c
-	    !(se->conn.want & FUSE_CAP_SPLICE_WRITE))
ddf19c
-		goto fallback;
ddf19c
-
ddf19c
-	llp = fuse_ll_get_pipe(se);
ddf19c
-	if (llp == NULL)
ddf19c
-		goto fallback;
ddf19c
-
ddf19c
-
ddf19c
-	headerlen = iov_length(iov, iov_count);
ddf19c
-
ddf19c
-	out->len = headerlen + len;
ddf19c
-
ddf19c
-	/*
ddf19c
-	 * Heuristic for the required pipe size, does not work if the
ddf19c
-	 * source contains less than page size fragments
ddf19c
-	 */
ddf19c
-	pipesize = pagesize * (iov_count + buf->count + 1) + out->len;
ddf19c
-
ddf19c
-	if (llp->size < pipesize) {
ddf19c
-		if (llp->can_grow) {
ddf19c
-			res = fcntl(llp->pipe[0], F_SETPIPE_SZ, pipesize);
ddf19c
-			if (res == -1) {
ddf19c
-				res = grow_pipe_to_max(llp->pipe[0]);
ddf19c
-				if (res > 0)
ddf19c
-					llp->size = res;
ddf19c
-				llp->can_grow = 0;
ddf19c
-				goto fallback;
ddf19c
-			}
ddf19c
-			llp->size = res;
ddf19c
-		}
ddf19c
-		if (llp->size < pipesize)
ddf19c
-			goto fallback;
ddf19c
-	}
ddf19c
-
ddf19c
-
ddf19c
-	res = vmsplice(llp->pipe[1], iov, iov_count, SPLICE_F_NONBLOCK);
ddf19c
-	if (res == -1)
ddf19c
-		goto fallback;
ddf19c
-
ddf19c
-	if (res != headerlen) {
ddf19c
-		res = -EIO;
ddf19c
-		fuse_log(FUSE_LOG_ERR, "fuse: short vmsplice to pipe: %u/%zu\n", res,
ddf19c
-			headerlen);
ddf19c
-		goto clear_pipe;
ddf19c
-	}
ddf19c
-
ddf19c
-	pipe_buf.buf[0].flags = FUSE_BUF_IS_FD;
ddf19c
-	pipe_buf.buf[0].fd = llp->pipe[1];
ddf19c
-
ddf19c
-	res = fuse_buf_copy(&pipe_buf, buf,
ddf19c
-			    FUSE_BUF_FORCE_SPLICE | FUSE_BUF_SPLICE_NONBLOCK);
ddf19c
-	if (res < 0) {
ddf19c
-		if (res == -EAGAIN || res == -EINVAL) {
ddf19c
-			/*
ddf19c
-			 * Should only get EAGAIN on kernels with
ddf19c
-			 * broken SPLICE_F_NONBLOCK support (<=
ddf19c
-			 * 2.6.35) where this error or a short read is
ddf19c
-			 * returned even if the pipe itself is not
ddf19c
-			 * full
ddf19c
-			 *
ddf19c
-			 * EINVAL might mean that splice can't handle
ddf19c
-			 * this combination of input and output.
ddf19c
-			 */
ddf19c
-			if (res == -EAGAIN)
ddf19c
-				se->broken_splice_nonblock = 1;
ddf19c
-
ddf19c
-			pthread_setspecific(se->pipe_key, NULL);
ddf19c
-			fuse_ll_pipe_free(llp);
ddf19c
-			goto fallback;
ddf19c
-		}
ddf19c
-		res = -res;
ddf19c
-		goto clear_pipe;
ddf19c
-	}
ddf19c
-
ddf19c
-	if (res != 0 && res < len) {
ddf19c
-		struct fuse_bufvec mem_buf = FUSE_BUFVEC_INIT(len);
ddf19c
-		void *mbuf;
ddf19c
-		size_t now_len = res;
ddf19c
-		/*
ddf19c
-		 * For regular files a short count is either
ddf19c
-		 *  1) due to EOF, or
ddf19c
-		 *  2) because of broken SPLICE_F_NONBLOCK (see above)
ddf19c
-		 *
ddf19c
-		 * For other inputs it's possible that we overflowed
ddf19c
-		 * the pipe because of small buffer fragments.
ddf19c
-		 */
ddf19c
-
ddf19c
-		res = posix_memalign(&mbuf, pagesize, len);
ddf19c
-		if (res != 0)
ddf19c
-			goto clear_pipe;
ddf19c
-
ddf19c
-		mem_buf.buf[0].mem = mbuf;
ddf19c
-		mem_buf.off = now_len;
ddf19c
-		res = fuse_buf_copy(&mem_buf, buf, 0);
ddf19c
-		if (res > 0) {
ddf19c
-			char *tmpbuf;
ddf19c
-			size_t extra_len = res;
ddf19c
-			/*
ddf19c
-			 * Trickiest case: got more data.  Need to get
ddf19c
-			 * back the data from the pipe and then fall
ddf19c
-			 * back to regular write.
ddf19c
-			 */
ddf19c
-			tmpbuf = malloc(headerlen);
ddf19c
-			if (tmpbuf == NULL) {
ddf19c
-				free(mbuf);
ddf19c
-				res = ENOMEM;
ddf19c
-				goto clear_pipe;
ddf19c
-			}
ddf19c
-			res = read_back(llp->pipe[0], tmpbuf, headerlen);
ddf19c
-			free(tmpbuf);
ddf19c
-			if (res != 0) {
ddf19c
-				free(mbuf);
ddf19c
-				goto clear_pipe;
ddf19c
-			}
ddf19c
-			res = read_back(llp->pipe[0], mbuf, now_len);
ddf19c
-			if (res != 0) {
ddf19c
-				free(mbuf);
ddf19c
-				goto clear_pipe;
ddf19c
-			}
ddf19c
-			len = now_len + extra_len;
ddf19c
-			iov[iov_count].iov_base = mbuf;
ddf19c
-			iov[iov_count].iov_len = len;
ddf19c
-			iov_count++;
ddf19c
-			res = fuse_send_msg(se, ch, iov, iov_count);
ddf19c
-			free(mbuf);
ddf19c
-			return res;
ddf19c
-		}
ddf19c
-		free(mbuf);
ddf19c
-		res = now_len;
ddf19c
-	}
ddf19c
-	len = res;
ddf19c
-	out->len = headerlen + len;
ddf19c
-
ddf19c
-	if (se->debug) {
ddf19c
-		fuse_log(FUSE_LOG_DEBUG,
ddf19c
-			"   unique: %llu, success, outsize: %i (splice)\n",
ddf19c
-			(unsigned long long) out->unique, out->len);
ddf19c
-	}
ddf19c
-
ddf19c
-	splice_flags = 0;
ddf19c
-	if ((flags & FUSE_BUF_SPLICE_MOVE) &&
ddf19c
-	    (se->conn.want & FUSE_CAP_SPLICE_MOVE))
ddf19c
-		splice_flags |= SPLICE_F_MOVE;
ddf19c
-
ddf19c
-	res = splice(llp->pipe[0], NULL, ch ? ch->fd : se->fd,
ddf19c
-		     NULL, out->len, splice_flags);
ddf19c
-	if (res == -1) {
ddf19c
-		res = -errno;
ddf19c
-		perror("fuse: splice from pipe");
ddf19c
-		goto clear_pipe;
ddf19c
-	}
ddf19c
-	if (res != out->len) {
ddf19c
-		res = -EIO;
ddf19c
-		fuse_log(FUSE_LOG_ERR, "fuse: short splice from pipe: %u/%u\n",
ddf19c
-			res, out->len);
ddf19c
-		goto clear_pipe;
ddf19c
-	}
ddf19c
-	return 0;
ddf19c
-
ddf19c
-clear_pipe:
ddf19c
-	fuse_ll_clear_pipe(se);
ddf19c
-	return res;
ddf19c
-
ddf19c
-fallback:
ddf19c
-	return fuse_send_data_iov_fallback(se, ch, iov, iov_count, buf, len);
ddf19c
-}
ddf19c
-#else
ddf19c
 static int fuse_send_data_iov(struct fuse_session *se, struct fuse_chan *ch,
ddf19c
 			       struct iovec *iov, int iov_count,
ddf19c
 			       struct fuse_bufvec *buf, unsigned int flags)
ddf19c
@@ -849,7 +485,6 @@ static int fuse_send_data_iov(struct fuse_session *se, struct fuse_chan *ch,
ddf19c
 
ddf19c
 	return fuse_send_data_iov_fallback(se, ch, iov, iov_count, buf, len);
ddf19c
 }
ddf19c
-#endif
ddf19c
 
ddf19c
 int fuse_reply_data(fuse_req_t req, struct fuse_bufvec *bufv,
ddf19c
 		    enum fuse_buf_copy_flags flags)
ddf19c
@@ -1408,16 +1043,11 @@ static void do_write_buf(fuse_req_t req, fuse_ino_t nodeid, const void *inarg,
ddf19c
 	if (bufv.buf[0].size < arg->size) {
ddf19c
 		fuse_log(FUSE_LOG_ERR, "fuse: do_write_buf: buffer size too small\n");
ddf19c
 		fuse_reply_err(req, EIO);
ddf19c
-		goto out;
ddf19c
+		return;
ddf19c
 	}
ddf19c
 	bufv.buf[0].size = arg->size;
ddf19c
 
ddf19c
 	se->op.write_buf(req, nodeid, &bufv, arg->offset, &fi);
ddf19c
-
ddf19c
-out:
ddf19c
-	/* Need to reset the pipe if ->write_buf() didn't consume all data */
ddf19c
-	if ((ibuf->flags & FUSE_BUF_IS_FD) && bufv.idx < bufv.count)
ddf19c
-		fuse_ll_clear_pipe(se);
ddf19c
 }
ddf19c
 
ddf19c
 static void do_flush(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
ddf19c
@@ -2038,17 +1668,6 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
ddf19c
 		return;
ddf19c
 	}
ddf19c
 
ddf19c
-	unsigned max_read_mo = get_max_read(se->mo);
ddf19c
-	if (se->conn.max_read != max_read_mo) {
ddf19c
-		fuse_log(FUSE_LOG_ERR, "fuse: error: init() and fuse_session_new() "
ddf19c
-			"requested different maximum read size (%u vs %u)\n",
ddf19c
-			se->conn.max_read, max_read_mo);
ddf19c
-		fuse_reply_err(req, EPROTO);
ddf19c
-		se->error = -EPROTO;
ddf19c
-		fuse_session_exit(se);
ddf19c
-		return;
ddf19c
-	}
ddf19c
-
ddf19c
 	if (se->conn.max_write < bufsize - FUSE_BUFFER_HEADER_SIZE) {
ddf19c
 		se->bufsize = se->conn.max_write + FUSE_BUFFER_HEADER_SIZE;
ddf19c
 	}
ddf19c
@@ -2364,8 +1983,6 @@ static void fuse_ll_retrieve_reply(struct fuse_notify_req *nreq,
ddf19c
 	}
ddf19c
 out:
ddf19c
 	free(rreq);
ddf19c
-	if ((ibuf->flags & FUSE_BUF_IS_FD) && bufv.idx < bufv.count)
ddf19c
-		fuse_ll_clear_pipe(se);
ddf19c
 }
ddf19c
 
ddf19c
 int fuse_lowlevel_notify_retrieve(struct fuse_session *se, fuse_ino_t ino,
ddf19c
@@ -2496,7 +2113,6 @@ static struct {
ddf19c
 	[FUSE_RENAME2]     = { do_rename2,      "RENAME2"    },
ddf19c
 	[FUSE_COPY_FILE_RANGE] = { do_copy_file_range, "COPY_FILE_RANGE" },
ddf19c
 	[FUSE_LSEEK]	   = { do_lseek,       "LSEEK"	     },
ddf19c
-	[CUSE_INIT]	   = { cuse_lowlevel_init, "CUSE_INIT"   },
ddf19c
 };
ddf19c
 
ddf19c
 #define FUSE_MAXOP (sizeof(fuse_ll_ops) / sizeof(fuse_ll_ops[0]))
ddf19c
@@ -2509,21 +2125,6 @@ static const char *opname(enum fuse_opcode opcode)
ddf19c
 		return fuse_ll_ops[opcode].name;
ddf19c
 }
ddf19c
 
ddf19c
-static int fuse_ll_copy_from_pipe(struct fuse_bufvec *dst,
ddf19c
-				  struct fuse_bufvec *src)
ddf19c
-{
ddf19c
-	ssize_t res = fuse_buf_copy(dst, src, 0);
ddf19c
-	if (res < 0) {
ddf19c
-		fuse_log(FUSE_LOG_ERR, "fuse: copy from pipe: %s\n", strerror(-res));
ddf19c
-		return res;
ddf19c
-	}
ddf19c
-	if ((size_t)res < fuse_buf_size(dst)) {
ddf19c
-		fuse_log(FUSE_LOG_ERR, "fuse: copy from pipe: short read\n");
ddf19c
-		return -1;
ddf19c
-	}
ddf19c
-	return 0;
ddf19c
-}
ddf19c
-
ddf19c
 void fuse_session_process_buf(struct fuse_session *se,
ddf19c
 			      const struct fuse_buf *buf)
ddf19c
 {
ddf19c
@@ -2533,36 +2134,12 @@ void fuse_session_process_buf(struct fuse_session *se,
ddf19c
 void fuse_session_process_buf_int(struct fuse_session *se,
ddf19c
 				  const struct fuse_buf *buf, struct fuse_chan *ch)
ddf19c
 {
ddf19c
-	const size_t write_header_size = sizeof(struct fuse_in_header) +
ddf19c
-		sizeof(struct fuse_write_in);
ddf19c
-	struct fuse_bufvec bufv = { .buf[0] = *buf, .count = 1 };
ddf19c
-	struct fuse_bufvec tmpbuf = FUSE_BUFVEC_INIT(write_header_size);
ddf19c
 	struct fuse_in_header *in;
ddf19c
 	const void *inarg;
ddf19c
 	struct fuse_req *req;
ddf19c
-	void *mbuf = NULL;
ddf19c
 	int err;
ddf19c
-	int res;
ddf19c
-
ddf19c
-	if (buf->flags & FUSE_BUF_IS_FD) {
ddf19c
-		if (buf->size < tmpbuf.buf[0].size)
ddf19c
-			tmpbuf.buf[0].size = buf->size;
ddf19c
 
ddf19c
-		mbuf = malloc(tmpbuf.buf[0].size);
ddf19c
-		if (mbuf == NULL) {
ddf19c
-			fuse_log(FUSE_LOG_ERR, "fuse: failed to allocate header\n");
ddf19c
-			goto clear_pipe;
ddf19c
-		}
ddf19c
-		tmpbuf.buf[0].mem = mbuf;
ddf19c
-
ddf19c
-		res = fuse_ll_copy_from_pipe(&tmpbuf, &bufv);
ddf19c
-		if (res < 0)
ddf19c
-			goto clear_pipe;
ddf19c
-
ddf19c
-		in = mbuf;
ddf19c
-	} else {
ddf19c
-		in = buf->mem;
ddf19c
-	}
ddf19c
+	in = buf->mem;
ddf19c
 
ddf19c
 	if (se->debug) {
ddf19c
 		fuse_log(FUSE_LOG_DEBUG,
ddf19c
@@ -2584,14 +2161,14 @@ void fuse_session_process_buf_int(struct fuse_session *se,
ddf19c
 		};
ddf19c
 
ddf19c
 		fuse_send_msg(se, ch, &iov, 1);
ddf19c
-		goto clear_pipe;
ddf19c
+		return;
ddf19c
 	}
ddf19c
 
ddf19c
 	req->unique = in->unique;
ddf19c
 	req->ctx.uid = in->uid;
ddf19c
 	req->ctx.gid = in->gid;
ddf19c
 	req->ctx.pid = in->pid;
ddf19c
-	req->ch = ch ? fuse_chan_get(ch) : NULL;
ddf19c
+	req->ch = ch;
ddf19c
 
ddf19c
 	err = EIO;
ddf19c
 	if (!se->got_init) {
ddf19c
@@ -2627,28 +2204,6 @@ void fuse_session_process_buf_int(struct fuse_session *se,
ddf19c
 			fuse_reply_err(intr, EAGAIN);
ddf19c
 	}
ddf19c
 
ddf19c
-	if ((buf->flags & FUSE_BUF_IS_FD) && write_header_size < buf->size &&
ddf19c
-	    (in->opcode != FUSE_WRITE || !se->op.write_buf) &&
ddf19c
-	    in->opcode != FUSE_NOTIFY_REPLY) {
ddf19c
-		void *newmbuf;
ddf19c
-
ddf19c
-		err = ENOMEM;
ddf19c
-		newmbuf = realloc(mbuf, buf->size);
ddf19c
-		if (newmbuf == NULL)
ddf19c
-			goto reply_err;
ddf19c
-		mbuf = newmbuf;
ddf19c
-
ddf19c
-		tmpbuf = FUSE_BUFVEC_INIT(buf->size - write_header_size);
ddf19c
-		tmpbuf.buf[0].mem = (char *)mbuf + write_header_size;
ddf19c
-
ddf19c
-		res = fuse_ll_copy_from_pipe(&tmpbuf, &bufv);
ddf19c
-		err = -res;
ddf19c
-		if (res < 0)
ddf19c
-			goto reply_err;
ddf19c
-
ddf19c
-		in = mbuf;
ddf19c
-	}
ddf19c
-
ddf19c
 	inarg = (void *) &in[1];
ddf19c
 	if (in->opcode == FUSE_WRITE && se->op.write_buf)
ddf19c
 		do_write_buf(req, in->nodeid, inarg, buf);
ddf19c
@@ -2657,16 +2212,10 @@ void fuse_session_process_buf_int(struct fuse_session *se,
ddf19c
 	else
ddf19c
 		fuse_ll_ops[in->opcode].func(req, in->nodeid, inarg);
ddf19c
 
ddf19c
-out_free:
ddf19c
-	free(mbuf);
ddf19c
 	return;
ddf19c
 
ddf19c
 reply_err:
ddf19c
 	fuse_reply_err(req, err);
ddf19c
-clear_pipe:
ddf19c
-	if (buf->flags & FUSE_BUF_IS_FD)
ddf19c
-		fuse_ll_clear_pipe(se);
ddf19c
-	goto out_free;
ddf19c
 }
ddf19c
 
ddf19c
 #define LL_OPTION(n,o,v) \
ddf19c
@@ -2684,7 +2233,6 @@ void fuse_lowlevel_version(void)
ddf19c
 {
ddf19c
 	printf("using FUSE kernel interface version %i.%i\n",
ddf19c
 	       FUSE_KERNEL_VERSION, FUSE_KERNEL_MINOR_VERSION);
ddf19c
-	fuse_mount_version();
ddf19c
 }
ddf19c
 
ddf19c
 void fuse_lowlevel_help(void)
ddf19c
@@ -2692,204 +2240,29 @@ void fuse_lowlevel_help(void)
ddf19c
 	/* These are not all options, but the ones that are
ddf19c
 	   potentially of interest to an end-user */
ddf19c
 	printf(
ddf19c
-"    -o allow_other         allow access by all users\n"
ddf19c
 "    -o allow_root          allow access by root\n"
ddf19c
-"    -o auto_unmount        auto unmount on process termination\n");
ddf19c
+);
ddf19c
 }
ddf19c
 
ddf19c
 void fuse_session_destroy(struct fuse_session *se)
ddf19c
 {
ddf19c
-	struct fuse_ll_pipe *llp;
ddf19c
-
ddf19c
 	if (se->got_init && !se->got_destroy) {
ddf19c
 		if (se->op.destroy)
ddf19c
 			se->op.destroy(se->userdata);
ddf19c
 	}
ddf19c
-	llp = pthread_getspecific(se->pipe_key);
ddf19c
-	if (llp != NULL)
ddf19c
-		fuse_ll_pipe_free(llp);
ddf19c
-	pthread_key_delete(se->pipe_key);
ddf19c
 	pthread_mutex_destroy(&se->lock);
ddf19c
 	free(se->cuse_data);
ddf19c
 	if (se->fd != -1)
ddf19c
 		close(se->fd);
ddf19c
-	destroy_mount_opts(se->mo);
ddf19c
 	free(se);
ddf19c
 }
ddf19c
 
ddf19c
 
ddf19c
-static void fuse_ll_pipe_destructor(void *data)
ddf19c
-{
ddf19c
-	struct fuse_ll_pipe *llp = data;
ddf19c
-	fuse_ll_pipe_free(llp);
ddf19c
-}
ddf19c
-
ddf19c
-int fuse_session_receive_buf(struct fuse_session *se, struct fuse_buf *buf)
ddf19c
-{
ddf19c
-	return fuse_session_receive_buf_int(se, buf, NULL);
ddf19c
-}
ddf19c
-
ddf19c
-int fuse_session_receive_buf_int(struct fuse_session *se, struct fuse_buf *buf,
ddf19c
-				 struct fuse_chan *ch)
ddf19c
-{
ddf19c
-	int err;
ddf19c
-	ssize_t res;
ddf19c
-#ifdef HAVE_SPLICE
ddf19c
-	size_t bufsize = se->bufsize;
ddf19c
-	struct fuse_ll_pipe *llp;
ddf19c
-	struct fuse_buf tmpbuf;
ddf19c
-
ddf19c
-	if (se->conn.proto_minor < 14 || !(se->conn.want & FUSE_CAP_SPLICE_READ))
ddf19c
-		goto fallback;
ddf19c
-
ddf19c
-	llp = fuse_ll_get_pipe(se);
ddf19c
-	if (llp == NULL)
ddf19c
-		goto fallback;
ddf19c
-
ddf19c
-	if (llp->size < bufsize) {
ddf19c
-		if (llp->can_grow) {
ddf19c
-			res = fcntl(llp->pipe[0], F_SETPIPE_SZ, bufsize);
ddf19c
-			if (res == -1) {
ddf19c
-				llp->can_grow = 0;
ddf19c
-				res = grow_pipe_to_max(llp->pipe[0]);
ddf19c
-				if (res > 0)
ddf19c
-					llp->size = res;
ddf19c
-				goto fallback;
ddf19c
-			}
ddf19c
-			llp->size = res;
ddf19c
-		}
ddf19c
-		if (llp->size < bufsize)
ddf19c
-			goto fallback;
ddf19c
-	}
ddf19c
-
ddf19c
-	res = splice(ch ? ch->fd : se->fd,
ddf19c
-		     NULL, llp->pipe[1], NULL, bufsize, 0);
ddf19c
-	err = errno;
ddf19c
-
ddf19c
-	if (fuse_session_exited(se))
ddf19c
-		return 0;
ddf19c
-
ddf19c
-	if (res == -1) {
ddf19c
-		if (err == ENODEV) {
ddf19c
-			/* Filesystem was unmounted, or connection was aborted
ddf19c
-			   via /sys/fs/fuse/connections */
ddf19c
-			fuse_session_exit(se);
ddf19c
-			return 0;
ddf19c
-		}
ddf19c
-		if (err != EINTR && err != EAGAIN)
ddf19c
-			perror("fuse: splice from device");
ddf19c
-		return -err;
ddf19c
-	}
ddf19c
-
ddf19c
-	if (res < sizeof(struct fuse_in_header)) {
ddf19c
-		fuse_log(FUSE_LOG_ERR, "short splice from fuse device\n");
ddf19c
-		return -EIO;
ddf19c
-	}
ddf19c
-
ddf19c
-	tmpbuf = (struct fuse_buf) {
ddf19c
-		.size = res,
ddf19c
-		.flags = FUSE_BUF_IS_FD,
ddf19c
-		.fd = llp->pipe[0],
ddf19c
-	};
ddf19c
-
ddf19c
-	/*
ddf19c
-	 * Don't bother with zero copy for small requests.
ddf19c
-	 * fuse_loop_mt() needs to check for FORGET so this more than
ddf19c
-	 * just an optimization.
ddf19c
-	 */
ddf19c
-	if (res < sizeof(struct fuse_in_header) +
ddf19c
-	    sizeof(struct fuse_write_in) + pagesize) {
ddf19c
-		struct fuse_bufvec src = { .buf[0] = tmpbuf, .count = 1 };
ddf19c
-		struct fuse_bufvec dst = { .count = 1 };
ddf19c
-
ddf19c
-		if (!buf->mem) {
ddf19c
-			buf->mem = malloc(se->bufsize);
ddf19c
-			if (!buf->mem) {
ddf19c
-				fuse_log(FUSE_LOG_ERR,
ddf19c
-					"fuse: failed to allocate read buffer\n");
ddf19c
-				return -ENOMEM;
ddf19c
-			}
ddf19c
-		}
ddf19c
-		buf->size = se->bufsize;
ddf19c
-		buf->flags = 0;
ddf19c
-		dst.buf[0] = *buf;
ddf19c
-
ddf19c
-		res = fuse_buf_copy(&dst, &src, 0);
ddf19c
-		if (res < 0) {
ddf19c
-			fuse_log(FUSE_LOG_ERR, "fuse: copy from pipe: %s\n",
ddf19c
-				strerror(-res));
ddf19c
-			fuse_ll_clear_pipe(se);
ddf19c
-			return res;
ddf19c
-		}
ddf19c
-		if (res < tmpbuf.size) {
ddf19c
-			fuse_log(FUSE_LOG_ERR, "fuse: copy from pipe: short read\n");
ddf19c
-			fuse_ll_clear_pipe(se);
ddf19c
-			return -EIO;
ddf19c
-		}
ddf19c
-		assert(res == tmpbuf.size);
ddf19c
-
ddf19c
-	} else {
ddf19c
-		/* Don't overwrite buf->mem, as that would cause a leak */
ddf19c
-		buf->fd = tmpbuf.fd;
ddf19c
-		buf->flags = tmpbuf.flags;
ddf19c
-	}
ddf19c
-	buf->size = tmpbuf.size;
ddf19c
-
ddf19c
-	return res;
ddf19c
-
ddf19c
-fallback:
ddf19c
-#endif
ddf19c
-	if (!buf->mem) {
ddf19c
-		buf->mem = malloc(se->bufsize);
ddf19c
-		if (!buf->mem) {
ddf19c
-			fuse_log(FUSE_LOG_ERR,
ddf19c
-				"fuse: failed to allocate read buffer\n");
ddf19c
-			return -ENOMEM;
ddf19c
-		}
ddf19c
-	}
ddf19c
-
ddf19c
-restart:
ddf19c
-	res = read(ch ? ch->fd : se->fd, buf->mem, se->bufsize);
ddf19c
-	err = errno;
ddf19c
-
ddf19c
-	if (fuse_session_exited(se))
ddf19c
-		return 0;
ddf19c
-	if (res == -1) {
ddf19c
-		/* ENOENT means the operation was interrupted, it's safe
ddf19c
-		   to restart */
ddf19c
-		if (err == ENOENT)
ddf19c
-			goto restart;
ddf19c
-
ddf19c
-		if (err == ENODEV) {
ddf19c
-			/* Filesystem was unmounted, or connection was aborted
ddf19c
-			   via /sys/fs/fuse/connections */
ddf19c
-			fuse_session_exit(se);
ddf19c
-			return 0;
ddf19c
-		}
ddf19c
-		/* Errors occurring during normal operation: EINTR (read
ddf19c
-		   interrupted), EAGAIN (nonblocking I/O), ENODEV (filesystem
ddf19c
-		   umounted) */
ddf19c
-		if (err != EINTR && err != EAGAIN)
ddf19c
-			perror("fuse: reading device");
ddf19c
-		return -err;
ddf19c
-	}
ddf19c
-	if ((size_t) res < sizeof(struct fuse_in_header)) {
ddf19c
-		fuse_log(FUSE_LOG_ERR, "short read on fuse device\n");
ddf19c
-		return -EIO;
ddf19c
-	}
ddf19c
-
ddf19c
-	buf->size = res;
ddf19c
-
ddf19c
-	return res;
ddf19c
-}
ddf19c
-
ddf19c
 struct fuse_session *fuse_session_new(struct fuse_args *args,
ddf19c
 				      const struct fuse_lowlevel_ops *op,
ddf19c
 				      size_t op_size, void *userdata)
ddf19c
 {
ddf19c
-	int err;
ddf19c
 	struct fuse_session *se;
ddf19c
-	struct mount_opts *mo;
ddf19c
 
ddf19c
 	if (sizeof(struct fuse_lowlevel_ops) < op_size) {
ddf19c
 		fuse_log(FUSE_LOG_ERR, "fuse: warning: library too old, some operations may not work\n");
ddf19c
@@ -2913,20 +2286,6 @@ struct fuse_session *fuse_session_new(struct fuse_args *args,
ddf19c
 	/* Parse options */
ddf19c
 	if(fuse_opt_parse(args, se, fuse_ll_opts, NULL) == -1)
ddf19c
 		goto out2;
ddf19c
-	if(se->deny_others) {
ddf19c
-		/* Allowing access only by root is done by instructing
ddf19c
-		 * kernel to allow access by everyone, and then restricting
ddf19c
-		 * access to root and mountpoint owner in libfuse.
ddf19c
-		 */
ddf19c
-		// We may be adding the option a second time, but
ddf19c
-		// that doesn't hurt.
ddf19c
-		if(fuse_opt_add_arg(args, "-oallow_other") == -1)
ddf19c
-			goto out2;
ddf19c
-	}
ddf19c
-	mo = parse_mount_opts(args);
ddf19c
-	if (mo == NULL)
ddf19c
-		goto out3;
ddf19c
-
ddf19c
 	if(args->argc == 1 &&
ddf19c
 	   args->argv[0][0] == '-') {
ddf19c
 		fuse_log(FUSE_LOG_ERR, "fuse: warning: argv[0] looks like an option, but "
ddf19c
@@ -2940,9 +2299,6 @@ struct fuse_session *fuse_session_new(struct fuse_args *args,
ddf19c
 		goto out4;
ddf19c
 	}
ddf19c
 
ddf19c
-	if (se->debug)
ddf19c
-		fuse_log(FUSE_LOG_DEBUG, "FUSE library version: %s\n", PACKAGE_VERSION);
ddf19c
-
ddf19c
 	se->bufsize = FUSE_MAX_MAX_PAGES * getpagesize() +
ddf19c
 		FUSE_BUFFER_HEADER_SIZE;
ddf19c
 
ddf19c
@@ -2952,26 +2308,14 @@ struct fuse_session *fuse_session_new(struct fuse_args *args,
ddf19c
 	se->notify_ctr = 1;
ddf19c
 	fuse_mutex_init(&se->lock);
ddf19c
 
ddf19c
-	err = pthread_key_create(&se->pipe_key, fuse_ll_pipe_destructor);
ddf19c
-	if (err) {
ddf19c
-		fuse_log(FUSE_LOG_ERR, "fuse: failed to create thread specific key: %s\n",
ddf19c
-			strerror(err));
ddf19c
-		goto out5;
ddf19c
-	}
ddf19c
-
ddf19c
 	memcpy(&se->op, op, op_size);
ddf19c
 	se->owner = getuid();
ddf19c
 	se->userdata = userdata;
ddf19c
 
ddf19c
-	se->mo = mo;
ddf19c
 	return se;
ddf19c
 
ddf19c
-out5:
ddf19c
-	pthread_mutex_destroy(&se->lock);
ddf19c
 out4:
ddf19c
 	fuse_opt_free_args(args);
ddf19c
-out3:
ddf19c
-	free(mo);
ddf19c
 out2:
ddf19c
 	free(se);
ddf19c
 out1:
ddf19c
@@ -3035,11 +2379,6 @@ int fuse_session_fd(struct fuse_session *se)
ddf19c
 
ddf19c
 void fuse_session_unmount(struct fuse_session *se)
ddf19c
 {
ddf19c
-	if (se->mountpoint != NULL) {
ddf19c
-		fuse_kern_unmount(se->mountpoint, se->fd);
ddf19c
-		free(se->mountpoint);
ddf19c
-		se->mountpoint = NULL;
ddf19c
-	}
ddf19c
 }
ddf19c
 
ddf19c
 #ifdef linux
ddf19c
diff --git a/tools/virtiofsd/fuse_lowlevel.h b/tools/virtiofsd/fuse_lowlevel.h
ddf19c
index 18c6363..6b1adfc 100644
ddf19c
--- a/tools/virtiofsd/fuse_lowlevel.h
ddf19c
+++ b/tools/virtiofsd/fuse_lowlevel.h
ddf19c
@@ -31,10 +31,6 @@
ddf19c
 #include <sys/statvfs.h>
ddf19c
 #include <sys/uio.h>
ddf19c
 
ddf19c
-#ifdef __cplusplus
ddf19c
-extern "C" {
ddf19c
-#endif
ddf19c
-
ddf19c
 /* ----------------------------------------------------------- *
ddf19c
  * Miscellaneous definitions				       *
ddf19c
  * ----------------------------------------------------------- */
ddf19c
@@ -1863,14 +1859,12 @@ void fuse_cmdline_help(void);
ddf19c
  * ----------------------------------------------------------- */
ddf19c
 
ddf19c
 struct fuse_cmdline_opts {
ddf19c
-	int singlethread;
ddf19c
 	int foreground;
ddf19c
 	int debug;
ddf19c
 	int nodefault_subtype;
ddf19c
 	char *mountpoint;
ddf19c
 	int show_version;
ddf19c
 	int show_help;
ddf19c
-	int clone_fd;
ddf19c
 	unsigned int max_idle_threads;
ddf19c
 };
ddf19c
 
ddf19c
@@ -1962,24 +1956,6 @@ int fuse_session_mount(struct fuse_session *se, const char *mountpoint);
ddf19c
 int fuse_session_loop(struct fuse_session *se);
ddf19c
 
ddf19c
 /**
ddf19c
- * Enter a multi-threaded event loop.
ddf19c
- *
ddf19c
- * For a description of the return value and the conditions when the
ddf19c
- * event loop exits, refer to the documentation of
ddf19c
- * fuse_session_loop().
ddf19c
- *
ddf19c
- * @param se the session
ddf19c
- * @param config session loop configuration 
ddf19c
- * @return see fuse_session_loop()
ddf19c
- */
ddf19c
-#if FUSE_USE_VERSION < 32
ddf19c
-int fuse_session_loop_mt_31(struct fuse_session *se, int clone_fd);
ddf19c
-#define fuse_session_loop_mt(se, clone_fd) fuse_session_loop_mt_31(se, clone_fd)
ddf19c
-#else
ddf19c
-int fuse_session_loop_mt(struct fuse_session *se, struct fuse_loop_config *config);
ddf19c
-#endif
ddf19c
-
ddf19c
-/**
ddf19c
  * Flag a session as terminated.
ddf19c
  *
ddf19c
  * This function is invoked by the POSIX signal handlers, when
ddf19c
@@ -2082,8 +2058,4 @@ void fuse_session_process_buf(struct fuse_session *se,
ddf19c
  */
ddf19c
 int fuse_session_receive_buf(struct fuse_session *se, struct fuse_buf *buf);
ddf19c
 
ddf19c
-#ifdef __cplusplus
ddf19c
-}
ddf19c
-#endif
ddf19c
-
ddf19c
 #endif /* FUSE_LOWLEVEL_H_ */
ddf19c
diff --git a/tools/virtiofsd/fuse_opt.h b/tools/virtiofsd/fuse_opt.h
ddf19c
index d8573e7..6910255 100644
ddf19c
--- a/tools/virtiofsd/fuse_opt.h
ddf19c
+++ b/tools/virtiofsd/fuse_opt.h
ddf19c
@@ -14,10 +14,6 @@
ddf19c
  * This file defines the option parsing interface of FUSE
ddf19c
  */
ddf19c
 
ddf19c
-#ifdef __cplusplus
ddf19c
-extern "C" {
ddf19c
-#endif
ddf19c
-
ddf19c
 /**
ddf19c
  * Option description
ddf19c
  *
ddf19c
@@ -264,8 +260,4 @@ void fuse_opt_free_args(struct fuse_args *args);
ddf19c
  */
ddf19c
 int fuse_opt_match(const struct fuse_opt opts[], const char *opt);
ddf19c
 
ddf19c
-#ifdef __cplusplus
ddf19c
-}
ddf19c
-#endif
ddf19c
-
ddf19c
 #endif /* FUSE_OPT_H_ */
ddf19c
diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c
ddf19c
index 64ff7ad..5a2e64c 100644
ddf19c
--- a/tools/virtiofsd/helper.c
ddf19c
+++ b/tools/virtiofsd/helper.c
ddf19c
@@ -41,14 +41,10 @@ static const struct fuse_opt fuse_helper_opts[] = {
ddf19c
 	FUSE_OPT_KEY("-d",		FUSE_OPT_KEY_KEEP),
ddf19c
 	FUSE_OPT_KEY("debug",		FUSE_OPT_KEY_KEEP),
ddf19c
 	FUSE_HELPER_OPT("-f",		foreground),
ddf19c
-	FUSE_HELPER_OPT("-s",		singlethread),
ddf19c
 	FUSE_HELPER_OPT("fsname=",	nodefault_subtype),
ddf19c
 	FUSE_OPT_KEY("fsname=",		FUSE_OPT_KEY_KEEP),
ddf19c
-#ifndef __FreeBSD__
ddf19c
 	FUSE_HELPER_OPT("subtype=",	nodefault_subtype),
ddf19c
 	FUSE_OPT_KEY("subtype=",	FUSE_OPT_KEY_KEEP),
ddf19c
-#endif
ddf19c
-	FUSE_HELPER_OPT("clone_fd",	clone_fd),
ddf19c
 	FUSE_HELPER_OPT("max_idle_threads=%u", max_idle_threads),
ddf19c
 	FUSE_OPT_END
ddf19c
 };
ddf19c
@@ -132,9 +128,6 @@ void fuse_cmdline_help(void)
ddf19c
 	       "    -V   --version         print version\n"
ddf19c
 	       "    -d   -o debug          enable debug output (implies -f)\n"
ddf19c
 	       "    -f                     foreground operation\n"
ddf19c
-	       "    -s                     disable multi-threaded operation\n"
ddf19c
-	       "    -o clone_fd            use separate fuse device fd for each thread\n"
ddf19c
-	       "                           (may improve performance)\n"
ddf19c
 	       "    -o max_idle_threads    the maximum number of idle worker threads\n"
ddf19c
 	       "                           allowed (default: 10)\n");
ddf19c
 }
ddf19c
@@ -171,34 +164,6 @@ static int fuse_helper_opt_proc(void *data, const char *arg, int key,
ddf19c
 	}
ddf19c
 }
ddf19c
 
ddf19c
-/* Under FreeBSD, there is no subtype option so this
ddf19c
-   function actually sets the fsname */
ddf19c
-static int add_default_subtype(const char *progname, struct fuse_args *args)
ddf19c
-{
ddf19c
-	int res;
ddf19c
-	char *subtype_opt;
ddf19c
-
ddf19c
-	const char *basename = strrchr(progname, '/');
ddf19c
-	if (basename == NULL)
ddf19c
-		basename = progname;
ddf19c
-	else if (basename[1] != '\0')
ddf19c
-		basename++;
ddf19c
-
ddf19c
-	subtype_opt = (char *) malloc(strlen(basename) + 64);
ddf19c
-	if (subtype_opt == NULL) {
ddf19c
-		fuse_log(FUSE_LOG_ERR, "fuse: memory allocation failed\n");
ddf19c
-		return -1;
ddf19c
-	}
ddf19c
-#ifdef __FreeBSD__
ddf19c
-	sprintf(subtype_opt, "-ofsname=%s", basename);
ddf19c
-#else
ddf19c
-	sprintf(subtype_opt, "-osubtype=%s", basename);
ddf19c
-#endif
ddf19c
-	res = fuse_opt_add_arg(args, subtype_opt);
ddf19c
-	free(subtype_opt);
ddf19c
-	return res;
ddf19c
-}
ddf19c
-
ddf19c
 int fuse_parse_cmdline(struct fuse_args *args,
ddf19c
 		       struct fuse_cmdline_opts *opts)
ddf19c
 {
ddf19c
@@ -210,14 +175,6 @@ int fuse_parse_cmdline(struct fuse_args *args,
ddf19c
 			   fuse_helper_opt_proc) == -1)
ddf19c
 		return -1;
ddf19c
 
ddf19c
-	/* *Linux*: if neither -o subtype nor -o fsname are specified,
ddf19c
-	   set subtype to program's basename.
ddf19c
-	   *FreeBSD*: if fsname is not specified, set to program's
ddf19c
-	   basename. */
ddf19c
-	if (!opts->nodefault_subtype)
ddf19c
-		if (add_default_subtype(args->argv[0], args) == -1)
ddf19c
-			return -1;
ddf19c
-
ddf19c
 	return 0;
ddf19c
 }
ddf19c
 
ddf19c
@@ -276,88 +233,6 @@ int fuse_daemonize(int foreground)
ddf19c
 	return 0;
ddf19c
 }
ddf19c
 
ddf19c
-int fuse_main_real(int argc, char *argv[], const struct fuse_operations *op,
ddf19c
-		   size_t op_size, void *user_data)
ddf19c
-{
ddf19c
-	struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
ddf19c
-	struct fuse *fuse;
ddf19c
-	struct fuse_cmdline_opts opts;
ddf19c
-	int res;
ddf19c
-
ddf19c
-	if (fuse_parse_cmdline(&args, &opts) != 0)
ddf19c
-		return 1;
ddf19c
-
ddf19c
-	if (opts.show_version) {
ddf19c
-		printf("FUSE library version %s\n", PACKAGE_VERSION);
ddf19c
-		fuse_lowlevel_version();
ddf19c
-		res = 0;
ddf19c
-		goto out1;
ddf19c
-	}
ddf19c
-
ddf19c
-	if (opts.show_help) {
ddf19c
-		if(args.argv[0][0] != '\0')
ddf19c
-			printf("usage: %s [options] <mountpoint>\n\n",
ddf19c
-			       args.argv[0]);
ddf19c
-		printf("FUSE options:\n");
ddf19c
-		fuse_cmdline_help();
ddf19c
-		fuse_lib_help(&args);
ddf19c
-		res = 0;
ddf19c
-		goto out1;
ddf19c
-	}
ddf19c
-
ddf19c
-	if (!opts.show_help &&
ddf19c
-	    !opts.mountpoint) {
ddf19c
-		fuse_log(FUSE_LOG_ERR, "error: no mountpoint specified\n");
ddf19c
-		res = 2;
ddf19c
-		goto out1;
ddf19c
-	}
ddf19c
-
ddf19c
-
ddf19c
-	fuse = fuse_new_31(&args, op, op_size, user_data);
ddf19c
-	if (fuse == NULL) {
ddf19c
-		res = 3;
ddf19c
-		goto out1;
ddf19c
-	}
ddf19c
-
ddf19c
-	if (fuse_mount(fuse,opts.mountpoint) != 0) {
ddf19c
-		res = 4;
ddf19c
-		goto out2;
ddf19c
-	}
ddf19c
-
ddf19c
-	if (fuse_daemonize(opts.foreground) != 0) {
ddf19c
-		res = 5;
ddf19c
-		goto out3;
ddf19c
-	}
ddf19c
-
ddf19c
-	struct fuse_session *se = fuse_get_session(fuse);
ddf19c
-	if (fuse_set_signal_handlers(se) != 0) {
ddf19c
-		res = 6;
ddf19c
-		goto out3;
ddf19c
-	}
ddf19c
-
ddf19c
-	if (opts.singlethread)
ddf19c
-		res = fuse_loop(fuse);
ddf19c
-	else {
ddf19c
-		struct fuse_loop_config loop_config;
ddf19c
-		loop_config.clone_fd = opts.clone_fd;
ddf19c
-		loop_config.max_idle_threads = opts.max_idle_threads;
ddf19c
-		res = fuse_loop_mt_32(fuse, &loop_config);
ddf19c
-	}
ddf19c
-	if (res)
ddf19c
-		res = 7;
ddf19c
-
ddf19c
-	fuse_remove_signal_handlers(se);
ddf19c
-out3:
ddf19c
-	fuse_unmount(fuse);
ddf19c
-out2:
ddf19c
-	fuse_destroy(fuse);
ddf19c
-out1:
ddf19c
-	free(opts.mountpoint);
ddf19c
-	fuse_opt_free_args(&args);
ddf19c
-	return res;
ddf19c
-}
ddf19c
-
ddf19c
-
ddf19c
 void fuse_apply_conn_info_opts(struct fuse_conn_info_opts *opts,
ddf19c
 			       struct fuse_conn_info *conn)
ddf19c
 {
ddf19c
@@ -420,21 +295,3 @@ struct fuse_conn_info_opts* fuse_parse_conn_info_opts(struct fuse_args *args)
ddf19c
 	}
ddf19c
 	return opts;
ddf19c
 }
ddf19c
-
ddf19c
-int fuse_open_channel(const char *mountpoint, const char* options)
ddf19c
-{
ddf19c
-	struct mount_opts *opts = NULL;
ddf19c
-	int fd = -1;
ddf19c
-	const char *argv[] = { "", "-o", options };
ddf19c
-	int argc = sizeof(argv) / sizeof(argv[0]);
ddf19c
-	struct fuse_args args = FUSE_ARGS_INIT(argc, (char**) argv);
ddf19c
-
ddf19c
-	opts = parse_mount_opts(&args);
ddf19c
-	if (opts == NULL)
ddf19c
-		return -1;
ddf19c
-
ddf19c
-	fd = fuse_kern_mount(mountpoint, opts);
ddf19c
-	destroy_mount_opts(opts);
ddf19c
-
ddf19c
-	return fd;
ddf19c
-}
ddf19c
diff --git a/tools/virtiofsd/passthrough_helpers.h b/tools/virtiofsd/passthrough_helpers.h
ddf19c
index 6b77c33..7c5f561 100644
ddf19c
--- a/tools/virtiofsd/passthrough_helpers.h
ddf19c
+++ b/tools/virtiofsd/passthrough_helpers.h
ddf19c
@@ -42,32 +42,6 @@ static int mknod_wrapper(int dirfd, const char *path, const char *link,
ddf19c
 		res = symlinkat(link, dirfd, path);
ddf19c
 	} else if (S_ISFIFO(mode)) {
ddf19c
 		res = mkfifoat(dirfd, path, mode);
ddf19c
-#ifdef __FreeBSD__
ddf19c
-	} else if (S_ISSOCK(mode)) {
ddf19c
-		struct sockaddr_un su;
ddf19c
-		int fd;
ddf19c
-
ddf19c
-		if (strlen(path) >= sizeof(su.sun_path)) {
ddf19c
-			errno = ENAMETOOLONG;
ddf19c
-			return -1;
ddf19c
-		}
ddf19c
-		fd = socket(AF_UNIX, SOCK_STREAM, 0);
ddf19c
-		if (fd >= 0) {
ddf19c
-			/*
ddf19c
-			 * We must bind the socket to the underlying file
ddf19c
-			 * system to create the socket file, even though
ddf19c
-			 * we'll never listen on this socket.
ddf19c
-			 */
ddf19c
-			su.sun_family = AF_UNIX;
ddf19c
-			strncpy(su.sun_path, path, sizeof(su.sun_path));
ddf19c
-			res = bindat(dirfd, fd, (struct sockaddr*)&su,
ddf19c
-				sizeof(su));
ddf19c
-			if (res == 0)
ddf19c
-				close(fd);
ddf19c
-		} else {
ddf19c
-			res = -1;
ddf19c
-		}
ddf19c
-#endif
ddf19c
 	} else {
ddf19c
 		res = mknodat(dirfd, path, mode, rdev);
ddf19c
 	}
ddf19c
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
ddf19c
index e1a6056..e5f7115 100644
ddf19c
--- a/tools/virtiofsd/passthrough_ll.c
ddf19c
+++ b/tools/virtiofsd/passthrough_ll.c
ddf19c
@@ -1240,7 +1240,6 @@ int main(int argc, char *argv[])
ddf19c
 		ret = 0;
ddf19c
 		goto err_out1;
ddf19c
 	} else if (opts.show_version) {
ddf19c
-		printf("FUSE library version %s\n", fuse_pkgversion());
ddf19c
 		fuse_lowlevel_version();
ddf19c
 		ret = 0;
ddf19c
 		goto err_out1;
ddf19c
-- 
ddf19c
1.8.3.1
ddf19c