diff options
Diffstat (limited to 'xlators/mount')
| -rw-r--r-- | xlators/mount/fuse/src/Makefile.am | 3 | ||||
| -rw-r--r-- | xlators/mount/fuse/src/fuse-bridge.c | 59 | 
2 files changed, 20 insertions, 42 deletions
diff --git a/xlators/mount/fuse/src/Makefile.am b/xlators/mount/fuse/src/Makefile.am index c1e7755b5f8..0231e7be0b9 100644 --- a/xlators/mount/fuse/src/Makefile.am +++ b/xlators/mount/fuse/src/Makefile.am @@ -5,7 +5,8 @@ noinst_HEADERS = $(CONTRIBDIR)/fuse-include/fuse_kernel.h  xlator_LTLIBRARIES = fuse.la  xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/mount -fuse_la_SOURCES = fuse-bridge.c $(CONTRIBDIR)/fuse-lib/misc.c +fuse_la_SOURCES = fuse-bridge.c $(CONTRIBDIR)/fuse-lib/misc.c \ +	$(CONTRIBDIR)/fuse-lib/mount.c  fuse_la_LDFLAGS = -module -avoidversion -shared -nostartfiles  AM_CFLAGS = -fPIC -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D$(GF_HOST_OS) -Wall \ diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index a86c15b0a0a..d2c08b57eb9 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -40,12 +40,12 @@  #include "glusterfs.h"  #include "logging.h"  #include "xlator.h" -#include "glusterfs.h"  #include "defaults.h"  #include "common-utils.h"  #include "fuse_kernel.h"  #include "fuse-misc.h" +#include "fuse-mount.h"  #include "list.h"  #include "dict.h" @@ -2791,14 +2791,23 @@ fuse_thread_proc (void *data)                  }                  if (res == -1) { +                        if (errno == ENODEV || errno == EBADF) { +                                gf_log ("glusterfs-fuse", GF_LOG_NORMAL, +                                        "terminating upon getting %s when " +                                        "reading /dev/fuse", +                                        errno == ENODEV ? "ENODEV" : "EBADF"); + +                                break; +                        }                          if (errno != EINTR) {                                  gf_log ("glusterfs-fuse", GF_LOG_WARNING, -                                        "read from /dev/fuse returned -1 (%d)", errno); +                                        "read from /dev/fuse returned -1 (%s)", +                                        strerror (errno));                          } -                        if (errno == ENODEV || errno == EBADF) -                                break; +                          iobuf_unref (iobuf);                          FREE (iov_in[0].iov_base); +                          continue;                  }                  if (res < sizeof (finh)) { @@ -2903,7 +2912,6 @@ init (xlator_t *this_xl)          dict_t            *options = NULL;          char              *value_string = NULL;          char              *fsname = NULL; -        char              *mount_param = NULL;          fuse_private_t    *priv = NULL;          struct stat        stbuf = {0,};          int                i = 0; @@ -3016,39 +3024,11 @@ init (xlator_t *this_xl)                  goto cleanup_exit;          } -        priv->fd = open ("/dev/fuse", O_RDWR); -        if (priv->fd == -1) { -                gf_log ("glusterfs-fuse", GF_LOG_ERROR, -                        "cannot open /dev/fuse (%s)", strerror (errno)); - -                goto cleanup_exit; -        } -        ret = asprintf (&mount_param, -                        "allow_other,default_permissions,max_read=131072," -                        "fd=%i,rootmode=%o,user_id=%i,group_id=%i", -                        priv->fd, stbuf.st_mode & S_IFMT, getuid (), getgid ()); -        if (ret == -1) { -                gf_log ("glusterfs-fuse", GF_LOG_ERROR, -                        "Out of memory"); - -                goto cleanup_exit; -        } -        ret = mount (fsname, priv->mount_point, "fuse.glusterfs", 0, -                     mount_param); -        if (ret == -1 && errno == ENODEV) -                /* fs subtype support was added by 79c0b2df aka -                   v2.6.21-3159-g79c0b2d. Probably we have an -                   older kernel ... */ -                ret = mount (fsname, priv->mount_point, "fuse", 0, -                             mount_param); -        if (ret == -1) { -                gf_log ("glusterfs-fuse", GF_LOG_ERROR, -                        "mount failed (%s)", strerror (errno)); - +        priv->fd = gf_fuse_mount (priv->mount_point, fsname, +                                  "allow_other,default_permissions," +                                  "max_read=131072"); +        if (priv->fd == -1)                  goto cleanup_exit; -        } - -        FREE (mount_param);          this_xl->ctx->top = this_xl; @@ -3096,7 +3076,6 @@ init (xlator_t *this_xl)  cleanup_exit:          if (xl_name_allocated)                  FREE (this_xl->name); -        FREE (mount_param);          if (priv) {                  FREE (priv->mount_point);                  close (priv->fd); @@ -3118,8 +3097,6 @@ fini (xlator_t *this_xl)          if ((priv = this_xl->private) == NULL)                  return; -        close (priv->fd); -          if (dict_get (this_xl->options, ZR_MOUNTPOINT_OPT))                  mount_point = data_to_str (dict_get (this_xl->options,                                                       ZR_MOUNTPOINT_OPT)); @@ -3128,7 +3105,7 @@ fini (xlator_t *this_xl)                          "Unmounting '%s'.", mount_point);                  dict_del (this_xl->options, ZR_MOUNTPOINT_OPT); -                umount (mount_point); +                gf_fuse_unmount (mount_point, priv->fd);          }  }  | 
