Module Name: src Committed By: pho Date: Tue Nov 30 12:13:12 UTC 2021
Modified Files: src/lib/librefuse: refuse.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.101 -r1.102 src/lib/librefuse/refuse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/librefuse/refuse.c diff -u src/lib/librefuse/refuse.c:1.101 src/lib/librefuse/refuse.c:1.102 --- src/lib/librefuse/refuse.c:1.101 Mon Sep 23 12:00:57 2019 +++ src/lib/librefuse/refuse.c Tue Nov 30 12:13:12 2021 @@ -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); }