I am developing a file system using libfuse
and need to find a way to intercept calls for storage size querying, i.e. du
and df
.
But I have been unable to identify how to this and unable to find an example that showcase this.
Looking at the debug output from my filesystem, doesn't give much information either, as I am unsure which call I should intercept.
For the df you can implement the statfs() operation, something like this:
In the example above, just to simplify, I query the root filesystem, than modify blocks available, but you can (and should) feel the complete statvfs structure with the information regarding your filesystem.
Now for the du, the man says: "Summarize disk usage of each FILE, recursively for directories", so every file will be queried. For this you need to implement the stat() operation.
Once those are implemented you have to add them do fuse_operations structure:
and pass it as a parameter to the fuse_main()