[fuse] Fix mounting FUSE fs into current working directory

Peter Lemenkov peter at fedoraproject.org
Wed Oct 27 13:12:13 UTC 2010


commit a353eb8e7683bb8fb9d06b945af4179aa9e10d08
Author: Peter Lemenkov <lemenkov at gmail.com>
Date:   Wed Oct 27 17:11:42 2010 +0400

    Fix mounting FUSE fs into current working directory
    
    See rhbz #622255 for additional details:
    
    https://bugzilla.redhat.com/show_bug.cgi?id=622255
    
    Signed-off-by: Peter Lemenkov <lemenkov at gmail.com>

 fuse-0001-Fix-udev-rules-Fedora-specific.patch     |   20 +++
 ...enfix.patch => fuse-0002-More-parentheses.patch |   32 ++++--
 ...ng-FUSE-fs-into-current-working-directory.patch |  125 ++++++++++++++++++++
 fuse-udev_rules.patch                              |    5 -
 fuse.spec                                          |   15 ++-
 5 files changed, 179 insertions(+), 18 deletions(-)
---
diff --git a/fuse-0001-Fix-udev-rules-Fedora-specific.patch b/fuse-0001-Fix-udev-rules-Fedora-specific.patch
new file mode 100644
index 0000000..d4bb544
--- /dev/null
+++ b/fuse-0001-Fix-udev-rules-Fedora-specific.patch
@@ -0,0 +1,20 @@
+From ba47031f3557b81e732d41593c95e7b984b54b78 Mon Sep 17 00:00:00 2001
+From: Peter Lemenkov <lemenkov at gmail.com>
+Date: Mon, 9 Aug 2010 12:09:00 +0400
+Subject: [PATCH 1/3] Fix udev rules (Fedora-specific)
+
+Signed-off-by: Peter Lemenkov <lemenkov at gmail.com>
+---
+ util/udev.rules |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/util/udev.rules b/util/udev.rules
+index 9585111..bb8033f 100644
+--- a/util/udev.rules
++++ b/util/udev.rules
+@@ -1 +1 @@
+-KERNEL=="fuse", MODE="0666"
++KERNEL=="fuse", MODE="0666",OWNER="root",GROUP="root"
+-- 
+1.7.3.1
+
diff --git a/fuse-openfix.patch b/fuse-0002-More-parentheses.patch
similarity index 50%
rename from fuse-openfix.patch
rename to fuse-0002-More-parentheses.patch
index c5a0b3d..bf0eef0 100644
--- a/fuse-openfix.patch
+++ b/fuse-0002-More-parentheses.patch
@@ -1,7 +1,19 @@
-diff -up fuse-2.7.2/lib/fuse.c.BAD fuse-2.7.2/lib/fuse.c
---- lib/fuse.c	2008-01-21 09:55:42.000000000 -0500
-+++ lib/fuse.c	2008-01-21 09:57:20.000000000 -0500
-@@ -633,17 +633,15 @@ static int fuse_compat_open(struct fuse_
+From 459c84a3e5fda1ef7f7060d44903b31215857e70 Mon Sep 17 00:00:00 2001
+From: Peter Lemenkov <lemenkov at gmail.com>
+Date: Mon, 9 Aug 2010 12:10:40 +0400
+Subject: [PATCH 2/3] More parentheses
+
+Signed-off-by: Peter Lemenkov <lemenkov at gmail.com>
+---
+ lib/fuse.c          |    8 +++-----
+ lib/fuse_lowlevel.c |    2 +-
+ 2 files changed, 4 insertions(+), 6 deletions(-)
+
+diff --git a/lib/fuse.c b/lib/fuse.c
+index 95cf50b..76c2681 100644
+--- a/lib/fuse.c
++++ b/lib/fuse.c
+@@ -961,17 +961,15 @@ static int fuse_compat_open(struct fuse_fs *fs, const char *path,
  {
  	int err;
  	if (!fs->compat || fs->compat >= 25)
@@ -22,10 +34,11 @@ diff -up fuse-2.7.2/lib/fuse.c.BAD fuse-2.7.2/lib/fuse.c
  	return err;
  }
  
-diff -up fuse-2.7.2/lib/fuse_lowlevel.c.BAD fuse-2.7.2/lib/fuse_lowlevel.c
---- lib/fuse_lowlevel.c	2008-01-21 09:57:52.000000000 -0500
-+++ lib/fuse_lowlevel.c	2008-01-21 09:58:15.000000000 -0500
-@@ -605,7 +605,7 @@ static void do_open(fuse_req_t req, fuse
+diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
+index c519bfb..d6275b5 100644
+--- a/lib/fuse_lowlevel.c
++++ b/lib/fuse_lowlevel.c
+@@ -716,7 +716,7 @@ static void do_open(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
  	fi.flags = arg->flags;
  
  	if (req->f->op.open)
@@ -34,3 +47,6 @@ diff -up fuse-2.7.2/lib/fuse_lowlevel.c.BAD fuse-2.7.2/lib/fuse_lowlevel.c
  	else
  		fuse_reply_open(req, &fi);
  }
+-- 
+1.7.3.1
+
diff --git a/fuse-0003-Fix-mounting-FUSE-fs-into-current-working-directory.patch b/fuse-0003-Fix-mounting-FUSE-fs-into-current-working-directory.patch
new file mode 100644
index 0000000..bd69cd0
--- /dev/null
+++ b/fuse-0003-Fix-mounting-FUSE-fs-into-current-working-directory.patch
@@ -0,0 +1,125 @@
+From d8bdebc639a84fa280153a466d4bb420fc9572bc Mon Sep 17 00:00:00 2001
+From: Peter Lemenkov <lemenkov at gmail.com>
+Date: Wed, 27 Oct 2010 16:29:45 +0400
+Subject: [PATCH 3/3] Fix mounting FUSE fs into current working directory
+
+See rhbz #622255 for bug description:
+
+https://bugzilla.redhat.com/622255
+
+Signed-off-by: Peter Lemenkov <lemenkov at gmail.com>
+---
+ lib/mount_util.c |   75 +++++++++++++-----------------------------------------
+ 1 files changed, 18 insertions(+), 57 deletions(-)
+
+diff --git a/lib/mount_util.c b/lib/mount_util.c
+index 33e6697..b9a0895 100644
+--- a/lib/mount_util.c
++++ b/lib/mount_util.c
+@@ -54,8 +54,8 @@ static int mtab_needs_update(const char *mnt)
+ 	return 1;
+ }
+ 
+-static int add_mount_legacy(const char *progname, const char *fsname,
+-			    const char *mnt, const char *type, const char *opts)
++static int add_mount(const char *progname, const char *fsname,
++		       const char *mnt, const char *type, const char *opts, int is_legacy)
+ {
+ 	int res;
+ 	int status;
+@@ -76,6 +76,14 @@ static int add_mount_legacy(const char *progname, const char *fsname,
+ 		goto out_restore;
+ 	}
+ 	if (res == 0) {
++		/*
++		 * Hide output, because old versions don't support
++		 * --no-canonicalize
++		 */
++		int fd = open("/dev/null", O_RDONLY);
++		dup2(fd, 1);
++		dup2(fd, 2);
++
+ 		char templ[] = "/tmp/fusermountXXXXXX";
+ 		char *tmp;
+ 
+@@ -99,59 +107,12 @@ static int add_mount_legacy(const char *progname, const char *fsname,
+ 			exit(1);
+ 		}
+ 		rmdir(tmp);
+-		execl("/bin/mount", "/bin/mount", "-i", "-f", "-t", type,
+-		      "-o", opts, fsname, mnt, NULL);
+-		fprintf(stderr, "%s: failed to execute /bin/mount: %s\n",
+-			progname, strerror(errno));
+-		exit(1);
+-	}
+-	res = waitpid(res, &status, 0);
+-	if (res == -1)
+-		fprintf(stderr, "%s: waitpid: %s\n", progname, strerror(errno));
+-
+-	if (status != 0)
+-		res = -1;
+-
+- out_restore:
+-	sigprocmask(SIG_SETMASK, &oldmask, NULL);
+-
+-	return res;
+-}
+-
+-static int add_mount(const char *progname, const char *fsname,
+-		       const char *mnt, const char *type, const char *opts)
+-{
+-	int res;
+-	int status;
+-	sigset_t blockmask;
+-	sigset_t oldmask;
+-
+-	sigemptyset(&blockmask);
+-	sigaddset(&blockmask, SIGCHLD);
+-	res = sigprocmask(SIG_BLOCK, &blockmask, &oldmask);
+-	if (res == -1) {
+-		fprintf(stderr, "%s: sigprocmask: %s\n", progname, strerror(errno));
+-		return -1;
+-	}
+-
+-	res = fork();
+-	if (res == -1) {
+-		fprintf(stderr, "%s: fork: %s\n", progname, strerror(errno));
+-		goto out_restore;
+-	}
+-	if (res == 0) {
+-		/*
+-		 * Hide output, because old versions don't support
+-		 * --no-canonicalize
+-		 */
+-		int fd = open("/dev/null", O_RDONLY);
+-		dup2(fd, 1);
+-		dup2(fd, 2);
+-
+-		sigprocmask(SIG_SETMASK, &oldmask, NULL);
+-		setuid(geteuid());
+-		execl("/bin/mount", "/bin/mount", "--no-canonicalize", "-i",
+-		      "-f", "-t", type, "-o", opts, fsname, mnt, NULL);
++		if(is_legacy)
++			execl("/bin/mount", "/bin/mount", "-i",
++					"-f", "-t", type, "-o", opts, fsname, mnt, NULL);
++		else
++			execl("/bin/mount", "/bin/mount", "--no-canonicalize", "-i",
++					"-f", "-t", type, "-o", opts, fsname, mnt, NULL);
+ 		fprintf(stderr, "%s: failed to execute /bin/mount: %s\n",
+ 			progname, strerror(errno));
+ 		exit(1);
+@@ -177,9 +138,9 @@ int fuse_mnt_add_mount(const char *progname, const char *fsname,
+ 	if (!mtab_needs_update(mnt))
+ 		return 0;
+ 
+-	res = add_mount(progname, fsname, mnt, type, opts);
++	res = add_mount(progname, fsname, mnt, type, opts, 0);
+ 	if (res == -1)
+-		res = add_mount_legacy(progname, fsname, mnt, type, opts);
++		res = add_mount(progname, fsname, mnt, type, opts, 1);
+ 
+ 	return res;
+ }
+-- 
+1.7.3.1
+
diff --git a/fuse.spec b/fuse.spec
index 54347af..9347880 100644
--- a/fuse.spec
+++ b/fuse.spec
@@ -1,6 +1,6 @@
 Name:           fuse
 Version:        2.8.5
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        File System in Userspace (FUSE) utilities
 
 Group:          System Environment/Base
@@ -8,8 +8,9 @@ License:        GPL+
 URL:            http://fuse.sf.net
 Source0:        http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
 
-Patch0:         fuse-udev_rules.patch
-Patch1:         fuse-openfix.patch
+Patch1:		fuse-0001-Fix-udev-rules-Fedora-specific.patch
+Patch2:		fuse-0002-More-parentheses.patch
+Patch3:		fuse-0003-Fix-mounting-FUSE-fs-into-current-working-directory.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 Requires:       kernel >= 2.6.14
 Requires:       which
@@ -50,8 +51,9 @@ pgk-config) to develop FUSE based applications/filesystems.
 %setup -q
 #disable device creation during build/install
 sed -i 's|mknod|echo Disabled: mknod |g' util/Makefile.in
-%patch0 -p0 -b .patch0
-%patch1 -p0 -b .patch1
+%patch1 -p1 -b .fix_udev_rules
+%patch2 -p1 -b .add_parentheses
+%patch3 -p1 -b allow_mount_to_cwd
 
 %build
 # Can't pass --disable-static here, or else the utils don't build
@@ -125,6 +127,9 @@ fi
 %{_includedir}/fuse
 
 %changelog
+* Wed Oct 27 2010 Peter Lemenkov <lemenkov at gmail.com> 2.8.5-2
+- Fixed rhbz #622255
+
 * Tue Oct 26 2010 Peter Lemenkov <lemenkov at gmail.com> 2.8.5-1
 - Ver. 2.8.5
 


More information about the scm-commits mailing list