mafintosh/fuse-bindings

fuse-bindings doesn't work on virtualbox

Tunga37 opened this issue · 4 comments

OS : xubuntu 18.04
node-version : 8.11.2

this simple example works fine on my host machine

var fuse = require('fuse-bindings')

var mountPath = process.platform !== 'win32' ? './mnt' : 'M:\\'

fuse.mount(mountPath, {
  readdir: function (path, cb) {
    console.log('readdir(%s)', path)
    if (path === '/') return cb(0, ['test'])
    cb(0)
  },
  getattr: function (path, cb) {
    console.log('getattr(%s)', path)
    if (path === '/') {
      cb(0, {
        mtime: new Date(),
        atime: new Date(),
        ctime: new Date(),
        nlink: 1,
        size: 100,
        mode: 16877,
        uid: process.getuid ? process.getuid() : 0,
        gid: process.getgid ? process.getgid() : 0
      })
      return
    }

    if (path === '/test') {
      cb(0, {
        mtime: new Date(),
        atime: new Date(),
        ctime: new Date(),
        nlink: 1,
        size: 12,
        mode: 33188,
        uid: process.getuid ? process.getuid() : 0,
        gid: process.getgid ? process.getgid() : 0
      })
      return
    }

    cb(fuse.ENOENT)
  },
  open: function (path, flags, cb) {
    console.log('open(%s, %d)', path, flags)
    cb(0, 42) // 42 is an fd
  },
  read: function (path, fd, buf, len, pos, cb) {
    console.log('read(%s, %d, %d, %d)', path, fd, len, pos)
    var str = 'hello world\n'.slice(pos, pos + len)
    if (!str) return cb(0)
    buf.write(str)
    return cb(str.length)
  }
}, function (err) {
  if (err) throw err
  console.log('filesystem mounted on ' + mountPath)
})

process.on('SIGINT', function () {
  fuse.unmount(mountPath, function (err) {
    if (err) {
      console.log('filesystem at ' + mountPath + ' not unmounted', err)
    } else {
      console.log('filesystem at ' + mountPath + ' unmounted')
    }
  })
})

but on guest machine (xubuntu 18.04) (when i run the same example) mounted directory is not accessible
https://i.imgur.com/ncvQxT9.png

Maybe a lack of permissions? At least for Docker FUSE needs to be enabled.

I'd double check that you have fuse and whatever other dependencies there are installed. It would probably error out during compilation if you didn't but node-gyp can be weird.

I have installed fuse, libfuse-dev and I've checked permissions (even started script as root). Also i restarted system after every installation.

I wonder if there are people who use fuse-bindings on virtualbox and they don't have this problem.

I solved this issue.
On guest linux system in file /etc/fuse.conf option 'user_allow_other' needs to be turned on and then
we have to mount our filesystem with option 'allow_other' like that

fuse.mount(mountPath, {
  options : ['allow_other'],
  readdir: function (path, cb) { ...