mirror of
https://github.com/fuse-friends/fuse-native
synced 2024-10-27 18:34:01 +00:00
all tests pass except clean unmounting
This commit is contained in:
parent
1be624229f
commit
54a5d6c0b3
@ -649,8 +649,12 @@ FUSE_METHOD(readlink, 1, 1, (const char *path, char *linkname, size_t len), {
|
||||
}, {
|
||||
napi_create_string_utf8(env, l->path, NAPI_AUTO_LENGTH, &(argv[2]));
|
||||
}, {
|
||||
NAPI_ARGV_UTF8(linkname, 1024, 2)
|
||||
strncpy(linkname, l->linkname, l->len);
|
||||
printf("right before napi_argv_utf8\n");
|
||||
NAPI_ARGV_UTF8(linkname, l->len, 2)
|
||||
printf("right after napi_argv_utf8, len: %i, linkname: %s \n", l->len, linkname);
|
||||
strncpy(l->linkname, linkname, l->len);
|
||||
printf("after copy: l->linkname: %s\n", l->linkname);
|
||||
ret = 0;
|
||||
})
|
||||
|
||||
FUSE_METHOD(chown, 3, 0, (const char *path, uid_t uid, gid_t gid), {
|
||||
|
4
index.js
4
index.js
@ -270,6 +270,7 @@ class Fuse {
|
||||
return
|
||||
}
|
||||
this.ops.getattr(path, (err, stat) => {
|
||||
console.log('USER GETATT RESULT, path:', path, 'err:', err, 'stat:', stat)
|
||||
if (err) return signal(err, getStatArray())
|
||||
return signal(0, getStatArray(stat))
|
||||
})
|
||||
@ -298,7 +299,6 @@ class Fuse {
|
||||
|
||||
_open (signal, path, flags) {
|
||||
this.ops.open(path, flags, (err, fd) => {
|
||||
console.log('SIGNALLING WITH FD:', fd)
|
||||
return signal(err, fd)
|
||||
})
|
||||
}
|
||||
@ -480,9 +480,7 @@ class Fuse {
|
||||
mount (cb) {
|
||||
const opts = this._fuseOptions()
|
||||
console.log('mounting at %s with opts: %s', this.mnt, opts)
|
||||
console.log('handlers:', this._handlers)
|
||||
const implemented = this._getImplementedArray()
|
||||
console.log('implemented:', implemented)
|
||||
fs.stat(this.mnt, (err, stat) => {
|
||||
if (err) return cb(new Error('Mountpoint does not exist'))
|
||||
if (!stat.isDirectory()) return cb(new Error('Mountpoint is not a directory'))
|
||||
|
@ -1,16 +1,17 @@
|
||||
var mnt = require('./fixtures/mnt')
|
||||
var stat = require('./fixtures/stat')
|
||||
var fuse = require('../')
|
||||
var tape = require('tape')
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
const tape = require('tape')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const Fuse = require('../')
|
||||
const mnt = require('./fixtures/mnt')
|
||||
const stat = require('./fixtures/stat')
|
||||
|
||||
tape('readlink', function (t) {
|
||||
var ops = {
|
||||
force: true,
|
||||
readdir: function (path, cb) {
|
||||
if (path === '/') return cb(null, ['hello', 'link'])
|
||||
return cb(fuse.ENOENT)
|
||||
return cb(Fuse.ENOENT)
|
||||
},
|
||||
readlink: function (path, cb) {
|
||||
cb(0, 'hello')
|
||||
@ -19,7 +20,7 @@ tape('readlink', function (t) {
|
||||
if (path === '/') return cb(null, stat({ mode: 'dir', size: 4096 }))
|
||||
if (path === '/hello') return cb(null, stat({ mode: 'file', size: 11 }))
|
||||
if (path === '/link') return cb(null, stat({ mode: 'link', size: 5 }))
|
||||
return cb(fuse.ENOENT)
|
||||
return cb(Fuse.ENOENT)
|
||||
},
|
||||
open: function (path, flags, cb) {
|
||||
cb(0, 42)
|
||||
@ -32,7 +33,8 @@ tape('readlink', function (t) {
|
||||
}
|
||||
}
|
||||
|
||||
fuse.mount(mnt, ops, function (err) {
|
||||
const fuse = new Fuse(mnt, ops, { debug: true })
|
||||
fuse.mount(function (err) {
|
||||
t.error(err, 'no error')
|
||||
|
||||
fs.lstat(path.join(mnt, 'link'), function (err, stat) {
|
||||
@ -51,7 +53,7 @@ tape('readlink', function (t) {
|
||||
t.error(err, 'no error')
|
||||
t.same(buf, new Buffer('hello world'), 'can read link content')
|
||||
|
||||
fuse.unmount(mnt, function () {
|
||||
fuse.unmount( function () {
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
@ -12,17 +12,18 @@ tape('read', function (t) {
|
||||
force: true,
|
||||
readdir: function (path, cb) {
|
||||
if (path === '/') return cb(null, ['test'])
|
||||
return cb(fuse.ENOENT)
|
||||
return cb(Fuse.ENOENT)
|
||||
},
|
||||
getattr: function (path, cb) {
|
||||
if (path === '/') return cb(null, stat({ mode: 'dir', size: 4096 }))
|
||||
if (path === '/test') return cb(null, stat({ mode: 'file', size: 11 }))
|
||||
return cb(fuse.ENOENT)
|
||||
return cb(Fuse.ENOENT)
|
||||
},
|
||||
open: function (path, flags, cb) {
|
||||
cb(0, 42)
|
||||
},
|
||||
release: function (path, fd, cb) {
|
||||
|
||||
t.same(fd, 42, 'fd was passed to release')
|
||||
cb(0)
|
||||
},
|
||||
@ -35,7 +36,6 @@ tape('read', function (t) {
|
||||
}
|
||||
|
||||
const fuse = new Fuse(mnt, ops, { debug: true })
|
||||
|
||||
fuse.mount(function (err) {
|
||||
t.error(err, 'no error')
|
||||
|
||||
@ -53,7 +53,7 @@ tape('read', function (t) {
|
||||
fs.createReadStream(path.join(mnt, 'test'), { start: 6, end: 10 }).pipe(concat(function (buf) {
|
||||
t.same(buf, new Buffer('world'), 'partial read file + start offset')
|
||||
|
||||
fuse.unmount(mnt, function () {
|
||||
fuse.unmount(function () {
|
||||
t.end()
|
||||
})
|
||||
}))
|
||||
|
@ -1,9 +1,10 @@
|
||||
var mnt = require('./fixtures/mnt')
|
||||
var stat = require('./fixtures/stat')
|
||||
var fuse = require('../')
|
||||
var tape = require('tape')
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
const tape = require('tape')
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const Fuse = require('../')
|
||||
const mnt = require('./fixtures/mnt')
|
||||
const stat = require('./fixtures/stat')
|
||||
|
||||
tape('write', function (t) {
|
||||
var created = false
|
||||
@ -14,15 +15,15 @@ tape('write', function (t) {
|
||||
force: true,
|
||||
readdir: function (path, cb) {
|
||||
if (path === '/') return cb(null, created ? ['hello'] : [])
|
||||
return cb(fuse.ENOENT)
|
||||
return cb(Fuse.ENOENT)
|
||||
},
|
||||
truncate: function (path, size, cb) {
|
||||
cb(0)
|
||||
},
|
||||
getattr: function (path, cb) {
|
||||
if (path === '/') return cb(null, stat({ mode: 'dir', size: 4096 }))
|
||||
if (path === '/hello' && created) return cb(null, stat({ mode: 'file', size: size }))
|
||||
return cb(fuse.ENOENT)
|
||||
if (path === '/hello' && created) return cb(0, stat({ mode: 'file', size: size }))
|
||||
return cb(Fuse.ENOENT)
|
||||
},
|
||||
create: function (path, flags, cb) {
|
||||
t.ok(!created, 'file not created yet')
|
||||
@ -39,14 +40,15 @@ tape('write', function (t) {
|
||||
}
|
||||
}
|
||||
|
||||
fuse.mount(mnt, ops, function (err) {
|
||||
const fuse = new Fuse(mnt, ops, { debug: true })
|
||||
fuse.mount(function (err) {
|
||||
t.error(err, 'no error')
|
||||
|
||||
fs.writeFile(path.join(mnt, 'hello'), 'hello world', function (err) {
|
||||
t.error(err, 'no error')
|
||||
t.same(data.slice(0, size), new Buffer('hello world'), 'data was written')
|
||||
|
||||
fuse.unmount(mnt, function () {
|
||||
fuse.unmount(function () {
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user