Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/puffs/rump_smbfs Add rump_smbfs. It's innards are ...



details:   https://anonhg.NetBSD.org/src/rev/0bc934685380
branches:  trunk
changeset: 747235:0bc934685380
user:      pooka <pooka%NetBSD.org@localhost>
date:      Sun Sep 06 20:26:47 2009 +0000

description:
Add rump_smbfs.  It's innards are different from most file systems
in two respects:
    * in addition to vfs (and networking), it depends on kernel
      device code to provide /dev/nsmb
    * mounting involves having lengthy chats with the kernel smb
      device instead of the typical "parse args and mount(2) away".

Seems to be pretty stable, at least data seems to flow over it
faster than over in-kernel nfs.

diffstat:

 usr.sbin/puffs/rump_smbfs/Makefile      |   16 ++++
 usr.sbin/puffs/rump_smbfs/rump_smbfs.8  |  112 ++++++++++++++++++++++++++++++++
 usr.sbin/puffs/rump_smbfs/rump_smbfs.c  |   70 ++++++++++++++++++++
 usr.sbin/puffs/rump_smbfs/smb_rumpops.c |   52 ++++++++++++++
 4 files changed, 250 insertions(+), 0 deletions(-)

diffs (266 lines):

diff -r fdf399cda33a -r 0bc934685380 usr.sbin/puffs/rump_smbfs/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/puffs/rump_smbfs/Makefile        Sun Sep 06 20:26:47 2009 +0000
@@ -0,0 +1,16 @@
+#      $NetBSD: Makefile,v 1.1 2009/09/06 20:26:47 pooka Exp $
+#
+
+.include <bsd.own.mk>
+
+MOUNTNAME=     smbfs
+SRCS+=         smb_rumpops.c
+
+LDADD+=        -lrumpnet_netinet -lrumpnet_sockin -lrumpnet
+LDADD+=                -lrumpcrypto -lrumpdev_netsmb -lrumpdev
+
+ISRUMP=                # it is
+
+.include "${.CURDIR}/../../../sbin/mount_smbfs/Makefile.inc"
+
+.include <bsd.prog.mk>
diff -r fdf399cda33a -r 0bc934685380 usr.sbin/puffs/rump_smbfs/rump_smbfs.8
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/puffs/rump_smbfs/rump_smbfs.8    Sun Sep 06 20:26:47 2009 +0000
@@ -0,0 +1,112 @@
+.\"    $NetBSD: rump_smbfs.8,v 1.1 2009/09/06 20:26:47 pooka Exp $
+.\"
+.\"    WARNING: GENERATED FILE, DO NOT EDIT
+.\"    INSTEAD, EDIT makerumpmanpages.sh AND REGEN
+.\"
+.\" Copyright (c) 2008 Antti Kantee. 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 AUTHOR 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 AUTHOR 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.
+.\"
+.Dd February 15, 2009
+.Dt RUMP_SMBFS 8
+.Os
+.Sh NAME
+.Nm rump_smbfs
+.Nd mount the smbfs file system using a userspace server
+.Sh SYNOPSIS
+.Cd "file-system PUFFS"
+.Cd "pseudo-device putter"
+.Pp
+.Nm
+.Op options
+.Ar special
+.Ar node
+.Sh DESCRIPTION
+The
+.Nm
+utility can be used to mount smbfs file systems.
+It uses
+.Xr rump 3
+and
+.Xr p2k 3
+to facilitate running the file system as a server in userspace.
+As opposed to
+.Xr mount_smbfs 8 ,
+.Nm
+does not use file system code within the kernel and therefore does
+not require kernel support except
+.Xr puffs 4 .
+Apart from a minor speed penalty (starting from 10% and depending
+on the workload and file system in question), there is no difference
+to using in-kernel code.
+.Pp
+In case mounting a file system image from a regular file,
+.Nm
+does not require the use of
+.Xr vnconfig 8
+unlike kernel file systems.
+Instead, the image path can be directly passed as the special file path.
+The exception is if the image contains a disklabel.
+In this case vnconfig is required to resolve the start offset for the
+correct partition within the image.
+.Pp
+It is recommended that untrusted file system images be mounted with
+.Nm
+instead of
+.Xr mount_smbfs 8 .
+Corrupt file system images commonly cause the file system
+to crash the entire kernel, but with
+.Nm
+only the userspace server process will dump core.
+.Pp
+To use
+.Nm
+via
+.Xr mount 8 ,
+the flags
+.Fl o Ar rump
+and
+.Fl t Ar smbfs
+should be given.
+Similarly,
+.Nm
+is run instead of
+.Xr mount_smbfs 8
+if
+.Dq rump
+is added to the options field of
+.Xr fstab 5 .
+.Pp
+Please see
+.Xr mount_smbfs 8
+for a full description of the available command line options.
+.Sh SEE ALSO
+.Xr p2k 3 ,
+.Xr puffs 3 ,
+.Xr rump 3 ,
+.Xr mount_smbfs 8
+.Sh HISTORY
+The
+.Nm
+utility first appeared in
+.Nx 5.0 .
+It is currently considered experimental.
diff -r fdf399cda33a -r 0bc934685380 usr.sbin/puffs/rump_smbfs/rump_smbfs.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/puffs/rump_smbfs/rump_smbfs.c    Sun Sep 06 20:26:47 2009 +0000
@@ -0,0 +1,70 @@
+/*     $NetBSD: rump_smbfs.c,v 1.1 2009/09/06 20:26:47 pooka Exp $     */
+
+/*
+ * Copyright (c) 2008 Antti Kantee.  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 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 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 <sys/types.h>
+#include <sys/mount.h>
+
+#include <fs/smbfs/smbfs.h>
+
+#include <rump/rump.h>
+#include <rump/p2k.h>
+
+#include <err.h>
+#include <puffs.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "mount_smbfs.h"
+
+int
+main(int argc, char *argv[])
+{
+       struct smbfs_args args;
+       char canon_dev[MAXPATHLEN], canon_dir[MAXPATHLEN];
+       int rv, mntflags;
+
+       setprogname(argv[0]);
+
+       /*
+        * XXX: rump_init() creates threads, we cannot detach after that.
+        * so let's call rump_smbfs work in progress and force debugging
+        * mode ;)  (I should go into marketing)
+        */
+       printf("rump_smbfs is work-in-progress.  forcing debug mode\n");
+       setenv("P2K_DEBUG", "1", 1);
+       rump_init();
+       mount_smbfs_parseargs(argc, argv, &args, &mntflags,
+           canon_dev, canon_dir);
+
+       rv = p2k_run_fs(MOUNT_SMBFS, canon_dev, canon_dir, mntflags, &args,
+           sizeof(args), 0);
+       if (rv == -1)
+               err(1, "mount");
+
+       return 0;
+}
diff -r fdf399cda33a -r 0bc934685380 usr.sbin/puffs/rump_smbfs/smb_rumpops.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/puffs/rump_smbfs/smb_rumpops.c   Sun Sep 06 20:26:47 2009 +0000
@@ -0,0 +1,52 @@
+/*     $NetBSD: smb_rumpops.c,v 1.1 2009/09/06 20:26:47 pooka Exp $    */
+
+/*
+ * Copyright (c) 2009 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.
+ *
+ * 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 <sys/cdefs.h>
+#ifndef lint
+__RCSID("$NetBSD: smb_rumpops.c,v 1.1 2009/09/06 20:26:47 pooka Exp $");
+#endif /* !lint */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+
+#include "smb_kernelops.h"
+
+const struct smb_kernelops smb_kops = {
+       .ko_open = rump_sys_open,
+       .ko_ioctl = rump_sys_ioctl,
+       .ko_close = rump_sys_close,
+
+       .ko_socket = rump_sys_socket,
+       .ko_setsockopt = rump_sys_setsockopt,
+       .ko_bind = rump_sys_bind,
+       .ko_sendto = rump_sys_sendto,
+       .ko_recvfrom = rump_sys_recvfrom,
+};



Home | Main Index | Thread Index | Old Index