From owner-p4-projects@FreeBSD.ORG Fri Sep 30 14:35:40 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4E7B816A422; Fri, 30 Sep 2005 14:35:40 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 265D316A41F for ; Fri, 30 Sep 2005 14:35:40 +0000 (GMT) (envelope-from soc-chenk@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id B50AC43D4C for ; Fri, 30 Sep 2005 14:35:39 +0000 (GMT) (envelope-from soc-chenk@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j8UEZdhG053895 for ; Fri, 30 Sep 2005 14:35:39 GMT (envelope-from soc-chenk@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j8UEZdSg053892 for perforce@freebsd.org; Fri, 30 Sep 2005 14:35:39 GMT (envelope-from soc-chenk@freebsd.org) Date: Fri, 30 Sep 2005 14:35:39 GMT Message-Id: <200509301435.j8UEZdSg053892@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to soc-chenk@freebsd.org using -f From: soc-chenk To: Perforce Change Reviews Cc: Subject: PERFORCE change 84554 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Sep 2005 14:35:41 -0000 http://perforce.freebsd.org/chv.cgi?CH=84554 Change 84554 by soc-chenk@soc-chenk_leavemealone on 2005/09/30 14:34:56 update kernel api and userspace (rename pending) Submitted by: soc-chenk Affected files ... .. //depot/projects/soc2005/fuse4bsd2/Changelog#12 edit .. //depot/projects/soc2005/fuse4bsd2/IMPLEMENTATION_NOTES#8 edit .. //depot/projects/soc2005/fuse4bsd2/README.html#7 edit .. //depot/projects/soc2005/fuse4bsd2/fuse_module/Makefile-5.4#2 delete .. //depot/projects/soc2005/fuse4bsd2/fuse_module/fuse.c#10 edit .. //depot/projects/soc2005/fuse4bsd2/fuselib/fuselib-2.4.0-pre2.diff#3 edit Differences ... ==== //depot/projects/soc2005/fuse4bsd2/Changelog#12 (text+ko) ==== @@ -1,3 +1,13 @@ +Fri Sep 30 15:23:08 CEST 2005 at node: creo.hu, nick: csaba + * update kernel api and userspace + - userspace patch updated to 2.4.0-rc1 + - bug in FreeBSD's mknod of example filesystems fixed + - module adjusted to new clone event handler API + - README.html updated to reflect above changes and + more info on access control was added + - Info on access control in IMPLEMENTATION_NOTES made + more exact + Wed Sep 21 20:05:27 CEST 2005 at node: creo.hu, nick: csaba tagged 0.2.11 ==== //depot/projects/soc2005/fuse4bsd2/IMPLEMENTATION_NOTES#8 (text+ko) ==== @@ -200,35 +200,35 @@ denying access to the device for everyone else than root makes no problem. -However, in FreeBSD daemons or the mount utilily open fuse -devices directly, and no setuid dispatcher is present, so here it's a -valid question: who should be able to use fuse devices? +However, in FreeBSD daemons or the mount utilily open fuse devices +directly, and no setuid dispatcher is present, so here it is a valid +question: who should be able to use fuse devices? + +In FreeBSD, mount access is controlled by two mechanisms. One is the +above mentioned vfs.usermount sysctl. The other comes into play if +the filesystem is backed by a device. In that case, only those can mount +the filesystem who have read/write access to the device to be mounted +(or read access for a read only mount). + +Both of these regard to Fuse, too: despite its somewhat synthetic +charater, Fuse is a device backed filesystem. There is though one subtle +difference between Fuse and traditonal device (disk) backed filesystems +in this respect: with traditional filesystems, permissions of the device +are used also for providing access control for the device file as such, +which is a valid entity on its own and can be used for performing raw I/O +on the appropriate hardware. -In fact, mounting privileges (as discussed above) is the real beef -- -the device files themselves don't need special protection (I guess, in -Linux neither, the root-only access policy is established only on a -"it's better to show up as one who prefers to play on the safe side" -base). The kernel is not willing to interact with a reader/writer of the -file until the VFS layer pushes messages onto it, which doesn't happen -until the device file gets mounted. As it seems to be a bad idea to -introduce non-orthogonal access policies in parallell, we tend to be -liberal in respect of fuse devices. Yet we also have to make our -commitment to the "it's better to show up as one who prefers to play on -the safe side" idea. +On the contrary, fuse devices has no use without being mounted (the +kernel is not willing to interact with a reader/writer of the device +file until the VFS layer pushes messages onto it). Hence permission +settings of fuse devices are to be directly interpreted as permissions +for mounting Fuse filesystems. So this is the tool by which a +fine-grained control on mounting Fuse filesystems can be set up. -As a compromise, fuse devices are set to be readable/writable for -members of the operator group (the same group which is usually used for -controlling access to devices like sound cards ands optical drives). One -might argue that it's nonsense that mounting a Fuse filesystem is harder -than mounting a traditional, disk based file system, as the latter -requires only vfs.usermount == 1, while the former requires membership -in operator, too. Well, the conscious admin who takes the effort to set -vfs.usermount to 1, can as well take the effort to adjust devfs(8) rules -so that fuse devices become world usable -("devfs rule add path 'fuse*' mode 666"). Hey, conscious admins, -hear my word, I hereby claim thou shalt not fear to do so. And, -concerning paranoiac admins, these defaults save them from a heart -attack upon seeing world writable entries under /dev. +By default, fuse devices can be used by members of the operator group +(that's used for controlling access to, eg., usb devices). One can set +permissions of fuse devives directly, by chmod, or generally, via +devfs(8) rules. * 1c -- dealing with the "allow other" misery ==== //depot/projects/soc2005/fuse4bsd2/README.html#7 (text+ko) ==== @@ -32,7 +32,7 @@ The main part of Fuse for FreeBSD is a kernel module which provides a kernel messaging interface to the Fuse library in userspace which is compatible with that of the Linux module. The userspace part is pretty portable. A lightweight patch is enough to get that compile and work.

-The module was written for and tested with CURRENT, aka FreeBSD-7.0. I'd guess it will work fine with RELENG 6 too, but currently it's not usable with 5.x (or lower) versions. +The module was written for and tested with CURRENT, aka FreeBSD-7.0. I'd guess it will work fine with RELENG 6 too, but currently it's not usable with 5.x (or lower) versions. The module will work with 7.0-CURRENT snapshots from not earlier than 8th of August and RELENG_6 snapshots from not earlier than 13th of August (desperate types can try with older CURRENT/RELENG_6 snapshots if they set the -DUSE_OLD_CLONEHANDLER_API flag for cc).

What can be considered as a public homepage for the project is [WWW]http://wikitest.freebsd.org/moin.cgi/FuseFilesystem; for updates, further info go there. Get in contact with me via the soc-chenk email addrees of the FreeBSD organization (freebsd.org). @@ -50,18 +50,18 @@

  • - Fuse itself. Get Fuse 2.4.0-pre2 from their [WWW]Sourceforge project page. + Fuse itself. Get Fuse 2.4.0-rc1 from their [WWW]Sourceforge project page. If this is not availabe there (because a newer (pre)release has taken its place), you can either try to adopt these instructions to the newer (pre)release, or fetch it from my download directory, [WWW]http://creo.hu/~csaba/projects/fuse4bsd/downloads/.

  • - The FreeBSD module. Source tarballs are provided at [WWW]http://creo.hu/~csaba/projects/fuse4bsd/downloads/ under the name fuse4bsd-<version>.tar.* (latest release is 0.2.11, date of release: 21th Sep 2005). The current code is available via Darcs, you can fetch it by + The FreeBSD module. Source tarballs are provided at [WWW]http://creo.hu/~csaba/projects/fuse4bsd/downloads/ under the name fuse4bsd-<version>.tar.* (latest release is 0.2.11, date of release: 21th Sep 2005). The current code is available via [WWW]Darcs, you can fetch it by

     darcs get http://creo.hu/~csaba/darcs-repos/fuse4bsd
    command, or via [WWW]Perforce (you can use this latter link for online source code browsing).

  • - Fuse sshfs. The latest release (1.2) will do, fetch the sshfs-fuse package also from the [WWW]Fuse SF project page. + Fuse sshfs. The latest release (1.2 as of writing this) should do, fetch the sshfs-fuse package also from the [WWW]Fuse SF project page.

  • @@ -82,7 +82,7 @@
  • - Type make. If you want normal quantity of debug output, use DEBUG2G=1, if you want tons of debug output, use DEBUG=1. + Type make. If you want normal quantity of debug output, use the make flag -DDEBUG2G, if you want tons of debug output, use -DDEBUG.

  • @@ -98,7 +98,7 @@
  • Apply the patch with -

     patch -Np1 < ../fuse4bsd/fuselib/fuselib-2.4.0-pre2.diff
    +
     patch -Np1 < ../fuse4bsd/fuselib/fuselib-2.4.0-rc1.diff

  • @@ -110,13 +110,20 @@
  • - We will do a non-privileged install (I'd say that's easier than set up a jail), I'll use ~/meta/fuse-2.4.0-pre2 as the prefix. Type the following commands: + We will do a non-privileged install (I'd say that's easier than set up a jail), I'll use ~/meta/fuse-2.4.0-rc1 as the prefix. Type the following commands:

     mkdir junk &&
    - ./configure --prefix=$HOME/meta/fuse-2.4.0-pre2 --bindir=`pwd`/junk --disable-kernel-module MOUNT_FUSE_PATH=`pwd`/junk &&
    - make &&
      ln -s /usr/bin/true junk/chown &&
      ln -s /usr/bin/true junk/mknod &&
    - env PATH=`pwd`/junk:$PATH make install
    + echo '#!/bin/sh + echo "$1" | grep -q /etc/udev || /bin/mkdir "$@"' > junk/mkdir && + chmod a+x junk/mkdir && + echo '#!/bin/sh + echo "$@" | grep -q udev || /usr/bin/install "$@"' > junk/install && + chmod a+x junk/install && + (export PATH=`pwd`/junk:$PATH && + ./configure --prefix=$HOME/meta/fuse-2.4.0-rc1 --bindir=`pwd`/junk --disable-kernel-module MOUNT_FUSE_PATH=`pwd`/junk && + make && + make install)

  • @@ -137,7 +144,7 @@
  • Type -

     env PKG_CONFIG_PATH=~/meta/fuse-2.4.0-pre2/lib/pkgconfig/ ./configure && make
    +
     env PKG_CONFIG_PATH=~/meta/fuse-2.4.0-rc1/lib/pkgconfig/ ./configure && make

  • @@ -149,18 +156,27 @@

    Using the Fuse based ssh filesystem

    -In the following, you'll need to act as superuser, or enable the vfs.usermount sysctl. +Here we will show how to setup Fuse so that non-privileged users can use it, too. +

    +

    +As the superuser, do +

    kldload use_module/fuse.ko
    +sysctl vfs.usermount=1
    +

    +

    +Now you'll have to act as a user belonging to the operator group or you can as well delete all barriers by +

    devfs rule add path 'fuse*' mode 666
    (opening and doing I/O on fuse devices will have no effect until they get mounted).

    -First, of course, load fuse_module/fuse.ko (for this you definitely need to be a superuser). +Proceed on with the user you chose (we will assume you use the same user as the one who did the installation).

    -Then pick your favourite ssh accessible account (though maybe you'd better stick to servers running OpenSSH -- I've seen commits in sshfs' CVS for better interoperability with other servers, which show there might occur problems with them), say, it's foo@bar.baz. +Pick your favourite ssh accessible account (though maybe you'd better stick to servers running OpenSSH -- I've seen commits in sshfs' CVS for better interoperability with other servers, which show there might occur problems with them), say, it's foo@bar.baz.

    Go to sshfs' directory. First prepare the mount:

    mkdir -p ~/fuse &&
    -export LD_LIBRARY_PATH=~/meta/fuse-2.4.0-pre2/lib/
    and also make sure that mount_fusefs (of FreeBSD Fuse) is in your path. Then do: +export LD_LIBRARY_PATH=~/meta/fuse-2.4.0-rc1/lib/and also make sure that mount_fusefs (of FreeBSD Fuse) is in your path. Then do:
    mount_fusefs auto ~/fuse ./sshfs foo@bar.baz:

    @@ -174,6 +190,10 @@

    For more details, see the man page (mount_fusefs(8)).

    +

    Miscellaneous

    +

    +You can get more info on Fuse based filesystems under FreeBSD at the Fuse wiki, [WWW]http://fuse.sourceforge.net/wiki/index.php/FileSystemsOnFreeBSD. Feel encouraged to add your experiences. +

    Bugs

    See the respective section of mount_fusefs(8). @@ -184,11 +204,6 @@

  • - Backport to 5.x, if it can be done without a major rewrite -

    -
  • -
  • -

    Implement attr/name caching (with timeouts)

  • ==== //depot/projects/soc2005/fuse4bsd2/fuse_module/fuse.c#10 (text+ko) ==== @@ -90,7 +90,11 @@ }; +#if USE_OLD_CLONEHANDLER_API static void fusedev_clone(void *arg, char *name, int namelen, struct cdev **dev); +#else +static void fusedev_clone(void *arg, struct ucred *cred, char *name, int namelen, struct cdev **dev); +#endif static void fuse_bringdown(eventhandler_tag eh_tag); static int fuse_loader(struct module *m, int what, void *arg); @@ -1521,11 +1525,7 @@ /* static vfs_vget_t fuse_vget; */ static int fuse_vget_i(struct mount *mp, struct thread *td, uint64_t nodeid, enum vtype vtyp, struct vnode **vpp); static __inline void fat2vat(struct mount *mp, struct fuse_attr *fat, struct vattr *vap); -#if __FreeBSD_version >= 600000 static vop_getattr_t fuse_getattr; -#else -static int fuse_getattr(struct vop_getattr_args *ap); -#endif static __inline int fuse_recyc_backend(struct vnode *vp, struct thread *td); static fuse_metrics_t release_filehandle; static void fuse_filehandle_gc(struct vnode *vp, struct thread *td, struct ucred *cred); @@ -1583,7 +1583,6 @@ .vfs_sync = vfs_stdsync, */ }; -#if __FreeBSD_version >= 600000 static struct vop_vector fuse_vnops = { .vop_default = &default_vnodeops, .vop_inactive = fuse_inactive, @@ -1610,15 +1609,6 @@ .vop_bmap = fuse_bmap, .vop_print = fuse_print, }; -#else -vop_t **fuse_vnodeop_p; -static struct vnodeopv_entry_desc fuse_vnops[] = { - { &vop_getattr_desc, (vop_t *)fuse_getattr }, -}; -static struct vnodeopv_desc fuse_vnodeop_opv_desc = - { &fuse_vnodeop_p, fuse_vnops }; -VNODEOP_SET(fuse_vnodeop_opv_desc); -#endif static struct fileops fuse_fileops; @@ -1857,11 +1847,7 @@ MALLOC(fvdat, struct fuse_vnode_data *, sizeof(*fvdat), M_FUSEFS, M_WAITOK | M_ZERO); -#if __FreeBSD_version >= 600000 err = getnewvnode("fuse", mp, &fuse_vnops, &rvp); -#else - err = getnewvnode("fuse", mp, fuse_vnodeop_p, &rvp); -#endif if (err) { fdata_kick_set(data); @@ -2034,12 +2020,7 @@ /* stolen from portalfs */ static int -fuse_root(struct mount *mp, -#if __FreeBSD_version >= 600000 - int flags, -#endif - struct vnode **vpp, - struct thread *td) +fuse_root(struct mount *mp, int flags, struct vnode **vpp, struct thread *td) { /* * Return locked reference to root. @@ -2162,11 +2143,7 @@ MALLOC(fvdat, struct fuse_vnode_data *, sizeof(*fvdat), M_FUSEFS, M_WAITOK | M_ZERO); -#if __FreeBSD_version >= 600000 err = getnewvnode("fuse", mp, &fuse_vnops, vpp); -#else - err = getnewvnode("fuse", mp, fuse_vnodeop_p, vpp); -#endif #if _DEBUG DEBUG2G("allocated new vnode:\n"); vn_printf(*vpp, " * "); @@ -5154,8 +5131,14 @@ /* Modeled after tunclone() of net/if_tun.c */ +#if USE_OLD_CLONEHANDLER_API static void fusedev_clone(void *arg, char *name, int namelen, struct cdev **dev) +#else +static void +fusedev_clone(void *arg, struct ucred *cred, char *name, int namelen, + struct cdev **dev) +#endif { /* * Why cloning? We do need per-open info, but we could as well put our ==== //depot/projects/soc2005/fuse4bsd2/fuselib/fuselib-2.4.0-pre2.diff#3 (text+ko) ==== @@ -1,6 +1,6 @@ diff -Naur linuxfuse/example/fusexmp.c bsdfuse/example/fusexmp.c ---- linuxfuse/example/fusexmp.c Thu Apr 7 17:35:10 2005 -+++ bsdfuse/example/fusexmp.c Tue Sep 13 16:47:54 2005 +--- linuxfuse/example/fusexmp.c Tue Sep 13 21:26:12 2005 ++++ bsdfuse/example/fusexmp.c Fri Sep 30 11:34:16 2005 @@ -20,7 +20,12 @@ #include #include @@ -14,24 +14,27 @@ #ifdef HAVE_SETXATTR #include #endif -@@ -79,7 +84,13 @@ +@@ -79,7 +84,17 @@ { int res; -- res = mknod(path, mode, rdev); ++#ifndef __FreeBSD__ + res = mknod(path, mode, rdev); ++#else + if (rdev) + res = mknod(path, mode, rdev); + else if (mode & S_IFIFO) + res = mkfifo(path, mode); + else -+ creat(path, mode); ++ res = open(path, O_CREAT | O_TRUNC | O_WRONLY, mode); ++#endif + if(res == -1) return -errno; diff -Naur linuxfuse/example/fusexmp_fh.c bsdfuse/example/fusexmp_fh.c ---- linuxfuse/example/fusexmp_fh.c Thu Sep 8 17:16:48 2005 -+++ bsdfuse/example/fusexmp_fh.c Tue Sep 13 16:47:55 2005 +--- linuxfuse/example/fusexmp_fh.c Tue Sep 13 21:26:12 2005 ++++ bsdfuse/example/fusexmp_fh.c Fri Sep 30 11:34:00 2005 @@ -17,7 +17,12 @@ #include #include @@ -57,22 +60,25 @@ break; } -@@ -87,7 +96,13 @@ +@@ -87,7 +96,17 @@ { int res; -- res = mknod(path, mode, rdev); ++#ifndef __FreeBSD__ + res = mknod(path, mode, rdev); ++#else + if (rdev) + res = mknod(path, mode, rdev); + else if (mode & S_IFIFO) + res = mkfifo(path, mode); + else -+ creat(path, mode); ++ res = open(path, O_CREAT | O_TRUNC | O_WRONLY, mode); ++#endif + if(res == -1) return -errno; -@@ -268,9 +283,11 @@ +@@ -268,9 +287,11 @@ int res; (void) path; @@ -86,7 +92,7 @@ return -errno; diff -Naur linuxfuse/include/fuse.h bsdfuse/include/fuse.h --- linuxfuse/include/fuse.h Thu Sep 8 17:16:48 2005 -+++ bsdfuse/include/fuse.h Tue Sep 13 16:47:55 2005 ++++ bsdfuse/include/fuse.h Fri Sep 30 11:29:31 2005 @@ -20,7 +20,12 @@ #include @@ -101,8 +107,8 @@ #ifdef __cplusplus diff -Naur linuxfuse/include/fuse_lowlevel.h bsdfuse/include/fuse_lowlevel.h ---- linuxfuse/include/fuse_lowlevel.h Thu Sep 8 17:16:48 2005 -+++ bsdfuse/include/fuse_lowlevel.h Tue Sep 13 16:47:55 2005 +--- linuxfuse/include/fuse_lowlevel.h Thu Sep 15 13:26:16 2005 ++++ bsdfuse/include/fuse_lowlevel.h Fri Sep 30 11:29:31 2005 @@ -18,7 +18,12 @@ #include #include @@ -118,7 +124,7 @@ #ifdef __cplusplus diff -Naur linuxfuse/lib/fuse.c bsdfuse/lib/fuse.c --- linuxfuse/lib/fuse.c Thu Sep 8 17:16:49 2005 -+++ bsdfuse/lib/fuse.c Sat Sep 17 22:36:48 2005 ++++ bsdfuse/lib/fuse.c Fri Sep 30 11:29:31 2005 @@ -1414,7 +1414,12 @@ static int default_statfs(struct statfs *buf) @@ -174,7 +180,7 @@ diff -Naur linuxfuse/lib/fuse_lowlevel.c bsdfuse/lib/fuse_lowlevel.c --- linuxfuse/lib/fuse_lowlevel.c Thu Sep 8 17:16:49 2005 -+++ bsdfuse/lib/fuse_lowlevel.c Tue Sep 13 16:47:55 2005 ++++ bsdfuse/lib/fuse_lowlevel.c Fri Sep 30 11:29:31 2005 @@ -194,7 +194,11 @@ kstatfs->bavail = stbuf->f_bavail; kstatfs->files = stbuf->f_files; @@ -201,7 +207,7 @@ in->opcode != FUSE_WRITE && in->opcode != FUSE_FSYNC && diff -Naur linuxfuse/lib/helper.c bsdfuse/lib/helper.c --- linuxfuse/lib/helper.c Mon Aug 15 16:03:59 2005 -+++ bsdfuse/lib/helper.c Sat Sep 17 22:44:02 2005 ++++ bsdfuse/lib/helper.c Fri Sep 30 11:29:31 2005 @@ -22,7 +22,11 @@ { if (progname) @@ -265,7 +271,7 @@ diff -Naur linuxfuse/lib/mount.c bsdfuse/lib/mount.c --- linuxfuse/lib/mount.c Wed Aug 3 12:22:32 2005 -+++ bsdfuse/lib/mount.c Sat Sep 17 22:44:57 2005 ++++ bsdfuse/lib/mount.c Fri Sep 30 11:29:31 2005 @@ -21,7 +21,7 @@ #define FUSERMOUNT_PROG "fusermount" #define FUSE_COMMFD_ENV "_FUSE_COMMFD" @@ -383,14 +389,14 @@ int fuse_mount_compat1(const char *mountpoint, const char *args[]) diff -Naur linuxfuse/util/fusermount.c bsdfuse/util/fusermount.c ---- linuxfuse/util/fusermount.c Fri Aug 5 12:24:55 2005 -+++ bsdfuse/util/fusermount.c Tue Sep 13 16:47:55 2005 +--- linuxfuse/util/fusermount.c Mon Sep 26 13:18:07 2005 ++++ bsdfuse/util/fusermount.c Fri Sep 30 11:29:31 2005 @@ -1,3 +1,4 @@ +#ifndef __FreeBSD__ /* FUSE: Filesystem in Userspace Copyright (C) 2001-2005 Miklos Szeredi -@@ -1125,3 +1126,12 @@ +@@ -1108,3 +1109,12 @@ return 0; }