Date: Sun, 9 Oct 2005 13:26:09 -0400 From: "Anish Mistry" <amistry@am-productions.biz> To: "FreeBSD gnats submit" <FreeBSD-gnats-submit@FreeBSD.org> Subject: ports/87167: New port: sysutils/fusefs Message-ID: <1128878769.0@bigguy.am-productions.biz> Resent-Message-ID: <200510091730.j99HULg4090827@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 87167 >Category: ports >Synopsis: New port: sysutils/fusefs >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Oct 09 17:30:20 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Anish Mistry >Release: FreeBSD 5.4-STABLE i386 >Organization: AM Productions >Environment: System: FreeBSD 5.4-STABLE #3: Wed Aug 17 14:50:43 EDT 2005 amistry@bigguy.am-productions.biz:/usr/obj/usr/src/sys/BIGGUY >Description: Add userland fuse filesystem support. This will allow the use of other filesystems like sshfs and gmailfs. Kernel module support will be send-pr'ed soon. >How-To-Repeat: >Fix: --- fusefs.shar begins here --- # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # fusefs # fusefs/Makefile # fusefs/distinfo # fusefs/pkg-descr # fusefs/pkg-message # fusefs/pkg-plist # fusefs/files # fusefs/files/patch-ac # fusefs/files/patch-ab # fusefs/files/patch-aa # fusefs/files/patch-ad # echo c - fusefs mkdir -p fusefs > /dev/null 2>&1 echo x - fusefs/Makefile sed 's/^X//' >fusefs/Makefile << 'END-of-fusefs/Makefile' X# New ports collection makefile for: fusefs X# Date created: 01 October 2005 X# Whom: Anish Mistry X# $FreeBSD$ X# X XPORTNAME= fusefs XPORTVERSION= 2.4.0 XCATEGORIES= sysutils XMASTER_SITES= ${MASTER_SITE_SOURCEFORGE} \ X http://creo.hu/~csaba/projects/fuse4bsd/downloads/ XMASTER_SITE_SUBDIR= fuse XDISTNAME= fuse-${PORTVERSION} X XMAINTAINER= amistry@am-productions.biz XCOMMENT= FUSE allows filesystem implementation in userspace X XUSE_LIBTOOL_VER=15 XCONFIGURE_ENV= MOUNT_FUSE_PATH=${LOCALBASE}/sbin \ X PKG_CONFIG_PATH=${LOCALBASE}/libdata/pkgconfig XHAS_CONFIGURE= yes XINSTALLS_SHLIB= yes XCONFIGURE_ARGS= --disable-kernel-module --exec-prefix=${LOCALBASE} X X.include <bsd.port.pre.mk> X X.if ${OSVERSION} < 500000 XBROKEN= "does not compile" X.endif X Xpost-install: X ${INSTALL_DATA} ${WRKSRC}/include/fuse_kernel.h ${LOCALBASE}/include/fuse X X.include <bsd.port.post.mk> END-of-fusefs/Makefile echo x - fusefs/distinfo sed 's/^X//' >fusefs/distinfo << 'END-of-fusefs/distinfo' XMD5 (fuse-2.4.0.tar.gz) = 52444398d4e771bf943d2eb602548db1 XSIZE (fuse-2.4.0.tar.gz) = 384358 END-of-fusefs/distinfo echo x - fusefs/pkg-descr sed 's/^X//' >fusefs/pkg-descr << 'END-of-fusefs/pkg-descr' XFUSE makes it possible to implement a filesystem in a userspace program. XFeatures include: simple yet comprehensive API, secure mounting by non-root Xusers, support for RELENG_6 and HEAD FreeBSD kernels, multi-threaded Xoperation. X XWWW: http://sourceforge.net/projects/fuse/ X X- Anish Mistry Xamistry@am-productions.biz XAM Productions http://am-productions.biz END-of-fusefs/pkg-descr echo x - fusefs/pkg-message sed 's/^X//' >fusefs/pkg-message << 'END-of-fusefs/pkg-message' XInstall the fuse kernel module to use this port. END-of-fusefs/pkg-message echo x - fusefs/pkg-plist sed 's/^X//' >fusefs/pkg-plist << 'END-of-fusefs/pkg-plist' Xinclude/fuse/fuse.h Xinclude/fuse/fuse_compat.h Xinclude/fuse/fuse_common.h Xinclude/fuse/fuse_lowlevel.h Xinclude/fuse/fuse_kernel.h Xinclude/fuse.h Xlib/libfuse.so.2 Xlib/libfuse.so Xlib/libfuse.a Xlibdata/pkgconfig/fuse.pc X@dirrm include/fuse END-of-fusefs/pkg-plist echo c - fusefs/files mkdir -p fusefs/files > /dev/null 2>&1 echo x - fusefs/files/patch-ac sed 's/^X//' >fusefs/files/patch-ac << 'END-of-fusefs/files/patch-ac' X--- util/Makefile.in.orig Mon Sep 26 07:39:38 2005 X+++ util/Makefile.in Sat Oct 1 23:56:51 2005 X@@ -38,7 +38,7 @@ X POST_UNINSTALL = : X build_triplet = @build@ X host_triplet = @host@ X-bin_PROGRAMS = fusermount$(EXEEXT) X+bin_PROGRAMS = X subdir = util X DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in X ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 X@@ -164,7 +164,7 @@ X sysconfdir = @sysconfdir@ X target_alias = @target_alias@ X fusermount_SOURCES = fusermount.c X-EXTRA_DIST = mount.fuse udev.rules X+EXTRA_DIST = X all: all-am X X .SUFFIXES: X@@ -361,10 +361,6 @@ X X installcheck: installcheck-am X install-strip: X- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ X- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ X- `test -z '$(STRIP)' || \ X- echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install X mostlyclean-generic: X X clean-generic: X@@ -434,34 +430,21 @@ X install-binPROGRAMS install-data install-data-am \ X install-data-local install-exec install-exec-am \ X install-exec-hook install-exec-local install-info \ X- install-info-am install-man install-strip installcheck \ X+ install-info-am install-man installcheck \ X installcheck-am installdirs maintainer-clean \ X maintainer-clean-generic mostlyclean mostlyclean-compile \ X mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ X tags uninstall uninstall-am uninstall-binPROGRAMS \ X uninstall-info-am uninstall-local X X- X install-exec-hook: X- -chown root $(DESTDIR)$(bindir)/fusermount X- -chmod u+s $(DESTDIR)$(bindir)/fusermount X- @if test ! -e $(DESTDIR)/dev/fuse; then \ X- $(mkdir_p) $(DESTDIR)/dev; \ X- echo "mknod $(DESTDIR)/dev/fuse -m 0666 c 10 229"; \ X- mknod $(DESTDIR)/dev/fuse -m 0666 c 10 229; \ X- fi X X install-exec-local: X- $(mkdir_p) $(DESTDIR)$(MOUNT_FUSE_PATH) X- $(INSTALL_PROGRAM) $(srcdir)/mount.fuse $(DESTDIR)$(MOUNT_FUSE_PATH)/mount.fuse X X install-data-local: X- $(mkdir_p) $(DESTDIR)$(UDEV_RULES_PATH) X- $(INSTALL_DATA) $(srcdir)/udev.rules $(DESTDIR)$(UDEV_RULES_PATH)/40-fuse.rules X X uninstall-local: X- rm -f $(DESTDIR)$(MOUNT_FUSE_PATH)/mount.fuse X- rm -f $(DESTDIR)$(UDEV_RULES_PATH)/40-fuse.rules X+ X # Tell versions [3.59,3.63) of GNU make to not export all variables. X # Otherwise a system limit (for SysV at least) may be exceeded. X .NOEXPORT: END-of-fusefs/files/patch-ac echo x - fusefs/files/patch-ab sed 's/^X//' >fusefs/files/patch-ab << 'END-of-fusefs/files/patch-ab' X--- include.orig/fuse_kernel.h Wed Aug 3 01:26:31 2005 X+++ include/fuse_kernel.h Wed Aug 3 09:41:51 2005 X@@ -8,7 +8,11 @@ X X /* This file defines the kernel interface of FUSE */ X X+#ifdef __FreeBSD__ X+#include "linux_compat.h" X+#else X #include <asm/types.h> X+#endif X X /** Version number of this interface */ X #define FUSE_KERNEL_VERSION 7 X Xdiff -ruN include.orig/linux_compat.h include/linux_compat.h X--- include.orig/linux_compat.h Wed Dec 31 19:00:00 1969 X+++ include/linux_compat.h Wed Sep 28 12:57:45 2005 X@@ -0,0 +1,6 @@ X+#include <sys/types.h> /* XXX Or should it be sys/stdint.h ? */ X+ X+#define __u64 uint64_t X+#define __u32 uint32_t X+#define __s32 int32_t X+ END-of-fusefs/files/patch-ab echo x - fusefs/files/patch-aa sed 's/^X//' >fusefs/files/patch-aa << 'END-of-fusefs/files/patch-aa' Xdiff -Naur example/fusexmp.c example/fusexmp.c X--- example/fusexmp.c Tue Sep 13 21:26:12 2005 X+++ example/fusexmp.c Thu Oct 6 02:38:03 2005 X@@ -20,7 +20,12 @@ X #include <fcntl.h> X #include <dirent.h> X #include <errno.h> X+#ifdef __FreeBSD__ X+#include <sys/param.h> X+#include <sys/mount.h> X+#else X #include <sys/statfs.h> X+#endif X #ifdef HAVE_SETXATTR X #include <sys/xattr.h> X #endif X@@ -79,7 +84,20 @@ X { X int res; X X+#ifndef __FreeBSD__ X res = mknod(path, mode, rdev); X+#else X+ if (rdev) X+ res = mknod(path, mode, rdev); X+ else if (mode & S_IFIFO) X+ res = mkfifo(path, mode); X+ else { X+ res = open(path, O_CREAT | O_TRUNC | O_WRONLY, mode); X+ if (res >= 0) X+ res = close(res); X+ } X+#endif X+ X if(res == -1) X return -errno; X Xdiff -Naur example/fusexmp_fh.c example/fusexmp_fh.c X--- example/fusexmp_fh.c Tue Sep 13 21:26:12 2005 X+++ example/fusexmp_fh.c Thu Oct 6 02:38:03 2005 X@@ -17,7 +17,12 @@ X #include <fcntl.h> X #include <dirent.h> X #include <errno.h> X+#ifdef __FreeBSD__ X+#include <sys/param.h> X+#include <sys/mount.h> X+#else X #include <sys/statfs.h> X+#endif X #ifdef HAVE_SETXATTR X #include <sys/xattr.h> X #endif X@@ -68,7 +73,11 @@ X memset(&st, 0, sizeof(st)); X st.st_ino = de->d_ino; X st.st_mode = de->d_type << 12; X+#ifdef __FreeBSD__ X+ if (filler(buf, de->d_name, &st, 0)) X+#else X if (filler(buf, de->d_name, &st, de->d_off)) X+#endif X break; X } X X@@ -87,7 +96,20 @@ X { X int res; X X+#ifndef __FreeBSD__ X res = mknod(path, mode, rdev); X+#else X+ if (rdev) X+ res = mknod(path, mode, rdev); X+ else if (mode & S_IFIFO) X+ res = mkfifo(path, mode); X+ else { X+ res = open(path, O_CREAT | O_TRUNC | O_WRONLY, mode); X+ if (res >= 0) X+ res = close(res); X+ } X+#endif X+ X if(res == -1) X return -errno; X X@@ -268,9 +290,13 @@ X int res; X (void) path; X X+#ifdef __FreeBSD__ X+ (void) isdatasync; X+#else X if (isdatasync) X res = fdatasync(fi->fh); X else X+#endif X res = fsync(fi->fh); X if(res == -1) X return -errno; Xdiff -Naur include/fuse.h include/fuse.h X--- include/fuse.h Mon Oct 3 16:12:50 2005 X+++ include/fuse.h Thu Oct 6 02:38:03 2005 X@@ -20,7 +20,12 @@ X X #include <sys/types.h> X #include <sys/stat.h> X+#ifdef __FreeBSD__ X+#include <sys/param.h> X+#include <sys/mount.h> X+#else X #include <sys/statfs.h> X+#endif X #include <utime.h> X X #ifdef __cplusplus Xdiff -Naur include/fuse_lowlevel.h include/fuse_lowlevel.h X--- include/fuse_lowlevel.h Mon Oct 3 16:12:50 2005 X+++ include/fuse_lowlevel.h Thu Oct 6 02:38:03 2005 X@@ -18,7 +18,12 @@ X #include <utime.h> X #include <sys/types.h> X #include <sys/stat.h> X+#ifdef __FreeBSD__ X+#include <sys/param.h> X+#include <sys/mount.h> X+#else X #include <sys/statfs.h> X+#endif X #include <sys/uio.h> X X #ifdef __cplusplus Xdiff -Naur lib/fuse.c lib/fuse.c X--- lib/fuse.c Mon Oct 3 17:02:37 2005 X+++ lib/fuse.c Thu Oct 6 02:38:03 2005 X@@ -1414,7 +1414,12 @@ X X static int default_statfs(struct statfs *buf) X { X+#ifdef __FreeBSD__ X+ buf->f_namemax = 255; X+#else X buf->f_namelen = 255; X+#endif X+ X buf->f_bsize = 512; X return 0; X } X@@ -1428,7 +1433,11 @@ X stbuf->f_bavail = compatbuf->blocks_free; X stbuf->f_files = compatbuf->files; X stbuf->f_ffree = compatbuf->files_free; X+#ifdef __FreeBSD__ X+ stbuf->f_namemax = compatbuf->namelen; X+#else X stbuf->f_namelen = compatbuf->namelen; X+#endif X } X X static void fuse_statfs(fuse_req_t req) X@@ -1761,8 +1770,10 @@ X f->flags |= FUSE_HARD_REMOVE; X else if (strcmp(opt, "use_ino") == 0) X f->flags |= FUSE_USE_INO; X+#ifndef FreeBSD X else if (strcmp(opt, "readdir_ino") == 0) X f->flags |= FUSE_READDIR_INO; X+#endif X else if (strcmp(opt, "direct_io") == 0) X f->flags |= FUSE_DIRECT_IO; X else if (strcmp(opt, "kernel_cache") == 0) X@@ -1787,6 +1798,13 @@ X else X free(xopts); X } X+#ifdef __FreeBSD__ X+ /* X+ * In FreeBSD, we always use these settings as inode numbers are needed to X+ * make getcwd(3) work. X+ */ X+ f->flags |= FUSE_READDIR_INO; X+#endif X return 0; X } X Xdiff -Naur lib/fuse_lowlevel.c lib/fuse_lowlevel.c X--- lib/fuse_lowlevel.c Mon Oct 3 17:15:05 2005 X+++ lib/fuse_lowlevel.c Thu Oct 6 02:38:03 2005 X@@ -194,7 +194,11 @@ X kstatfs->bavail = stbuf->f_bavail; X kstatfs->files = stbuf->f_files; X kstatfs->ffree = stbuf->f_ffree; X+#ifdef __FreeBSD__ X+ kstatfs->namelen = stbuf->f_namemax; X+#else X kstatfs->namelen = stbuf->f_namelen; X+#endif X } X X static int send_reply_ok(fuse_req_t req, const void *arg, size_t argsize) X@@ -690,7 +694,11 @@ X req->ch = ch; X X if (!f->got_init && in->opcode != FUSE_INIT) X+#ifdef EPROTO X fuse_reply_err(req, EPROTO); X+#else X+ fuse_reply_err(req, EPROTONOSUPPORT); X+#endif X else if (f->allow_root && in->uid != f->owner && in->uid != 0 && X in->opcode != FUSE_INIT && in->opcode != FUSE_READ && X in->opcode != FUSE_WRITE && in->opcode != FUSE_FSYNC && Xdiff -Naur lib/helper.c lib/helper.c X--- lib/helper.c Mon Aug 15 16:03:59 2005 X+++ lib/helper.c Thu Oct 6 02:38:03 2005 X@@ -22,7 +22,11 @@ X { X if (progname) X fprintf(stderr, X+#ifdef __FreeBSD__ X+ "usage: %s [FUSE options]\n\n", progname); X+#else X "usage: %s mountpoint [FUSE options]\n\n", progname); X+#endif X X fprintf(stderr, X "FUSE options:\n" X@@ -45,11 +49,19 @@ X " debug enable debug output\n" X " fsname=NAME set filesystem name in mtab\n" X " use_ino let filesystem set inode numbers\n" X+#ifndef __FreeBSD__ X " readdir_ino try to fill in d_ino in readdir\n" X+#endif X " nonempty allow mounts over non-empty file/dir\n" X " umask=M set file permissions (octal)\n" X " uid=N set file owner\n" X " gid=N set file group\n" X+#ifdef __FreeBSD__ X+ "\n" X+ "(Note that the above description regards to Linux. Hence these\n" X+ "options might work differently or might not work at all.\n" X+ "For more information, see mount_fusefs(8).)\n" X+#endif X ); X } X X@@ -275,11 +287,13 @@ X } X } X X+#ifndef __FreeBSD__ X if (*mountpoint == NULL) { X fprintf(stderr, "missing mountpoint\n"); X fprintf(stderr, "see `%s -h' for usage\n", argv[0]); X goto err; X } X+#endif X return 0; X X err: X@@ -377,8 +391,13 @@ X fuse_instance = NULL; X X fuse_destroy(fuse); X+#ifndef __FreeBSD__ X close(fd); X fuse_unmount(mountpoint); X+#else X+ fuse_unmount(mountpoint); X+ close(fd); X+#endif X free(mountpoint); X } X Xdiff -Naur lib/mount.c lib/mount.c X--- lib/mount.c Sun Oct 2 11:16:12 2005 X+++ lib/mount.c Thu Oct 6 02:38:03 2005 X@@ -21,7 +21,7 @@ X #define FUSERMOUNT_PROG "fusermount" X #define FUSE_COMMFD_ENV "_FUSE_COMMFD" X X- X+#ifndef __FreeBSD__ X /* return value: X * >= 0 => fd X * -1 => error X@@ -66,9 +66,11 @@ X } X return *(int*)CMSG_DATA(cmsg); X } X+#endif X X void fuse_unmount(const char *mountpoint) X { X+#ifndef __FreeBSD__ X const char *mountprog = FUSERMOUNT_PROG; X char umount_cmd[1024]; X X@@ -77,10 +79,53 @@ X X umount_cmd[sizeof(umount_cmd) - 1] = '\0'; X system(umount_cmd); X+#else X+ /* X+ * This is how we could do unmount-by-the-daemon in FreeBSD. X+ * Alas, by the time we get here, fuse_kern_chan_destroy X+ * has closed up the device, so this will fail. X+ * Maybe fuse_kern_chan_destroy should be castrated for FreeBSD? X+ * Well, let's stay on the safe side for now. X+ */ X+#if 0 X+ /* X+ * We keep on not wanting to rely on the mountpoint argument X+ * so let's just look up our device as in mount_fusefs(8)... X+ * we don't trust the environment here though. X+ */ X+ char dev[128]; X+ char *ssc, *umount_cmd; X+ FILE *sf; X+ int rv; X+ char *seekscript = X+ "/usr/bin/fstat /dev/fuse* |\n" X+ "/usr/bin/awk '{if ($3 == %d) print $10}' |\n" X+ "/usr/bin/sort |\n" X+ "/usr/bin/uniq |\n" X+ "/usr/bin/awk '{ i+=1; if(i > 1){ exit (1); }; printf; }; END{if (i==0) exit (1)}'"; X+ X+ asprintf(&ssc, seekscript, getpid()); X+ X+ errno = 0; X+ sf = popen(ssc, "r"); X+ if (! sf) X+ return; X+ X+ fgets(dev, sizeof(dev), sf); X+ rv = pclose(sf); X+ if (rv) X+ return; X+ X+ asprintf(&umount_cmd, "/sbin/umount %s", dev); X+ system(umount_cmd); X+#endif X+ (void)mountpoint; X+#endif X } X X int fuse_mount(const char *mountpoint, const char *opts) X { X+#ifndef __FreeBSD__ X const char *mountprog = FUSERMOUNT_PROG; X int fds[2], pid; X int res; X@@ -133,6 +178,40 @@ X waitpid(pid, NULL, 0); /* bury zombie */ X X return rv; X+#else X+ int fd; X+ char *dev; X+ X+ (void)mountpoint; X+ (void)opts; X+ X+ dev = getenv("FUSE_DEV_FD"); X+ X+ if (dev) { X+ errno = 0; X+ fd = strtol(dev, NULL, 10); X+ X+ if (errno) { X+ perror("bad value given in FUSE_DEV_FD"); X+ return -1; X+ } X+ X+ if (fd < 0) X+ return -1; X+ X+ return fd; X+ } X+ X+ dev = getenv("FUSE_DEV_NAME"); X+ X+ if (! dev) X+ dev = "/dev/fuse"; X+ X+ if ((fd = open(dev, O_RDWR)) < 0) X+ perror("failed to open fuse device"); X+ X+ return fd; X+#endif X } X X int fuse_mount_compat1(const char *mountpoint, const char *args[]) Xdiff -Naur util/fusermount.c util/fusermount.c X--- util/fusermount.c Mon Oct 3 17:02:37 2005 X+++ util/fusermount.c Thu Oct 6 02:38:03 2005 X@@ -1,3 +1,4 @@ X+#ifndef __FreeBSD__ X /* X FUSE: Filesystem in Userspace X Copyright (C) 2001-2005 Miklos Szeredi <miklos@szeredi.hu> X@@ -1113,3 +1114,12 @@ X X return 0; X } X+#else X+#include <stdio.h> X+ X+main() X+{ X+ fprintf(stderr, "You don't wanna use this program under FreeBSD...\n"); X+ exit(1); X+} X+#endif END-of-fusefs/files/patch-aa echo x - fusefs/files/patch-ad sed 's/^X//' >fusefs/files/patch-ad << 'END-of-fusefs/files/patch-ad' X--- Makefile.in.orig Sun Oct 9 12:37:38 2005 X+++ Makefile.in Sun Oct 9 12:39:05 2005 X@@ -184,7 +184,7 @@ X doc/how-fuse-works \ X doc/kernel.txt X X-pkgconfigdir = $(libdir)/pkgconfig X+pkgconfigdir = $(prefix)/libdata/pkgconfig X pkgconfig_DATA = fuse.pc X all: all-recursive X END-of-fusefs/files/patch-ad exit --- fusefs.shar ends here --- >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1128878769.0>