summaryrefslogtreecommitdiff
path: root/lib/librefuse
diff options
context:
space:
mode:
authorpho <pho@NetBSD.org>2021-11-30 12:13:12 +0000
committerpho <pho@NetBSD.org>2021-11-30 12:13:12 +0000
commit45a48eb12bbfbc7e0ac4c1294682492cc69d115e (patch)
treefa82668cdf5d687270fce4b95f753cca49e891db /lib/librefuse
parent3e9034f673814d3fc5277382ef154dcc260664ab (diff)
Move the call of fuse_operations::init() from fuse_new() to fuse_loop()
Prior to this change we were calling init() before daemonizing the process. Some filesystems call chdir(2) in init() but fuse_daemonize() call chdir("/"), which breaks assumptions about the state of the process.
Diffstat (limited to 'lib/librefuse')
-rw-r--r--lib/librefuse/refuse.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/librefuse/refuse.c b/lib/librefuse/refuse.c
index deb8a750250..588bbb0369c 100644
--- a/lib/librefuse/refuse.c
+++ b/lib/librefuse/refuse.c
@@ -1,4 +1,4 @@
-/* $NetBSD: refuse.c,v 1.101 2019/09/23 12:00:57 christos Exp $ */
+/* $NetBSD: refuse.c,v 1.102 2021/11/30 12:13:12 pho Exp $ */
/*
* Copyright © 2007 Alistair Crooks. All rights reserved.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
-__RCSID("$NetBSD: refuse.c,v 1.101 2019/09/23 12:00:57 christos Exp $");
+__RCSID("$NetBSD: refuse.c,v 1.102 2021/11/30 12:13:12 pho Exp $");
#endif /* !lint */
#include <sys/types.h>
@@ -1276,9 +1276,6 @@ fuse_new(struct fuse_args *args,
fusectx->pid = 0;
fusectx->private_data = userdata;
- if (fuse->op.init != NULL)
- fusectx->private_data = fuse->op.init(NULL); /* XXX */
-
/* initialise the puffs operations structure */
PUFFSOP_INIT(pops);
@@ -1328,6 +1325,18 @@ fuse_new(struct fuse_args *args,
int
fuse_loop(struct fuse *fuse)
{
+ if (fuse->op.init != NULL) {
+ struct fuse_context *fusectx = fuse_get_context();
+
+ /* XXX: prototype incompatible with FUSE: a secondary argument
+ * of struct fuse_config* needs to be passed.
+ *
+ * XXX: Our struct fuse_conn_info is not fully compatible with
+ * the FUSE one.
+ */
+ fusectx->private_data = fuse->op.init(NULL);
+ }
+
return puffs_mainloop(fuse->pu);
}