fuse-friends / fuse-native

Multithreaded FUSE bindings for Node JS.
203 stars 29 forks source link

Cannot overwrite files #34

Closed algj closed 3 years ago

algj commented 3 years ago
$ echo "Hello World" > file
warning: An error occurred while redirecting file 'file'
open: Function not implemented
function open(path, flags, cb) {
    console.log(path, flags);
    return cb(0, 42);
}

It returns this flag:

/file 32769

Appending data or overwriting specific parts without overwriting whole file works fine. When appending data the flag is 33793.

But when I try to overwrite file with bash, I don't know how to implement it.

Any suggestions how to handle file overwrites? What shall I return instead of (0, 42)?

Debug (overwrite):

unique: 740, opcode: GETATTR (3), nodeid: 1, insize: 56, pid: 1810488
getattr /
   unique: 740, success, outsize: 120
unique: 742, opcode: OPENDIR (27), nodeid: 1, insize: 48, pid: 1810488
   unique: 742, success, outsize: 32
unique: 744, opcode: RELEASEDIR (29), nodeid: 1, insize: 64, pid: 0
   unique: 744, success, outsize: 16
unique: 746, opcode: LOOKUP (1), nodeid: 1, insize: 45, pid: 1810488
LOOKUP /file
getattr /file
   NODEID: 40
   unique: 746, success, outsize: 144
unique: 748, opcode: OPEN (14), nodeid: 40, insize: 48, pid: 1810488
open flags: 0x8001 /file
/file 32769
   open[42] flags: 0x8001 /file
   unique: 748, success, outsize: 32
unique: 750, opcode: SETATTR (4), nodeid: 40, insize: 128, pid: 1810488
   unique: 750, error: -38 (Function not implemented), outsize: 16
unique: 752, opcode: RELEASE (18), nodeid: 40, insize: 64, pid: 0
release[42] flags: 0x8001
   unique: 752, success, outsize: 16
unique: 754, opcode: LOOKUP (1), nodeid: 1, insize: 45, pid: 2435855

Debug (appending/overwriting specific parts, not whole file which works):

unique: 890, opcode: GETATTR (3), nodeid: 1, insize: 56, pid: 1810488
getattr /
   unique: 890, success, outsize: 120
unique: 892, opcode: OPENDIR (27), nodeid: 1, insize: 48, pid: 1810488
   unique: 892, success, outsize: 32
unique: 894, opcode: RELEASEDIR (29), nodeid: 1, insize: 64, pid: 0
   unique: 894, success, outsize: 16
unique: 896, opcode: LOOKUP (1), nodeid: 1, insize: 45, pid: 1810488
LOOKUP /file
getattr /file
   NODEID: 40
   unique: 896, success, outsize: 144
unique: 898, opcode: OPEN (14), nodeid: 40, insize: 48, pid: 1810488
open flags: 0x8401 /file
/file 33793
   open[42] flags: 0x8401 /file
   unique: 898, success, outsize: 32
unique: 900, opcode: WRITE (16), nodeid: 40, insize: 81, pid: 1810488
write[42] 1 bytes to 0 flags: 0x8401
...

Having problems with this too:

$ touch hi
touch: setting times of 'hi': Function not implemented

But it does create the file, so it's not a huge deal.

algj commented 3 years ago

I think those might solve the problem: ops.truncate(path, size, cb) ops.ftruncate(path, fd, size, cb)

I will code it in and see if it starts working.

Edit: Yeah, my bad, they're necessary :sweat_smile: