Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/mount_qemufwcfg lib/librefuse: Implement FUSE session A...
details: https://anonhg.NetBSD.org/src/rev/f0f59e886d59
branches: trunk
changeset: 359758:f0f59e886d59
user: pho <pho%NetBSD.org@localhost>
date: Sat Jan 22 07:53:05 2022 +0000
description:
lib/librefuse: Implement FUSE session API and its signal handling functionality
diffstat:
distrib/sets/lists/base/mi | 3 +-
distrib/sets/lists/comp/mi | 3 +-
etc/mtree/NetBSD.dist.base | 3 +-
lib/librefuse/Makefile | 6 +-
lib/librefuse/fuse.h | 8 +-
lib/librefuse/fuse_internal.h | 17 +-
lib/librefuse/refuse.c | 6 +-
lib/librefuse/refuse/Makefile.inc | 7 +
lib/librefuse/refuse/session.c | 70 ++++++++
lib/librefuse/refuse/session.h | 69 +++++++
lib/librefuse/refuse_signals.c | 331 ++++++++++++++++++++++++++++++++++++++
sbin/mount_qemufwcfg/fwcfg.c | 5 +-
12 files changed, 515 insertions(+), 13 deletions(-)
diffs (truncated from 670 to 300 lines):
diff -r 2309b0ca972d -r f0f59e886d59 distrib/sets/lists/base/mi
--- a/distrib/sets/lists/base/mi Sat Jan 22 07:38:45 2022 +0000
+++ b/distrib/sets/lists/base/mi Sat Jan 22 07:53:05 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1287 2022/01/10 10:02:30 martin Exp $
+# $NetBSD: mi,v 1.1288 2022/01/22 07:53:05 pho Exp $
#
# Note: Don't delete entries from here - mark them as "obsolete" instead,
# unless otherwise stated below.
@@ -1147,6 +1147,7 @@
./usr/include/protocols base-c-usr
./usr/include/quota base-obsolete obsolete
./usr/include/readline base-c-usr
+./usr/include/refuse base-refuse-usr
./usr/include/rpc base-c-usr
./usr/include/rpcsvc base-c-usr
./usr/include/rump base-c-usr
diff -r 2309b0ca972d -r f0f59e886d59 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi Sat Jan 22 07:38:45 2022 +0000
+++ b/distrib/sets/lists/comp/mi Sat Jan 22 07:53:05 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.2404 2022/01/22 07:38:45 pho Exp $
+# $NetBSD: mi,v 1.2405 2022/01/22 07:53:05 pho Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
./etc/mtree/set.comp comp-sys-root
@@ -3092,6 +3092,7 @@
./usr/include/readline.h comp-obsolete obsolete
./usr/include/readline/history.h comp-c-include
./usr/include/readline/readline.h comp-c-include
+./usr/include/refuse/session.h comp-refuse-include
./usr/include/regex.h comp-c-include
./usr/include/regexp.h comp-c-include
./usr/include/res_update.h comp-c-include
diff -r 2309b0ca972d -r f0f59e886d59 etc/mtree/NetBSD.dist.base
--- a/etc/mtree/NetBSD.dist.base Sat Jan 22 07:38:45 2022 +0000
+++ b/etc/mtree/NetBSD.dist.base Sat Jan 22 07:53:05 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: NetBSD.dist.base,v 1.240 2021/12/13 23:59:35 maya Exp $
+# $NetBSD: NetBSD.dist.base,v 1.241 2022/01/22 07:53:06 pho Exp $
# @(#)4.4BSD.dist 8.1 (Berkeley) 6/13/93
# Do not customize this file as it may be overwritten on upgrades.
@@ -326,6 +326,7 @@
./usr/include/prop
./usr/include/protocols
./usr/include/readline
+./usr/include/refuse
./usr/include/rpc
./usr/include/rpcsvc
./usr/include/rump
diff -r 2309b0ca972d -r f0f59e886d59 lib/librefuse/Makefile
--- a/lib/librefuse/Makefile Sat Jan 22 07:38:45 2022 +0000
+++ b/lib/librefuse/Makefile Sat Jan 22 07:53:05 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.13 2022/01/22 07:38:45 pho Exp $
+# $NetBSD: Makefile,v 1.14 2022/01/22 07:53:06 pho Exp $
USE_FORT?= yes # data driven bugs?
@@ -13,10 +13,12 @@
CFLAGS+= ${FUSE_OPT_DEBUG_FLAGS}
CPPFLAGS+= -I${.CURDIR}
SRCS= refuse.c refuse_log.c refuse_lowlevel.c
-SRCS+= refuse_opt.c
+SRCS+= refuse_opt.c refuse_signals.c
MAN= refuse.3
WARNS?= 5
INCS= fuse.h fuse_opt.h fuse_log.h fuse_lowlevel.h
INCSDIR= /usr/include
+.include "${.CURDIR}/refuse/Makefile.inc"
+
.include <bsd.lib.mk>
diff -r 2309b0ca972d -r f0f59e886d59 lib/librefuse/fuse.h
--- a/lib/librefuse/fuse.h Sat Jan 22 07:38:45 2022 +0000
+++ b/lib/librefuse/fuse.h Sat Jan 22 07:53:05 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fuse.h,v 1.24 2021/12/04 06:42:39 pho Exp $ */
+/* $NetBSD: fuse.h,v 1.25 2022/01/22 07:53:06 pho Exp $ */
/*
* Copyright © 2007 Alistair Crooks. All rights reserved.
@@ -30,9 +30,11 @@
#ifndef FUSE_H_
#define FUSE_H_ 20211204
+#include <refuse/session.h>
+#include <sys/cdefs.h>
+#include <sys/stat.h>
+#include <sys/statvfs.h>
#include <sys/types.h>
-
-#include <puffs.h>
#include <utime.h>
/* The latest version of FUSE API currently provided by refuse. */
diff -r 2309b0ca972d -r f0f59e886d59 lib/librefuse/fuse_internal.h
--- a/lib/librefuse/fuse_internal.h Sat Jan 22 07:38:45 2022 +0000
+++ b/lib/librefuse/fuse_internal.h Sat Jan 22 07:53:05 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fuse_internal.h,v 1.1 2021/12/04 06:42:39 pho Exp $ */
+/* $NetBSD: fuse_internal.h,v 1.2 2022/01/22 07:53:06 pho Exp $ */
/*
* Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -38,5 +38,20 @@
#include <fuse.h>
#include <fuse_lowlevel.h>
+#include <sys/cdefs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Internal functions, hidden from users */
+__BEGIN_HIDDEN_DECLS
+int __fuse_set_signal_handlers(struct fuse* fuse);
+int __fuse_remove_signal_handlers(struct fuse* fuse);
+__END_HIDDEN_DECLS
+
+#ifdef __cplusplus
+}
+#endif
#endif
diff -r 2309b0ca972d -r f0f59e886d59 lib/librefuse/refuse.c
--- a/lib/librefuse/refuse.c Sat Jan 22 07:38:45 2022 +0000
+++ b/lib/librefuse/refuse.c Sat Jan 22 07:53:05 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: refuse.c,v 1.103 2021/12/04 06:42:39 pho Exp $ */
+/* $NetBSD: refuse.c,v 1.104 2022/01/22 07:53:06 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.103 2021/12/04 06:42:39 pho Exp $");
+__RCSID("$NetBSD: refuse.c,v 1.104 2022/01/22 07:53:06 pho Exp $");
#endif /* !lint */
/* We emit a compiler warning for anyone including <fuse.h> without
@@ -47,6 +47,8 @@
#include <fuse_internal.h>
#include <fuse_opt.h>
#include <paths.h>
+#include <puffs.h>
+#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
diff -r 2309b0ca972d -r f0f59e886d59 lib/librefuse/refuse/Makefile.inc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/librefuse/refuse/Makefile.inc Sat Jan 22 07:53:05 2022 +0000
@@ -0,0 +1,7 @@
+# $NetBSD: Makefile.inc,v 1.1 2022/01/22 07:53:06 pho Exp $
+
+.PATH: ${.CURDIR}/refuse
+
+SRCS+= session.c
+
+INCS+= refuse/session.h
diff -r 2309b0ca972d -r f0f59e886d59 lib/librefuse/refuse/session.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/librefuse/refuse/session.c Sat Jan 22 07:53:05 2022 +0000
@@ -0,0 +1,70 @@
+/* $NetBSD: session.c,v 1.1 2022/01/22 07:53:06 pho Exp $ */
+
+/*
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if !defined(lint)
+__RCSID("$NetBSD: session.c,v 1.1 2022/01/22 07:53:06 pho Exp $");
+#endif /* !lint */
+
+#include <err.h>
+#include <fuse_internal.h>
+#include <puffs.h>
+
+/* The documentation for FUSE is not clear as to what "struct fuse_session" is,
+ * why it exists, or how it's different from "struct fuse". For now we leave it
+ * undefined (i.e. an incomplete type) and treat "struct fuse_session *" as
+ * being identical to "struct fuse *". */
+
+struct fuse_session *
+fuse_get_session(struct fuse *f) {
+ return (struct fuse_session*)f;
+}
+
+int
+fuse_session_fd(struct fuse_session *se) {
+ struct fuse* fuse = (struct fuse*)se;
+
+ /* We don't want to expose this to users, but filesystems in the wild often
+ * wants to set FD_CLOEXEC on it. Hope they don't assume it's the real
+ * /dev/fuse, because it's actually /dev/puffs in our implementation. */
+ return puffs_getselectable(fuse->pu);
+}
+
+int
+fuse_set_signal_handlers(struct fuse_session *se) {
+ return __fuse_set_signal_handlers((struct fuse*)se);
+}
+
+void
+fuse_remove_signal_handlers(struct fuse_session *se) {
+ if (__fuse_remove_signal_handlers((struct fuse*)se) == -1)
+ warn("%s: failed to remove signal handlers", __func__);
+}
diff -r 2309b0ca972d -r f0f59e886d59 lib/librefuse/refuse/session.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/librefuse/refuse/session.h Sat Jan 22 07:53:05 2022 +0000
@@ -0,0 +1,69 @@
+/* $NetBSD: session.h,v 1.1 2022/01/22 07:53:06 pho Exp $ */
+
+/*
+ * Copyright (c) 2021 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#if !defined(_FUSE_SESSION_H_)
+#define _FUSE_SESSION_H_
+
+/* FUSE session API
+ */
+
+#if !defined(FUSE_H_)
+# error Do not include this header directly. Include <fuse.h> instead.
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Forward declarations */
+struct fuse;
+
+/* A private structure appeared on FUSE 2.4. */
+struct fuse_session;
+
+/* Get a session from a fuse object. Appeared on FUSE 2.6. */
+struct fuse_session *fuse_get_session(struct fuse *f);
+
+/* Get the file descriptor for communicaiton with kernel. Appeared on
+ * FUSE 3.0. */
+int fuse_session_fd(struct fuse_session *se);
+
Home |
Main Index |
Thread Index |
Old Index