mirror of
https://github.com/fuse-friends/fuse-native
synced 2024-10-27 18:34:01 +00:00
Added statfs test
This commit is contained in:
parent
0d48cd8fc8
commit
994331abbe
@ -223,10 +223,13 @@ static void populate_statvfs (uint32_t *ints, struct statvfs* statvfs) {
|
|||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
|
|
||||||
FUSE_METHOD(statfs, 0, 1, (const char * path, struct statvfs *statvfs), {
|
FUSE_METHOD(statfs, 1, 1, (const char * path, struct statvfs *statvfs), {
|
||||||
|
l->path = path;
|
||||||
l->statvfs = statvfs;
|
l->statvfs = statvfs;
|
||||||
},
|
},
|
||||||
{},
|
{
|
||||||
|
napi_create_string_utf8(env, l->path, NAPI_AUTO_LENGTH, &(argv[2]));
|
||||||
|
},
|
||||||
{
|
{
|
||||||
NAPI_ARGV_BUFFER_CAST(uint32_t*, ints, 2)
|
NAPI_ARGV_BUFFER_CAST(uint32_t*, ints, 2)
|
||||||
populate_statvfs(ints, l->statvfs);
|
populate_statvfs(ints, l->statvfs);
|
||||||
|
6
index.js
6
index.js
@ -300,11 +300,11 @@ class Fuse extends Nanoresource {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
_op_statfs (signal) {
|
_op_statfs (signal, path) {
|
||||||
this.ops.statfs((err, statfs) => {
|
this.ops.statfs(path, (err, statfs) => {
|
||||||
if (err) return signal(err)
|
if (err) return signal(err)
|
||||||
const arr = getStatfsArray(statfs)
|
const arr = getStatfsArray(statfs)
|
||||||
return signal(null, [arr])
|
return signal(0, arr)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
37
test/statfs.js
Normal file
37
test/statfs.js
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
const { exec } = require('child_process')
|
||||||
|
var tape = require('tape')
|
||||||
|
|
||||||
|
var Fuse = require('../')
|
||||||
|
const mnt = require('./fixtures/mnt')
|
||||||
|
const stat = require('./fixtures/stat')
|
||||||
|
|
||||||
|
tape('statfs', function (t) {
|
||||||
|
const ops = {
|
||||||
|
force: true,
|
||||||
|
statfs: function (path, cb) {
|
||||||
|
return cb(0, {
|
||||||
|
bsize: 1000000,
|
||||||
|
frsize: 1000000,
|
||||||
|
blocks: 1000000,
|
||||||
|
bfree: 1000000,
|
||||||
|
bavail: 1000000,
|
||||||
|
files: 1000000,
|
||||||
|
ffree: 1000000,
|
||||||
|
favail: 1000000,
|
||||||
|
fsid: 1000000,
|
||||||
|
flag: 1000000,
|
||||||
|
namemax: 1000000
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
const fuse = new Fuse(mnt, ops, { debug: true })
|
||||||
|
fuse.mount(function (err) {
|
||||||
|
t.error(err, 'no error')
|
||||||
|
exec(`df ${mnt}`, (err) => {
|
||||||
|
t.error(err, 'no error')
|
||||||
|
fuse.unmount(function () {
|
||||||
|
t.end()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user