| .gitignore | ||
| binding.gyp | ||
| example.js | ||
| fuse-bindings.cc | ||
| index.js | ||
| LICENSE | ||
| package.json | ||
| README.md | ||
fuse-bindings
Fully maintained fuse bindings for Node that aims to cover the entire FUSE api
npm install fuse-bindings
Created because fuse4js isn't maintained anymore and doesn't compile on iojs
Requirements
You need to have FUSE installed
- On Linux/Ubuntu 
sudo apt-get install libfuse-dev - On OSX install OSXFuse
 
Usage
Try creating an empty folder called mnt and run the below example
var fuse = require('fuse-bindings')
fuse.mount('./mnt', {
  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(),
        size: 100,
        mode: 16877,
        uid: process.getuid(),
        gid: process.getgid()
      })
      return
    }
    if (path === '/test') {
      cb(0, {
        mtime: new Date(),
        atime: new Date(),
        ctime: new Date(),
        size: 12,
        mode: 33188,
        uid: process.getuid(),
        gid: process.getgid()
      })
      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)
    if (!str) return cb(0)
    buf.write(str)
    return cb(str.length)
  }
})
process.on('SIGINT', function () {
  fuse.unmount('./mnt', function () {
    process.exit()
  })
})
API
fuse.mount(mnt, ops)
Mount a new filesystem on mnt.
Pass the FUSE operations you want to support as the ops argument.
fuse.unmount(mnt, [cb])
Unmount a filesystem
fuse.unmountSync(mnt)
Unmount a filesystem synchroniously
FUSE operations
Most of the FUSE api is supported.
ops.init(cb)ops.access(path, cb)ops.statfs(path, cb)ops.getattr(path, cb)ops.fgetattr(path, fd, cb)ops.flush(path, fd, cb)ops.fsync(path, fd, cb)ops.fsyncdir(path, fd, cb)ops.readdir(path, cb)ops.truncate(path, size, cb)ops.ftruncate(path, fd, size, cb)ops.readlink(path, result, cb)ops.chown(path, uid, gid, cb)ops.chmod(path, mode, cb)ops.setxattr(path, name, buf, length, offset, flags, cb)ops.getxattr(path, name, buf, length, offset, cb)ops.open(path, flags, cb)ops.opendir(path, flags, cb)ops.read(path, fd, buf, length, position, cb)ops.write(path, fd, buf, length, position, cb)ops.release(path, fd, cb)ops.releasedir(path, fd, cb)ops.create(path, mode, cb)ops.utimens(path, cb)ops.unlink(path, cb)ops.rename(src, dest, cb)ops.link(src, dest, cb)ops.symlink(src, dest, cb)ops.mkdir(path, cb)ops.rmdir(path, cb)ops.destroy(cb)
The goal is to support 100% of the API.
When using getattr you should return a stat object after the status code,
readdir expects an array of directory names, open an optional fd and
utimens an object with mtime and atime dates.
Both read and write passes the underlying fuse buffer without copying them to be as fast as possible.
You can pass mount options (i.e. direct_io etc) as ops.options = ['direct_io']
Error codes
The available error codes are exposes as well as properties. These include
fuse.EPERM === -1fuse.ENOENT === -2fuse.ESRCH === -3fuse.EINTR === -4fuse.EIO === -5fuse.ENXIO === -6fuse.E2BIG === -7fuse.ENOEXEC === -8fuse.EBADF === -9fuse.ECHILD === -10fuse.EAGAIN === -11fuse.ENOMEM === -12fuse.EACCES === -13fuse.EFAULT === -14fuse.ENOTBLK === -15fuse.EBUSY === -16fuse.EEXIST === -17fuse.EXDEV === -18fuse.ENODEV === -19fuse.ENOTDIR === -20fuse.EISDIR === -21fuse.EINVAL === -22fuse.ENFILE === -23fuse.EMFILE === -24fuse.ENOTTY === -25fuse.ETXTBSY === -26fuse.EFBIG === -27fuse.ENOSPC === -28fuse.ESPIPE === -29fuse.EROFS === -30fuse.EMLINK === -31fuse.EPIPE === -32fuse.EDOM === -33fuse.ERANGE === -34fuse.EDEADLK === -35fuse.ENAMETOOLONG === -36fuse.ENOLCK === -37fuse.ENOSYS === -38fuse.ENOTEMPTY === -39fuse.ELOOP === -40fuse.EWOULDBLOCK === -11fuse.ENOMSG === -42fuse.EIDRM === -43fuse.ECHRNG === -44fuse.EL2NSYNC === -45fuse.EL3HLT === -46fuse.EL3RST === -47fuse.ELNRNG === -48fuse.EUNATCH === -49fuse.ENOCSI === -50fuse.EL2HLT === -51fuse.EBADE === -52fuse.EBADR === -53fuse.EXFULL === -54fuse.ENOANO === -55fuse.EBADRQC === -56fuse.EBADSLT === -57fuse.EDEADLOCK === -35fuse.EBFONT === -59fuse.ENOSTR === -60fuse.ENODATA === -61fuse.ETIME === -62fuse.ENOSR === -63fuse.ENONET === -64fuse.ENOPKG === -65fuse.EREMOTE === -66fuse.ENOLINK === -67fuse.EADV === -68fuse.ESRMNT === -69fuse.ECOMM === -70fuse.EPROTO === -71fuse.EMULTIHOP === -72fuse.EDOTDOT === -73fuse.EBADMSG === -74fuse.EOVERFLOW === -75fuse.ENOTUNIQ === -76fuse.EBADFD === -77fuse.EREMCHG === -78fuse.ELIBACC === -79fuse.ELIBBAD === -80fuse.ELIBSCN === -81fuse.ELIBMAX === -82fuse.ELIBEXEC === -83fuse.EILSEQ === -84fuse.ERESTART === -85fuse.ESTRPIPE === -86fuse.EUSERS === -87fuse.ENOTSOCK === -88fuse.EDESTADDRREQ === -89fuse.EMSGSIZE === -90fuse.EPROTOTYPE === -91fuse.ENOPROTOOPT === -92fuse.EPROTONOSUPPORT === -93fuse.ESOCKTNOSUPPORT === -94fuse.EOPNOTSUPP === -95fuse.EPFNOSUPPORT === -96fuse.EAFNOSUPPORT === -97fuse.EADDRINUSE === -98fuse.EADDRNOTAVAIL === -99fuse.ENETDOWN === -100fuse.ENETUNREACH === -101fuse.ENETRESET === -102fuse.ECONNABORTED === -103fuse.ECONNRESET === -104fuse.ENOBUFS === -105fuse.EISCONN === -106fuse.ENOTCONN === -107fuse.ESHUTDOWN === -108fuse.ETOOMANYREFS === -109fuse.ETIMEDOUT === -110fuse.ECONNREFUSED === -111fuse.EHOSTDOWN === -112fuse.EHOSTUNREACH === -113fuse.EALREADY === -114fuse.EINPROGRESS === -115fuse.ESTALE === -116fuse.EUCLEAN === -117fuse.ENOTNAM === -118fuse.ENAVAIL === -119fuse.EISNAM === -120fuse.EREMOTEIO === -121fuse.EDQUOT === -122fuse.ENOMEDIUM === -123fuse.EMEDIUMTYPE === -124
License
MIT