osxfuse / osxfuse

FUSE extends macOS by adding support for user space file systems
https://osxfuse.github.io/
Other
8.79k stars 515 forks source link

fgetattr after create fails with input/output error #887

Closed lwoggardner closed 10 months ago

lwoggardner commented 2 years ago

Hello, I am working on Ruby bindings for FUSE (ffi-libfuse) and (finally) getting it running on MacOS.

I'm almost there but having one issue with the fgetattr() call received after create().

Unlike callbacks to plain getattr() the stat struct in the call following create() has not been zeroed, and although the stat struct is filled appropriately (I think), and zero is returned, the fgetattr results in 'DELETE: 2 unique: 7, error: -5 (Input/output error), outsize: 16' which is then sent back to the client.

Any thoughts on what I might be doing wrong?

Debug output.

unique: 2, opcode: LOOKUP (1), nodeid: 1, insize: 50, pid: 1483
LOOKUP /hello.txt
getattr /hello.txt
Stat on getattr()
 {:dev=>0, :mode=>0, :nlink=>0, :ino=>0, :uid=>0, :gid=>0, :rdev=>0, :size=>0, :blocks=>0, :blksize=>0, :flags=>0, :gen=>0, :lspare=>0, :gspare=>0, :atime=>1970-01-01 00:00:00 UTC, :mtime=>1970-01-01 00:00:00 UTC, :ctime=>1970-01-01 00:00:00 UTC, :birthtime=>1970-01-01 00:00:00 UTC}
MemoryFS 2022-05-11T20:11:25+10:00 #<Thread:0x00007fa31005fa90 run> getattr(/hello.txt,#<FFI::Stat:0x00007fa31026f5b0>)
    => -2
   unique: 2, error: -2 (No such file or directory), outsize: 16
unique: 7, opcode: CREATE (35), nodeid: 1, insize: 66, pid: 1483
create flags: 0xa02 /hello.txt 0100644 umask=0000
MemoryFS 2022-05-11T20:11:25+10:00 #<Thread:0x00007fa31005fa90 run> create(/hello.txt,33188,#<FFI::Libfuse::FuseFileInfo:0x00007fa31026ca68>)
    => 0
   create[1700] flags: 0xa02 /hello.txt
fgetattr[1700] /hello.txt
Stat on fgetattr entry
{:dev=>323023840, :mode=>32675, :nlink=>0, :ino=>140732696082424, :uid=>3797662000, :gid=>32766, :rdev=>325057328, :size=>140732696082320, :blocks=>4546150478, :blksize=>-497305608, :flags=>32766, :gen=>3797661672, :lspare=>32766, :gspare=>140338381569424, :atime=>4461611-08-11 17:31:14.381751472 UTC, :mtime=>4461611-08-10 02:24:20.546246954 UTC, :ctime=>1970-01-02 14:59:24.37942064 UTC, :birthtime=>4461611-08-11 17:26:02.381751472 UTC}
Stat on fgetattr return
{:dev=>0, :mode=>33188, :nlink=>1, :ino=>0, :uid=>502, :gid=>20, :rdev=>0, :size=>0, :blocks=>0, :blksize=>0, :flags=>0, :gen=>0, :lspare=>0, :gspare=>0, :atime=>2022-05-11 10:11:25.033242 UTC, :mtime=>2022-05-11 10:11:25.033242 UTC, :ctime=>2022-05-11 10:11:25.033242 UTC, :birthtime=>2022-05-11 10:11:25.033242 UTC}
MemoryFS 2022-05-11T20:11:25+10:00 #<Thread:0x00007fa31005fa90 run> fgetattr(/hello.txt,#<FFI::Stat:0x00007fa310266988>,#<FFI::Libfuse::FuseFileInfo:0x00007fa3102668e8>)
    => 0
   NODEID: 2
release[1700] flags: 0xa02
MemoryFS 2022-05-11T20:11:25+10:00 #<Thread:0x00007fa31005fa90 run> release(/hello.txt,#<FFI::Libfuse::FuseFileInfo:0x00007fa31025d158>)
    => 0
DELETE: 2
   unique: 7, error: -5 (Input/output error), outsize: 16
lwoggardner commented 10 months ago

I have replicated this on Linux running FUSE 2.9.9 so unlinkely to be a osxfuse issue. fgetattr is removed in Fuse 3 , and in Fuse2 falls back getattr if not implemented so there's really no reason to implement them anyway. (similar applies to ftruncate/truncate).