From 54e529adb9e61e652ad66130f7f564cf9f9fb33b Mon Sep 17 00:00:00 2001 From: syl Date: Thu, 2 Jan 2014 15:39:12 +0000 Subject: [PATCH] Call fuse callbacks on FBT_INIT and FBT_DESTROY. Issue reported by Helg Bredow, thanks! With inputs from tedu@ ok tedu@ --- lib/libfuse/fuse_ops.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/libfuse/fuse_ops.c b/lib/libfuse/fuse_ops.c index 13fbcb629fd..88c6bb28b5f 100644 --- a/lib/libfuse/fuse_ops.c +++ b/lib/libfuse/fuse_ops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fuse_ops.c,v 1.18 2013/12/20 22:03:26 syl Exp $ */ +/* $OpenBSD: fuse_ops.c,v 1.19 2014/01/02 15:39:12 syl Exp $ */ /* * Copyright (c) 2013 Sylvestre Gallon * @@ -84,9 +84,19 @@ update_vattr(struct fuse *f, struct vattr *attr, const char *realname, } static int -ifuse_ops_init(void) +ifuse_ops_init(struct fuse *f) { + struct fuse_conn_info fci; + DPRINTF("Opcode:\tinit\n"); + + if (f->op.init) { + bzero(&fci, sizeof fci); + fci.proto_minor = FUSE_MINOR_VERSION; + fci.proto_major = FUSE_MAJOR_VERSION; + + f->op.init(&fci); + } return (0); } @@ -770,8 +780,16 @@ ifuse_ops_rename(struct fuse *f, struct fusebuf *fbuf) static int ifuse_ops_destroy(struct fuse *f) { + struct fuse_context *ctx; + DPRINTF("Opcode:\tdestroy\n"); + if (f->op.destroy) { + ctx = fuse_get_context(); + + f->op.destroy((ctx)?ctx->private_data:NULL); + } + f->fc->dead = 1; return (0); @@ -840,7 +858,7 @@ ifuse_exec_opcode(struct fuse *f, struct fusebuf *fbuf) ret = ifuse_ops_release(f, fbuf); break; case FBT_INIT: - ret = ifuse_ops_init(); + ret = ifuse_ops_init(f); break; case FBT_OPENDIR: ret = ifuse_ops_opendir(f, fbuf); -- 2.20.1