Search code examples
cfuse

fuse: How do I get the size of the file that is going to be written before it's written?


When a file is written, the write function corresponding with .write in fuse_operations is called for each file segment.

This means that for a larger file (e.g. 12720 bytes), the write function could be called 4 times with

1. size=4096, offset=0
2. size=4096, offset=4096
3. size=4096, offset=8192
4. size=432, offset=12288

because it has 4 segments with max segment size of 4096 bytes.

Inside the write function, I'd like to determine when the last segment size is being writen. I'm intending to put all the segments into a buffer, and use this last written segment to signal that the buffer now contains the entire object, so that it can be put somewhere else (such as an object store). By knowing the size of the object being written before it's written, I can just do a simple equality test file_size == size + offset to determine when the last segment is being written.


Solution

  • Apparently, I can't. I can only put the entire object somewhere else (such as an object store) after the file handler is closed.