Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libperfuse libperfuse(3) is a PUFFS relay to FUSE. In or...
details: https://anonhg.NetBSD.org/src/rev/6cbf811739fd
branches: trunk
changeset: 757316:6cbf811739fd
user: manu <manu%NetBSD.org@localhost>
date: Wed Aug 25 07:16:00 2010 +0000
description:
libperfuse(3) is a PUFFS relay to FUSE. In order to use it,
FUSE filesystem must be patched to #include <perfuse.h> in the source
files that open /dev/fuse and perform the mount(2) system call. The
FUSE filesystem must be linked with -lperfuse.
libperfuse(3) implements the FUSE kernel interface, on which libfuse or
any FUSE filesystem that opens /dev/fuse directly can be used.
For now, an external daemon called perfused(8) is used. This may change
in the future.
diffstat:
lib/libperfuse/Makefile | 14 +
lib/libperfuse/debug.c | 94 +
lib/libperfuse/fuse.h | 496 +++++++++
lib/libperfuse/libperfuse.3 | 117 ++
lib/libperfuse/ops.c | 2133 +++++++++++++++++++++++++++++++++++++++++
lib/libperfuse/perfuse.c | 416 +++++++
lib/libperfuse/perfuse.h | 45 +
lib/libperfuse/perfuse_if.h | 201 +++
lib/libperfuse/perfuse_priv.h | 215 ++++
lib/libperfuse/shlib_version | 4 +
lib/libperfuse/subr.c | 160 +++
11 files changed, 3895 insertions(+), 0 deletions(-)
diffs (truncated from 3939 to 300 lines):
diff -r 6af623ca712f -r 6cbf811739fd lib/libperfuse/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libperfuse/Makefile Wed Aug 25 07:16:00 2010 +0000
@@ -0,0 +1,14 @@
+LIB= perfuse
+LIBDPLIBS+= puffs /usr/src/lib/libpuffs
+
+
+PERFUSE_OPT_DEBUG_FLAGS= -g -DPERFUSE_DEBUG
+
+CFLAGS+= ${PERFUSE_OPT_DEBUG_FLAGS}
+SRCS= perfuse.c ops.c subr.c debug.c
+MAN= libperfuse.3
+WARNS= 4
+INCS= perfuse.h
+INCSDIR= /usr/include
+
+.include <bsd.lib.mk>
diff -r 6af623ca712f -r 6cbf811739fd lib/libperfuse/debug.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libperfuse/debug.c Wed Aug 25 07:16:00 2010 +0000
@@ -0,0 +1,94 @@
+/* $NetBSD: debug.c,v 1.1 2010/08/25 07:16:00 manu Exp $ */
+
+/*-
+ * Copyright (c) 2010 Emmanuel Dreyfus. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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 <puffs.h>
+#include <sys/types.h>
+
+#include "perfuse_if.h"
+#include "fuse.h"
+
+struct perfuse_opcode {
+ int opcode;
+ const char *opname;
+};
+
+const struct perfuse_opcode perfuse_opcode[] = {
+ { FUSE_LOOKUP, "LOOKUP" },
+ { FUSE_FORGET, "FORGET" },
+ { FUSE_GETATTR, "GETATTR" },
+ { FUSE_SETATTR, "SETATTR" },
+ { FUSE_READLINK, "READLINK" },
+ { FUSE_SYMLINK, "SYMLINK" },
+ { FUSE_MKNOD, "MKNOD" },
+ { FUSE_MKDIR, "MKDIR" },
+ { FUSE_UNLINK, "UNLINK" },
+ { FUSE_RMDIR, "RMDIR" },
+ { FUSE_RENAME, "RENAME" },
+ { FUSE_LINK, "LINK" },
+ { FUSE_OPEN, "OPEN" },
+ { FUSE_READ, "READ" },
+ { FUSE_WRITE, "WRITE" },
+ { FUSE_STATFS, "STATFS" },
+ { FUSE_RELEASE, "RELEASE" },
+ { FUSE_FSYNC, "FSYNC" },
+ { FUSE_SETXATTR, "SETXATTR" },
+ { FUSE_GETXATTR, "GETXATTR" },
+ { FUSE_LISTXATTR, "LISTXATTR" },
+ { FUSE_REMOVEXATTR, "REMOVEXATTR" },
+ { FUSE_FLUSH, "FLUSH" },
+ { FUSE_INIT, "INIT" },
+ { FUSE_OPENDIR, "OPENDIR" },
+ { FUSE_READDIR, "READDIR" },
+ { FUSE_RELEASEDIR, "RELEASEDIR" },
+ { FUSE_FSYNCDIR, "FSYNCDIR" },
+ { FUSE_GETLK, "GETLK" },
+ { FUSE_SETLK, "SETLK" },
+ { FUSE_SETLKW, "SETLKW" },
+ { FUSE_ACCESS, "ACCESS" },
+ { FUSE_CREATE, "CREATE" },
+ { FUSE_INTERRUPT, "INTERRUPT" },
+ { FUSE_BMAP, "BMAP" },
+ { FUSE_DESTROY, "DESTROY" },
+ { FUSE_IOCTL, "IOCTL" },
+ { FUSE_POLL, "POLL" },
+ { FUSE_CUSE_INIT, "CUSE_INIT" },
+ { 0, "UNKNOWN" },
+};
+
+const char *
+perfuse_opname(opcode)
+ int opcode;
+{
+ const struct perfuse_opcode *po;
+
+ for (po = perfuse_opcode; po->opcode; po++) {
+ if (po->opcode == opcode)
+ return po->opname;
+ }
+
+ return po->opname; /* "UNKNOWN" */
+}
diff -r 6af623ca712f -r 6cbf811739fd lib/libperfuse/fuse.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libperfuse/fuse.h Wed Aug 25 07:16:00 2010 +0000
@@ -0,0 +1,496 @@
+/* $NetBSD: fuse.h,v 1.1 2010/08/25 07:16:00 manu Exp $ */
+
+/*-
+ * Copyright (c) 2010 Emmanuel Dreyfus. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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.
+ */
+
+#ifndef _FUSE_H
+#define _FUSE_H
+
+#define FUSE_KERNEL_VERSION 7
+#define FUSE_KERNEL_MINOR_VERSION 12
+#define FUSE_ROOT_ID 1
+#define FUSE_UNKNOWN_FH (uint64_t)0
+
+#define FUSE_MIN_BUFSIZE 0x21000
+#define FUSE_PREF_BUFSIZE (PAGE_SIZE + 0x1000)
+#define FUSE_BUFSIZE MAX(FUSE_PREF_BUFSIZE, FUSE_MIN_BUFSIZE)
+
+struct fuse_attr {
+ uint64_t ino;
+ uint64_t size;
+ uint64_t blocks;
+ uint64_t atime;
+ uint64_t mtime;
+ uint64_t ctime;
+ uint32_t atimensec;
+ uint32_t mtimensec;
+ uint32_t ctimensec;
+ uint32_t mode;
+ uint32_t nlink;
+ uint32_t uid;
+ uint32_t gid;
+ uint32_t rdev;
+ uint32_t blksize;
+ uint32_t padding;
+};
+
+struct fuse_kstatfs {
+ uint64_t blocks;
+ uint64_t bfree;
+ uint64_t bavail;
+ uint64_t files;
+ uint64_t ffree;
+ uint32_t bsize;
+ uint32_t namelen;
+ uint32_t frsize;
+ uint32_t padding;
+ uint32_t spare[6];
+};
+
+struct fuse_file_lock {
+ uint64_t start;
+ uint64_t end;
+ uint32_t type;
+ uint32_t pid;
+};
+
+/*
+ * Various flags
+ */
+#define FUSE_FATTR_MODE 0x0001
+#define FUSE_FATTR_UID 0x0002
+#define FUSE_FATTR_GID 0x0004
+#define FUSE_FATTR_SIZE 0x0008
+#define FUSE_FATTR_ATIME 0x0010
+#define FUSE_FATTR_MTIME 0x0020
+#define FUSE_FATTR_FH 0x0040
+#define FUSE_FATTR_ATIME_NOW 0x0080
+#define FUSE_FATTR_MTIME_NOW 0x0100
+#define FUSE_FATTR_LOCKOWNER 0x0200
+
+#define FUSE_FOPEN_DIRECT_IO 0x0001
+#define FUSE_FOPEN_KEEP_CACHE 0x0002
+#define FUSE_FOPEN_NONSEEKABLE 0x0004
+
+#define FUSE_ASYNC_READ 0x0001
+#define FUSE_POSIX_LOCKS 0x0002
+#define FUSE_FILE_OPS 0x0004
+#define FUSE_ATOMIC_O_TRUNC 0x0008
+#define FUSE_EXPORT_SUPPORT 0x0010
+#define FUSE_BIG_WRITES 0x0020
+#define FUSE_DONT_MASK 0x0040
+
+#define FUSE_CUSE_UNRESTRICTED_IOCTL 0x0001
+
+#define FUSE_RELEASE_FLUSH 0x0001
+
+#define FUSE_GETATTR_FH 0x0001
+
+#define FUSE_LK_FLOCK 0x0001
+
+#define FUSE_WRITE_CACHE 0x0001
+#define FUSE_WRITE_LOCKOWNER 0x0002
+
+#define FUSE_READ_LOCKOWNER 0x0002
+
+#define FUSE_IOCTL_COMPAT 0x0001
+#define FUSE_IOCTL_UNRESTRICTED 0x0002
+#define FUSE_IOCTL_RETRY 0x0004
+
+#define FUSE_IOCTL_MAX_IOV 256
+
+#define FUSE_POLL_SCHEDULE_NOTIFY 0x0001
+
+enum fuse_opcode {
+ FUSE_LOOKUP = 1,
+ FUSE_FORGET = 2,
+ FUSE_GETATTR = 3,
+ FUSE_SETATTR = 4,
+ FUSE_READLINK = 5,
+ FUSE_SYMLINK = 6,
+ FUSE_MKNOD = 8,
+ FUSE_MKDIR = 9,
+ FUSE_UNLINK = 10,
+ FUSE_RMDIR = 11,
+ FUSE_RENAME = 12,
+ FUSE_LINK = 13,
+ FUSE_OPEN = 14,
+ FUSE_READ = 15,
+ FUSE_WRITE = 16,
+ FUSE_STATFS = 17,
+ FUSE_RELEASE = 18,
+ FUSE_FSYNC = 20,
+ FUSE_SETXATTR = 21,
+ FUSE_GETXATTR = 22,
+ FUSE_LISTXATTR = 23,
+ FUSE_REMOVEXATTR = 24,
+ FUSE_FLUSH = 25,
+ FUSE_INIT = 26,
+ FUSE_OPENDIR = 27,
+ FUSE_READDIR = 28,
+ FUSE_RELEASEDIR = 29,
+ FUSE_FSYNCDIR = 30,
+ FUSE_GETLK = 31,
+ FUSE_SETLK = 32,
+ FUSE_SETLKW = 33,
+ FUSE_ACCESS = 34,
+ FUSE_CREATE = 35,
+ FUSE_INTERRUPT = 36,
+ FUSE_BMAP = 37,
+ FUSE_DESTROY = 38,
+ FUSE_IOCTL = 39,
+ FUSE_POLL = 40,
+
+ FUSE_CUSE_INIT = 4096
+};
+
+enum fuse_notify_code {
+ FUSE_NOTIFY_POLL = 1,
+ FUSE_NOTIFY_INVAL_INODE = 2,
+ FUSE_NOTIFY_INVAL_ENTRY = 3,
+ FUSE_NOTIFY_CODE_MAX
+};
+
+#define FUSE_MIN_READ_BUFFER 8192
+
+#define FUSE_COMPAT_ENTRY_OUT_SIZE 120
+
+struct fuse_entry_out {
Home |
Main Index |
Thread Index |
Old Index