Fuse: How do I known the end of the file when write function calling?

262 Views Asked by At

When a file is written, the write function can only get offset and buffer, so i can't get the file total size. i want check the file end and do something else, like upload to cloud server. i tryed check with fuse block size 131072, like save last block size and compare with current, if current is smaller then last, i'll do something else. but this plan can't handle file that total size is 131072.

1

There are 1 best solutions below

0
On

It was answered in How to get entire file size when fuse write. A file copy is a series of write calls. The write calls are not aware that they are a part of a series of specific file writes. So there is no way to know inside write anything about the higher level file copy operation.

Since you are implementing a FUSE file system you can modify it to suite your need. For instance, on call to close, following a series of writes, you can decide to do something with the data now written, for instance upload to a server.